Skip to content

Commit 8de58b2

Browse files
fix hook issue
1 parent 6c900aa commit 8de58b2

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

packages/compass-aggregations/src/components/stage-toolbar/stage-operator-select.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,19 @@ export const StageOperatorSelect = ({
100100
collectionStats,
101101
stages,
102102
}: StageOperatorSelectProps) => {
103+
const enableAtlasSearchIndexes = usePreference('enableAtlasSearchIndexes');
104+
// filter out search stages for data explorer
105+
const filteredStages =
106+
isReadonlyView && enableAtlasSearchIndexes
107+
? stages
108+
: stages.filter((stage) => !isSearchStage(stage.name));
109+
103110
const onStageOperatorSelected = useCallback(
104111
(name: string | null) => {
105112
onChange(index, name);
106113
},
107114
[onChange, index]
108115
);
109-
110116
const versionIncompatibleCompass =
111117
!VIEW_PIPELINE_UTILS.isVersionSearchCompatibleForViewsCompass(
112118
serverVersion
@@ -132,7 +138,7 @@ export const StageOperatorSelect = ({
132138
data-testid="stage-operator-combobox"
133139
className={comboboxStyles}
134140
>
135-
{stages.map((stage: Stage, index) => (
141+
{filteredStages.map((stage: Stage, index) => (
136142
<ComboboxOption
137143
data-testid={`combobox-option-stage-${stage.name}`}
138144
key={`combobox-option-stage-${index}`}
@@ -174,7 +180,6 @@ export default withPreferences(
174180
isTimeSeries: state.isTimeSeries,
175181
sourceName: state.sourceName,
176182
preferencesReadOnly: ownProps.readOnly,
177-
enableAtlasSearchIndexes: usePreference('enableAtlasSearchIndexes'),
178183
});
179184
return {
180185
selectedStage: stage.stageOperator,

packages/compass-aggregations/src/utils/stage.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,12 @@ export const filterStageOperators = ({
4747
isTimeSeries,
4848
sourceName,
4949
preferencesReadOnly,
50-
enableAtlasSearchIndexes,
5150
}: {
5251
serverVersion: string;
5352
env: ServerEnvironment;
5453
isTimeSeries: boolean;
5554
sourceName: string | null;
5655
preferencesReadOnly: boolean;
57-
enableAtlasSearchIndexes: boolean;
5856
}): FilteredStageOperators => {
5957
const namespaceType = isTimeSeries
6058
? TIME_SERIES
@@ -68,7 +66,6 @@ export const filterStageOperators = ({
6866
env,
6967
namespaceType,
7068
preferencesReadOnly,
71-
enableAtlasSearchIndexes,
7269
});
7370

7471
if (FilteredStagesCache.has(cacheKey)) {
@@ -88,14 +85,9 @@ export const filterStageOperators = ({
8885
[env, ATLAS]
8986
: env,
9087
},
91-
})
92-
.filter((op) => {
93-
return disallowOutputStagesOnCompassReadonly(op, preferencesReadOnly);
94-
})
95-
.filter((op) => {
96-
// if enableAtlasSearchIndexes is false, only allow non search stages
97-
return enableAtlasSearchIndexes || !isSearchStage(op.value);
98-
});
88+
}).filter((op) => {
89+
return disallowOutputStagesOnCompassReadonly(op, preferencesReadOnly);
90+
});
9991

10092
FilteredStagesCache.set(cacheKey, filteredStages);
10193

0 commit comments

Comments
 (0)