Skip to content

Commit 9ee4bda

Browse files
committed
fix more typing and clear error when there's new changes
1 parent 45cf375 commit 9ee4bda

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

packages/compass-crud/src/stores/crud-store.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1834,7 +1834,7 @@ class CrudStoreImpl
18341834

18351835
openCreateIndexModal() {
18361836
this.localAppRegistry.emit('open-create-index-modal', {
1837-
query: EJSON.serialize(this.queryBar.getLastAppliedQuery('crud').filter),
1837+
query: EJSON.serialize(this.queryBar.getLastAppliedQuery('crud')?.filter),
18381838
});
18391839
}
18401840

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ import {
1313
Tooltip,
1414
} from '@mongodb-js/compass-components';
1515
import React, { useState, useCallback, useEffect } from 'react';
16-
import { errorEncountered, type Field } from '../../modules/create-index';
16+
import {
17+
errorCleared,
18+
errorEncountered,
19+
type Field,
20+
} from '../../modules/create-index';
1721
import MDBCodeViewer from './mdb-code-viewer';
1822
import { areAllFieldsFilledIn } from '../../utils/create-index-modal-validation';
1923
import { connect } from 'react-redux';
@@ -82,6 +86,7 @@ export type IndexFlowSectionProps = {
8286
dbName: string;
8387
collectionName: string;
8488
onErrorEncountered: (error: string) => void;
89+
onErrorCleared: () => void;
8590
};
8691

8792
const generateCoveredQueries = (
@@ -163,6 +168,7 @@ const IndexFlowSection = ({
163168
dbName,
164169
collectionName,
165170
onErrorEncountered,
171+
onErrorCleared,
166172
}: IndexFlowSectionProps) => {
167173
const [isCodeEquivalentToggleChecked, setIsCodeEquivalentToggleChecked] =
168174
useState(false);
@@ -218,7 +224,8 @@ const IndexFlowSection = ({
218224

219225
useEffect(() => {
220226
setHasFieldChanges(true);
221-
}, [fields]);
227+
onErrorCleared();
228+
}, [fields, onErrorCleared]);
222229

223230
const { coveredQueries, optimalQueries, showCoveredQueries } =
224231
coveredQueriesObj;
@@ -346,6 +353,7 @@ const mapState = () => {
346353

347354
const mapDispatch = {
348355
onErrorEncountered: errorEncountered,
356+
onErrorCleared: errorCleared,
349357
};
350358

351359
export default connect(mapState, mapDispatch)(IndexFlowSection);

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

Lines changed: 2 additions & 2 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?: BsonDocument;
80+
query?: string;
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: BsonDocument | null;
317+
query: string | null;
318318
};
319319

320320
export const INITIAL_STATE: State = {

0 commit comments

Comments
 (0)