Skip to content

Commit a342378

Browse files
committed
combine coveredqueries data into an obj
1 parent b75ab5f commit a342378

File tree

2 files changed

+28
-29
lines changed

2 files changed

+28
-29
lines changed

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

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,11 @@ export type IndexFlowSectionProps = {
115115
optimalQueries,
116116
showCoveredQueries,
117117
}: CoveredQueriesFetchedProps) => void;
118-
coveredQueries: JSX.Element | null;
119-
optimalQueries: string | JSX.Element | null;
120-
showCoveredQueries: boolean;
118+
coveredQueriesObj: {
119+
coveredQueries: JSX.Element | null;
120+
optimalQueries: string | JSX.Element | null;
121+
showCoveredQueries: boolean;
122+
};
121123
hasIndexFieldChanges: boolean;
122124
};
123125

@@ -207,9 +209,8 @@ const IndexFlowSection = ({
207209
onErrorEncountered,
208210
onErrorCleared,
209211
onCoveredQueriesFetched,
210-
coveredQueries,
211-
optimalQueries,
212-
showCoveredQueries,
212+
coveredQueriesObj,
213+
213214
hasIndexFieldChanges,
214215
}: IndexFlowSectionProps) => {
215216
const darkMode = useDarkMode();
@@ -260,6 +261,9 @@ const IndexFlowSection = ({
260261
onErrorCleared();
261262
}, [fields, onErrorCleared]);
262263

264+
const { coveredQueries, optimalQueries, showCoveredQueries } =
265+
coveredQueriesObj;
266+
263267
return (
264268
<div>
265269
<div
@@ -423,16 +427,9 @@ const IndexFlowSection = ({
423427
};
424428

425429
const mapState = ({ createIndex }: RootState) => {
426-
const {
427-
coveredQueries,
428-
optimalQueries,
429-
showCoveredQueries,
430-
hasIndexFieldChanges,
431-
} = createIndex;
430+
const { coveredQueriesObj, hasIndexFieldChanges } = createIndex;
432431
return {
433-
coveredQueries,
434-
optimalQueries,
435-
showCoveredQueries,
432+
coveredQueriesObj,
436433
hasIndexFieldChanges,
437434
};
438435
};

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

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -323,14 +323,12 @@ export type State = {
323323
// to determine whether there has been new query changes since user last pressed the button
324324
hasQueryChanges: boolean;
325325

326-
// covered queries for the index flow
327-
coveredQueries: JSX.Element | null;
328-
329-
// optimal queries for the index flow
330-
optimalQueries: string | JSX.Element | null;
331-
332-
// to determine whether to show the covered queries or not
333-
showCoveredQueries: boolean;
326+
// covered queries obj for the index flow
327+
coveredQueriesObj: {
328+
coveredQueries: JSX.Element | null;
329+
optimalQueries: string | JSX.Element | null;
330+
showCoveredQueries: boolean;
331+
};
334332

335333
// to determine whether there has been new index field changes since user last pressed the button
336334
hasIndexFieldChanges: boolean;
@@ -352,9 +350,11 @@ export const INITIAL_STATE: State = {
352350
hasQueryChanges: false,
353351

354352
// Index flow
355-
coveredQueries: null,
356-
optimalQueries: null,
357-
showCoveredQueries: false,
353+
coveredQueriesObj: {
354+
coveredQueries: null,
355+
optimalQueries: null,
356+
showCoveredQueries: false,
357+
},
358358
hasIndexFieldChanges: false,
359359
};
360360

@@ -866,9 +866,11 @@ const reducer: Reducer<State, Action> = (state = INITIAL_STATE, action) => {
866866
) {
867867
return {
868868
...state,
869-
coveredQueries: action.coveredQueries,
870-
optimalQueries: action.optimalQueries,
871-
showCoveredQueries: action.showCoveredQueries,
869+
coveredQueriesObj: {
870+
coveredQueries: action.coveredQueries,
871+
optimalQueries: action.optimalQueries,
872+
showCoveredQueries: action.showCoveredQueries,
873+
},
872874
hasIndexFieldChanges: false,
873875
};
874876
}

0 commit comments

Comments
 (0)