Skip to content

Commit 90317a1

Browse files
committed
fixed up typing more
1 parent a0f5f19 commit 90317a1

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

packages/compass-indexes/src/components/create-index-form/create-index-form.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { usePreference } from 'compass-preferences-model/provider';
2121
import IndexFlowSection from './index-flow-section';
2222
import QueryFlowSection from './query-flow-section';
2323
import toNS from 'mongodb-ns';
24+
import type { Document as BsonDocument } from 'bson';
2425

2526
const createIndexModalFieldsStyles = css({
2627
margin: `${spacing[600]}px 0 ${spacing[800]}px 0`,
@@ -49,7 +50,7 @@ export type CreateIndexFormProps = {
4950
onRemoveFieldClick: (idx: number) => void; // Minus icon.
5051
onTabClick: (tab: Tab) => void;
5152
showIndexesGuidanceVariant?: boolean;
52-
query: string | null;
53+
query: BsonDocument | null;
5354
};
5455

5556
function CreateIndexForm({

packages/compass-indexes/src/components/create-index-form/query-flow-section.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
useFocusRing,
88
ParagraphSkeleton,
99
} from '@mongodb-js/compass-components';
10+
import type { Document as BsonDocument } from 'bson';
1011
import React, { useMemo, useCallback } from 'react';
1112
import { css, spacing } from '@mongodb-js/compass-components';
1213
import {
@@ -106,9 +107,11 @@ const QueryFlowSection = ({
106107
}: SuggestedIndexFetchedProps) => Promise<void>;
107108
indexSuggestions: Record<string, number> | null;
108109
fetchingSuggestionsState: IndexSuggestionState;
109-
initialQuery: string | null;
110+
initialQuery: BsonDocument | null;
110111
}) => {
111-
const [inputQuery, setInputQuery] = React.useState(initialQuery || '');
112+
const [inputQuery, setInputQuery] = React.useState(
113+
JSON.stringify(initialQuery ?? '', null, 2)
114+
);
112115
const [hasNewChanges, setHasNewChanges] = React.useState(
113116
initialQuery !== null
114117
);

packages/compass-indexes/src/components/create-index-modal/create-index-modal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@ import {
2929
import { useConnectionInfoRef } from '@mongodb-js/compass-connections/provider';
3030
import { usePreference } from 'compass-preferences-model/provider';
3131
import CreateIndexModalHeader from './create-index-modal-header';
32+
import type { Document as BsonDocument } from 'bson';
3233

3334
type CreateIndexModalProps = React.ComponentProps<typeof CreateIndexForm> & {
3435
isVisible: boolean;
3536
namespace: string;
3637
error: string | null;
3738
currentTab: Tab;
38-
query: string | null;
39+
query: BsonDocument | null;
3940
onErrorBannerCloseClick: () => void;
4041
onCreateIndexClick: () => void;
4142
onCancelCreateIndexClick: () => void;

packages/compass-indexes/src/modules/create-index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ type ErrorClearedAction = {
7777

7878
export type CreateIndexOpenedAction = {
7979
type: ActionTypes.CreateIndexOpened;
80-
query?: string;
80+
query?: BsonDocument;
8181
};
8282

8383
type CreateIndexClosedAction = {
@@ -314,7 +314,7 @@ export type State = {
314314
sampleDocs: Array<Document> | null;
315315

316316
// base query to be used for query flow index creation
317-
query: string | null;
317+
query: BsonDocument | null;
318318
};
319319

320320
export const INITIAL_STATE: State = {
@@ -339,7 +339,7 @@ function getInitialState(): State {
339339

340340
//-------
341341

342-
export const createIndexOpened = (query?: BsonDocument) => ({
342+
export const createIndexOpened = (query?: Document) => ({
343343
type: ActionTypes.CreateIndexOpened,
344344
query,
345345
});

0 commit comments

Comments
 (0)