@@ -3,11 +3,8 @@ import SettingsList from './settings-list';
33import {
44 usePreference ,
55 featureFlags ,
6- withPreferences ,
6+ useIsAIFeatureEnabled ,
77} from 'compass-preferences-model' ;
8- import type { UserPreferences } from 'compass-preferences-model' ;
9- import { connect } from 'react-redux' ;
10- import type { RootState } from '../../stores' ;
118import { ConnectedAtlasLoginSettings } from './atlas-login' ;
129import { css , spacing } from '@mongodb-js/compass-components' ;
1310
@@ -36,33 +33,24 @@ function useShouldShowPreviewFeatures(): boolean {
3633
3734export function useShouldShowFeaturePreviewSettings ( ) : boolean {
3835 // We want show the feature preview settings tab if:
36+ // - AI feature flag is enabled
3937 // - there are feature flags in preview stage
4038 // - or if:
4139 // - we are in a development environment or 'showDevFeatureFlags' is explicitly enabled
4240 // - and there are feature flags in 'development' stage.
43- // - AI feature flag is enabled
44- const enableAIWithoutRolloutAccess = usePreference (
45- 'enableAIWithoutRolloutAccess' ,
46- React
47- ) ;
48- const enableAIExperience = usePreference ( 'enableAIExperience' , React ) ;
41+ const aiFeatureEnabled = useIsAIFeatureEnabled ( React ) ;
4942 const showDevFeatures = useShouldShowDevFeatures ( ) ;
5043 const showPreviewFeatures = useShouldShowPreviewFeatures ( ) ;
51- return (
52- enableAIWithoutRolloutAccess ||
53- enableAIExperience ||
54- showPreviewFeatures ||
55- showDevFeatures
56- ) ;
44+
45+ return aiFeatureEnabled || showPreviewFeatures || showDevFeatures ;
5746}
5847
5948const atlasSettingsContainerStyles = css ( {
6049 marginTop : spacing [ 3 ] ,
6150} ) ;
6251
63- export const FeaturePreviewSettings : React . FunctionComponent < {
64- showAtlasLoginSettings ?: boolean ;
65- } > = ( { showAtlasLoginSettings } ) => {
52+ export const FeaturePreviewSettings : React . FunctionComponent = ( ) => {
53+ const aiFeatureEnabled = useIsAIFeatureEnabled ( React ) ;
6654 const showPreviewFeatures = useShouldShowPreviewFeatures ( ) ;
6755 const showDevFeatures = useShouldShowDevFeatures ( ) ;
6856
@@ -73,7 +61,7 @@ export const FeaturePreviewSettings: React.FunctionComponent<{
7361 your own risk!
7462 </ div >
7563
76- { showAtlasLoginSettings && (
64+ { aiFeatureEnabled && (
7765 < div className = { atlasSettingsContainerStyles } >
7866 < ConnectedAtlasLoginSettings > </ ConnectedAtlasLoginSettings >
7967 </ div >
@@ -92,30 +80,4 @@ export const FeaturePreviewSettings: React.FunctionComponent<{
9280 ) ;
9381} ;
9482
95- export default withPreferences (
96- connect (
97- (
98- state : RootState ,
99- ownProps : {
100- enableAIExperience ?: boolean ;
101- enableAIWithoutRolloutAccess ?: boolean ;
102- cloudFeatureRolloutAccess ?: UserPreferences [ 'cloudFeatureRolloutAccess' ] ;
103- }
104- ) => {
105- return {
106- showAtlasLoginSettings :
107- state . settings . settings . enableAIExperience ||
108- [ 'authenticated' , 'in-progress' ] . includes ( state . atlasLogin . status ) ||
109- ownProps . enableAIExperience ||
110- ownProps . enableAIWithoutRolloutAccess ||
111- ownProps . cloudFeatureRolloutAccess ?. GEN_AI_COMPASS ,
112- } ;
113- }
114- ) ( FeaturePreviewSettings ) ,
115- [
116- 'enableAIExperience' ,
117- 'cloudFeatureRolloutAccess' ,
118- 'enableAIWithoutRolloutAccess' ,
119- ] ,
120- React
121- ) ;
83+ export default FeaturePreviewSettings ;
0 commit comments