@@ -3,11 +3,8 @@ import SettingsList from './settings-list';
3
3
import {
4
4
usePreference ,
5
5
featureFlags ,
6
- withPreferences ,
6
+ useIsAIFeatureEnabled ,
7
7
} from 'compass-preferences-model' ;
8
- import type { UserPreferences } from 'compass-preferences-model' ;
9
- import { connect } from 'react-redux' ;
10
- import type { RootState } from '../../stores' ;
11
8
import { ConnectedAtlasLoginSettings } from './atlas-login' ;
12
9
import { css , spacing } from '@mongodb-js/compass-components' ;
13
10
@@ -36,33 +33,24 @@ function useShouldShowPreviewFeatures(): boolean {
36
33
37
34
export function useShouldShowFeaturePreviewSettings ( ) : boolean {
38
35
// We want show the feature preview settings tab if:
36
+ // - AI feature flag is enabled
39
37
// - there are feature flags in preview stage
40
38
// - or if:
41
39
// - we are in a development environment or 'showDevFeatureFlags' is explicitly enabled
42
40
// - 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 ) ;
49
42
const showDevFeatures = useShouldShowDevFeatures ( ) ;
50
43
const showPreviewFeatures = useShouldShowPreviewFeatures ( ) ;
51
- return (
52
- enableAIWithoutRolloutAccess ||
53
- enableAIExperience ||
54
- showPreviewFeatures ||
55
- showDevFeatures
56
- ) ;
44
+
45
+ return aiFeatureEnabled || showPreviewFeatures || showDevFeatures ;
57
46
}
58
47
59
48
const atlasSettingsContainerStyles = css ( {
60
49
marginTop : spacing [ 3 ] ,
61
50
} ) ;
62
51
63
- export const FeaturePreviewSettings : React . FunctionComponent < {
64
- showAtlasLoginSettings ?: boolean ;
65
- } > = ( { showAtlasLoginSettings } ) => {
52
+ export const FeaturePreviewSettings : React . FunctionComponent = ( ) => {
53
+ const aiFeatureEnabled = useIsAIFeatureEnabled ( React ) ;
66
54
const showPreviewFeatures = useShouldShowPreviewFeatures ( ) ;
67
55
const showDevFeatures = useShouldShowDevFeatures ( ) ;
68
56
@@ -73,7 +61,7 @@ export const FeaturePreviewSettings: React.FunctionComponent<{
73
61
your own risk!
74
62
</ div >
75
63
76
- { showAtlasLoginSettings && (
64
+ { aiFeatureEnabled && (
77
65
< div className = { atlasSettingsContainerStyles } >
78
66
< ConnectedAtlasLoginSettings > </ ConnectedAtlasLoginSettings >
79
67
</ div >
@@ -92,30 +80,4 @@ export const FeaturePreviewSettings: React.FunctionComponent<{
92
80
) ;
93
81
} ;
94
82
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