Skip to content

Commit 2120e88

Browse files
authored
chore(preferences): remove enableQueryHistoryAutocomplete feature flag (#6918)
1 parent 1e95d95 commit 2120e88

File tree

2 files changed

+34
-58
lines changed

2 files changed

+34
-58
lines changed

packages/compass-preferences-model/src/feature-flags.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export type FeatureFlags = {
1919
showInsights: boolean;
2020
enableExportSchema: boolean;
2121
enableRenameCollectionModal: boolean;
22-
enableQueryHistoryAutocomplete: boolean;
2322
enableProxySupport: boolean;
2423
enableRollingIndexes: boolean;
2524
showDisabledConnections: boolean;
@@ -70,17 +69,6 @@ export const featureFlags: Required<{
7069
},
7170
},
7271

73-
/**
74-
* Feature flag for adding query history items to the query bar autocompletion. COMPASS-8096
75-
*/
76-
enableQueryHistoryAutocomplete: {
77-
stage: 'released',
78-
description: {
79-
short:
80-
'Enables showing query history items in the query bar autocomplete.',
81-
},
82-
},
83-
8472
/**
8573
* Feature flag for explicit proxy configuration support.
8674
*/

packages/compass-query-bar/src/components/option-editor.tsx

Lines changed: 34 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import type {
1515
} from '@mongodb-js/compass-editor';
1616
import {
1717
CodemirrorInlineEditor as InlineEditor,
18-
createQueryAutocompleter,
1918
createQueryWithHistoryAutocompleter,
2019
} from '@mongodb-js/compass-editor';
2120
import { connect } from '../stores/context';
@@ -119,9 +118,6 @@ export const OptionEditor: React.FunctionComponent<OptionEditorProps> = ({
119118
}) => {
120119
const editorContainerRef = useRef<HTMLDivElement>(null);
121120
const editorRef = useRef<EditorRef>(null);
122-
const isQueryHistoryAutocompleteEnabled = usePreference(
123-
'enableQueryHistoryAutocomplete'
124-
);
125121

126122
const focusRingProps = useFocusRing({
127123
outer: true,
@@ -158,52 +154,45 @@ export const OptionEditor: React.FunctionComponent<OptionEditorProps> = ({
158154
}, [optionName, recentQueries, favoriteQueries]);
159155

160156
const completer = useMemo(() => {
161-
return isQueryHistoryAutocompleteEnabled
162-
? createQueryWithHistoryAutocompleter({
163-
queryProperty: optionName,
164-
savedQueries,
165-
options: {
166-
fields: schemaFields,
167-
serverVersion,
168-
},
169-
onApply: (query: SavedQuery['queryProperties']) => {
170-
// When we are applying a query from `filter` field, we want to apply the whole query,
171-
// otherwise we want to preserve the other fields that are already in the current query.
172-
const fieldsToPreserve =
173-
optionName === 'filter'
174-
? []
175-
: QUERY_PROPERTIES.filter((x) => x !== optionName);
176-
onApplyQuery(query, fieldsToPreserve);
177-
if (!query[optionName]) {
178-
return;
179-
}
180-
const formFields = mapQueryToFormFields(
181-
{ maxTimeMS: maxTimeMSPreference },
182-
{
183-
...DEFAULT_FIELD_VALUES,
184-
...query,
185-
}
186-
);
187-
const optionFormField =
188-
formFields[optionName as keyof QueryFormFields];
189-
if (optionFormField?.string) {
190-
// When we did apply something we want to move the cursor to the end of the input.
191-
editorRef.current?.cursorDocEnd();
192-
}
193-
},
194-
theme: darkMode ? 'dark' : 'light',
195-
})
196-
: createQueryAutocompleter({
197-
fields: schemaFields,
198-
serverVersion,
199-
});
157+
return createQueryWithHistoryAutocompleter({
158+
queryProperty: optionName,
159+
savedQueries,
160+
options: {
161+
fields: schemaFields,
162+
serverVersion,
163+
},
164+
onApply: (query: SavedQuery['queryProperties']) => {
165+
// When we are applying a query from `filter` field, we want to apply the whole query,
166+
// otherwise we want to preserve the other fields that are already in the current query.
167+
const fieldsToPreserve =
168+
optionName === 'filter'
169+
? []
170+
: QUERY_PROPERTIES.filter((x) => x !== optionName);
171+
onApplyQuery(query, fieldsToPreserve);
172+
if (!query[optionName]) {
173+
return;
174+
}
175+
const formFields = mapQueryToFormFields(
176+
{ maxTimeMS: maxTimeMSPreference },
177+
{
178+
...DEFAULT_FIELD_VALUES,
179+
...query,
180+
}
181+
);
182+
const optionFormField = formFields[optionName as keyof QueryFormFields];
183+
if (optionFormField?.string) {
184+
// When we did apply something we want to move the cursor to the end of the input.
185+
editorRef.current?.cursorDocEnd();
186+
}
187+
},
188+
theme: darkMode ? 'dark' : 'light',
189+
});
200190
}, [
201191
maxTimeMSPreference,
202192
savedQueries,
203193
schemaFields,
204194
serverVersion,
205195
onApplyQuery,
206-
isQueryHistoryAutocompleteEnabled,
207196
darkMode,
208197
optionName,
209198
]);
@@ -216,8 +205,7 @@ export const OptionEditor: React.FunctionComponent<OptionEditorProps> = ({
216205
editorRef.current?.editorContents === '{}'
217206
) {
218207
editorRef.current?.applySnippet('\\{${}}');
219-
if (isQueryHistoryAutocompleteEnabled && editorRef.current?.editor)
220-
editorRef.current?.startCompletion();
208+
if (editorRef.current?.editor) editorRef.current?.startCompletion();
221209
}
222210
});
223211
}

0 commit comments

Comments
 (0)