Skip to content

Commit a752813

Browse files
authored
chore(settings): use sandbox preference for showing ai settings COMPASS-7800 (#5691)
1 parent d8ab142 commit a752813

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

packages/compass-settings/src/components/modal.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,15 @@ import Sidebar from './sidebar';
2020
import { saveSettings, closeModal } from '../stores/settings';
2121
import type { RootState } from '../stores';
2222
import { getUserInfo } from '../stores/atlas-login';
23-
import {
24-
useIsAIFeatureEnabled,
25-
useHasAIFeatureCloudRolloutAccess,
26-
} from 'compass-preferences-model/provider';
23+
import { useHasAIFeatureCloudRolloutAccess } from 'compass-preferences-model/provider';
2724

2825
type Settings = {
2926
name: string;
3027
component: React.ComponentType;
3128
};
3229

3330
type SettingsModalProps = {
31+
isAIFeatureEnabled: boolean;
3432
isOpen: boolean;
3533
isOIDCEnabled: boolean;
3634
onMount?: () => void;
@@ -60,14 +58,14 @@ const settingsStyles = css(
6058
);
6159

6260
export const SettingsModal: React.FunctionComponent<SettingsModalProps> = ({
61+
isAIFeatureEnabled,
6362
isOpen,
6463
onMount,
6564
onClose,
6665
onSave,
6766
isOIDCEnabled,
6867
hasChangedSettings,
6968
}) => {
70-
const aiFeatureEnabled = useIsAIFeatureEnabled();
7169
const aiFeatureHasCloudRolloutAccess = useHasAIFeatureCloudRolloutAccess();
7270
const onMountRef = useRef(onMount);
7371

@@ -84,7 +82,7 @@ export const SettingsModal: React.FunctionComponent<SettingsModalProps> = ({
8482
if (
8583
isOIDCEnabled ||
8684
// because oidc options overlap with atlas login used for ai feature
87-
aiFeatureEnabled
85+
isAIFeatureEnabled
8886
) {
8987
settings.push({
9088
name: 'OIDC (Preview)',
@@ -151,6 +149,7 @@ export default connect(
151149
return {
152150
isOpen:
153151
state.settings.isModalOpen && state.settings.loadingState === 'ready',
152+
isAIFeatureEnabled: !!state.settings.settings.enableGenAIFeatures,
154153
isOIDCEnabled: !!state.settings.settings.enableOidc,
155154
hasChangedSettings: state.settings.updatedFields.length > 0,
156155
};
Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
import React from 'react';
2+
import { css, spacing } from '@mongodb-js/compass-components';
3+
import { connect } from 'react-redux';
4+
5+
import type { RootState } from '../../stores';
26
import SettingsList from './settings-list';
3-
import { useIsAIFeatureEnabled } from 'compass-preferences-model/provider';
47
import { ConnectedAtlasLoginSettings } from './atlas-login';
5-
import { css, spacing } from '@mongodb-js/compass-components';
68

79
const atlasSettingsContainerStyles = css({
810
marginTop: spacing[3],
911
});
1012

11-
export const GenAISettings: React.FunctionComponent = () => {
12-
const aiFeatureEnabled = useIsAIFeatureEnabled();
13-
13+
export const GenAISettings: React.FunctionComponent<{
14+
isAIFeatureEnabled: boolean;
15+
}> = ({ isAIFeatureEnabled }) => {
1416
return (
1517
<div data-testid="gen-ai-settings">
1618
<div>
@@ -20,7 +22,7 @@ export const GenAISettings: React.FunctionComponent = () => {
2022
</div>
2123
<SettingsList fields={['enableGenAIFeatures']} />
2224

23-
{aiFeatureEnabled && (
25+
{isAIFeatureEnabled && (
2426
<>
2527
<div className={atlasSettingsContainerStyles}>
2628
<ConnectedAtlasLoginSettings></ConnectedAtlasLoginSettings>
@@ -32,4 +34,8 @@ export const GenAISettings: React.FunctionComponent = () => {
3234
);
3335
};
3436

35-
export default GenAISettings;
37+
const mapState = (state: RootState) => ({
38+
isAIFeatureEnabled: !!state.settings.settings.enableGenAIFeatures,
39+
});
40+
41+
export default connect(mapState, null)(GenAISettings);

0 commit comments

Comments
 (0)