Skip to content

Commit cc2aed6

Browse files
committed
fix: make onAddToQuery optional
1 parent 79d0a26 commit cc2aed6

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

packages/compass-components/src/components/document-list/document.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const HadronDocument: React.FunctionComponent<{
8686
editing?: boolean;
8787
onEditStart?: () => void;
8888
extraGutterWidth?: number;
89-
onAddToQuery?: (field: string, value: any) => void;
89+
onAddToQuery?: (field: string, value: unknown) => void;
9090
}> = ({
9191
value: document,
9292
editable = false,

packages/compass-components/src/components/document-list/element.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ export const HadronElement: React.FunctionComponent<{
428428
lineNumberSize: number;
429429
onAddElement(el: HadronElementType): void;
430430
extraGutterWidth?: number;
431-
onAddToQuery: (field: string, value: any) => void;
431+
onAddToQuery?: (field: string, value: unknown) => void;
432432
}> = ({
433433
value: element,
434434
editable,
@@ -464,12 +464,16 @@ export const HadronElement: React.FunctionComponent<{
464464
// Add context menu hook for the field
465465
const fieldContextMenuRef = useContextMenuItems(
466466
() => [
467-
{
468-
label: 'Add to query',
469-
onAction: () => {
470-
onAddToQuery(key.value, element.generateObject());
471-
},
472-
},
467+
...(onAddToQuery
468+
? [
469+
{
470+
label: 'Add to query',
471+
onAction: () => {
472+
onAddToQuery(key.value, element.generateObject());
473+
},
474+
},
475+
]
476+
: []),
473477
{
474478
label: 'Copy field & value',
475479
onAction: () => {

packages/compass-crud/src/components/editable-document.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export type EditableDocumentProps = {
2121
openInsertDocumentDialog?: CrudActions['openInsertDocumentDialog'];
2222
copyToClipboard?: CrudActions['copyToClipboard'];
2323
showInsights?: boolean;
24-
onAddToQuery?: (field: string, value: any) => void;
24+
onAddToQuery?: (field: string, value: unknown) => void;
2525
};
2626

2727
type EditableDocumentState = {

packages/compass-crud/src/components/readonly-document.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export type ReadonlyDocumentProps = {
2929
openInsertDocumentDialog?: (doc: BSONObject, cloned: boolean) => void;
3030
doc: Document;
3131
showInsights?: boolean;
32-
onAddToQuery?: (field: string, value: any) => void;
32+
onAddToQuery?: (field: string, value: unknown) => void;
3333
};
3434

3535
type ReadonlyDocumentState = {

0 commit comments

Comments
 (0)