Skip to content

Commit 432a555

Browse files
fetched is readOnly and serverVersion
1 parent e9e14a4 commit 432a555

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

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

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type { RootState } from '../../modules';
1313
import { changeStageOperator } from '../../modules/pipeline-builder/stage-editor';
1414
import type { StoreStage } from '../../modules/pipeline-builder/stage-editor';
1515

16-
import { filterStageOperators } from '../../utils/stage';
16+
import { filterStageOperators, isSearchStage } from '../../utils/stage';
1717
import { isAtlasOnly } from '../../utils/stage';
1818
import type { ServerEnvironment } from '../../modules/env';
1919

@@ -43,6 +43,9 @@ type StageOperatorSelectProps = {
4343
env: ServerEnvironment[];
4444
description: string;
4545
}[];
46+
serverVersion: string;
47+
isReadonlyView: boolean;
48+
pipelineBuilder: any;
4649
};
4750

4851
// exported for tests
@@ -52,13 +55,29 @@ export const StageOperatorSelect = ({
5255
selectedStage,
5356
isDisabled,
5457
stages,
58+
serverVersion,
59+
isReadonlyView,
60+
pipelineBuilder,
5561
}: StageOperatorSelectProps) => {
5662
const onStageOperatorSelected = useCallback(
5763
(name: string | null) => {
5864
onChange(index, name);
5965
},
6066
[onChange, index]
6167
);
68+
69+
const getStageDescription = (stage: {
70+
name: string;
71+
env: ServerEnvironment[];
72+
description: string;
73+
}) => {
74+
//const mongoDBMajorVersion = parseFloat(serverVersion.split('.').slice(0, 2).join('.'));
75+
if (isSearchStage(stage.name)) {
76+
return `${serverVersion} ${isReadonlyView}Atlas only. Requires MongoDB 8.1+ to run on a view. Performs a full-text search on the specified fields.`;
77+
}
78+
return (isAtlasOnly(stage.env) ? 'Atlas only. ' : '') + stage.description;
79+
};
80+
6281
return (
6382
<Combobox
6483
value={selectedStage}
@@ -75,9 +94,8 @@ export const StageOperatorSelect = ({
7594
data-testid={`combobox-option-stage-${stage.name}`}
7695
key={`combobox-option-stage-${index}`}
7796
value={stage.name}
78-
description={
79-
(isAtlasOnly(stage.env) ? 'Atlas only. ' : '') + stage.description
80-
}
97+
disabled={isSearchStage(stage.name)}
98+
description={getStageDescription(stage)}
8199
/>
82100
))}
83101
</Combobox>
@@ -113,6 +131,9 @@ export default withPreferences(
113131
selectedStage: stage.stageOperator,
114132
isDisabled: stage.disabled,
115133
stages: stages,
134+
serverVersion: state.serverVersion,
135+
isReadonlyView: !!state.sourceName,
136+
pipelineBuilder: state.pipelineBuilder,
116137
};
117138
},
118139
(dispatch: any, ownProps) => {

0 commit comments

Comments
 (0)