@@ -4,12 +4,12 @@ import {
44 Banner ,
55 Body ,
66 Link ,
7- ConfirmationModal ,
8- SpinLoader ,
7+ MarketingModal ,
98 css ,
109 spacing ,
11- H3 ,
1210 palette ,
11+ useDarkMode ,
12+ SpinLoader ,
1313} from '@mongodb-js/compass-components' ;
1414import { AiImageBanner } from './ai-image-banner' ;
1515import { closeOptInModal , optIn } from '../store/atlas-optin-reducer' ;
@@ -22,50 +22,44 @@ const GEN_AI_FAQ_LINK = 'https://www.mongodb.com/docs/generative-ai-faq/';
2222type OptInModalProps = {
2323 isOptInModalVisible : boolean ;
2424 isOptInInProgress : boolean ;
25+ isCloudOptIn : boolean ;
2526 onOptInModalClose : ( ) => void ;
2627 onOptInClick : ( ) => void ;
2728 projectId ?: string ;
2829} ;
2930
30- const titleStyles = css ( {
31- marginBottom : spacing [ 400 ] ,
32- marginTop : spacing [ 400 ] ,
33- marginLeft : spacing [ 500 ] ,
34- marginRight : spacing [ 500 ] ,
35- textAlign : 'center' ,
36- } ) ;
37-
38- const bodyStyles = css ( {
39- marginBottom : spacing [ 400 ] ,
40- marginTop : spacing [ 400 ] ,
41- marginLeft : spacing [ 300 ] ,
42- marginRight : spacing [ 300 ] ,
43- display : 'flex' ,
44- flexDirection : 'column' ,
45- alignItems : 'center' ,
46- textAlign : 'center' ,
47- } ) ;
48-
4931const disclaimerStyles = css ( {
5032 color : palette . gray . dark1 ,
51- marginTop : spacing [ 400 ] ,
52- marginLeft : spacing [ 800 ] ,
53- marginRight : spacing [ 800 ] ,
33+ paddingLeft : spacing [ 800 ] ,
34+ paddingRight : spacing [ 800 ] ,
5435} ) ;
5536
56- const bannerStyles = css ( {
57- padding : spacing [ 400 ] ,
58- marginTop : spacing [ 400 ] ,
59- textAlign : 'left' ,
37+ // TODO: The LG MarketingModal does not provide a way to disable a button
38+ // so this is a temporary workaround to make the button look disabled.
39+ const disableOptInButtonStyles = css ( {
40+ button : {
41+ opacity : 0.5 ,
42+ pointerEvents : 'none' ,
43+ cursor : 'not-allowed' ,
44+ } ,
6045} ) ;
61- const getButtonText = ( isOptInInProgress : boolean ) => {
46+
47+ const getButtonText = ( {
48+ isOptInInProgress,
49+ isCloudOptIn,
50+ darkMode,
51+ } : {
52+ isOptInInProgress : boolean ;
53+ isCloudOptIn : boolean ;
54+ darkMode : boolean | undefined ;
55+ } ) => {
6256 return (
6357 < >
64- Use Natural Language
65- { isOptInInProgress && (
58+ Opt-in AI features
59+ { isOptInInProgress && isCloudOptIn && (
6660 < >
6761
68- < SpinLoader darkMode = { true } > </ SpinLoader >
62+ < SpinLoader darkMode = { darkMode } > </ SpinLoader >
6963 </ >
7064 ) }
7165 </ >
@@ -75,12 +69,14 @@ const getButtonText = (isOptInInProgress: boolean) => {
7569export const AIOptInModal : React . FunctionComponent < OptInModalProps > = ( {
7670 isOptInModalVisible,
7771 isOptInInProgress,
72+ isCloudOptIn,
7873 onOptInModalClose,
7974 onOptInClick,
8075 projectId,
8176} ) => {
8277 const isProjectAIEnabled = usePreference ( 'enableGenAIFeaturesAtlasProject' ) ;
8378 const track = useTelemetry ( ) ;
79+ const darkMode = useDarkMode ( ) ;
8480 const PROJECT_SETTINGS_LINK = projectId
8581 ? window . location . origin + '/v2/' + projectId + '#/settings/groupSettings'
8682 : null ;
@@ -92,7 +88,7 @@ export const AIOptInModal: React.FunctionComponent<OptInModalProps> = ({
9288 } , [ isOptInModalVisible , track ] ) ;
9389
9490 const onConfirmClick = ( ) => {
95- if ( isOptInInProgress ) {
91+ if ( ( isOptInInProgress && isCloudOptIn ) || ! isProjectAIEnabled ) {
9692 return ;
9793 }
9894 onOptInClick ( ) ;
@@ -104,43 +100,23 @@ export const AIOptInModal: React.FunctionComponent<OptInModalProps> = ({
104100 } , [ track , onOptInModalClose ] ) ;
105101
106102 return (
107- < ConfirmationModal
108- open = { isOptInModalVisible }
109- title = ""
110- confirmButtonProps = { {
111- children : getButtonText ( isOptInInProgress ) ,
112- disabled : ! isProjectAIEnabled ,
113- onClick : onConfirmClick ,
114- } }
115- cancelButtonProps = { {
116- onClick : handleModalClose ,
117- } }
118- >
119- < Body className = { bodyStyles } >
120- < AiImageBanner > </ AiImageBanner >
121- < H3 className = { titleStyles } >
122- Use natural language to generate queries and pipelines
123- </ H3 >
124- Atlas users can now quickly create queries and aggregations with
125- MongoDB's intelligent AI-powered feature, available today.
126- < Banner
127- variant = { isProjectAIEnabled ? 'info' : 'warning' }
128- className = { bannerStyles }
129- >
130- { isProjectAIEnabled
131- ? 'AI features are enabled for project users with data access.'
132- : 'AI features are disabled for project users.' } { ' ' }
133- Project Owners can { isProjectAIEnabled ? 'disable' : 'enable' } Data
134- Explorer AI features in the{ ' ' }
135- { PROJECT_SETTINGS_LINK !== null ? (
136- < Link href = { PROJECT_SETTINGS_LINK } target = "_blank" >
137- Project Settings
138- </ Link >
139- ) : (
140- 'Project Settings'
141- ) }
142- .
143- </ Banner >
103+ < MarketingModal
104+ open = { true }
105+ onClose = { handleModalClose }
106+ className = { isCloudOptIn ? disableOptInButtonStyles : undefined }
107+ onButtonClick = { onConfirmClick }
108+ title = "Opt-in Gen AI-Powered features"
109+ // @ts -expect-error - buttonText expects a string but supports ReactNode as well.
110+ buttonText = { getButtonText ( {
111+ isOptInInProgress,
112+ isCloudOptIn,
113+ darkMode,
114+ } ) }
115+ linkText = "Not now"
116+ onLinkClick = { handleModalClose }
117+ graphic = { < AiImageBanner /> }
118+ darkMode = { darkMode }
119+ disclaimer = {
144120 < div className = { disclaimerStyles } >
145121 This is a feature powered by generative AI, and may give inaccurate
146122 responses. Please see our{ ' ' }
@@ -149,8 +125,49 @@ export const AIOptInModal: React.FunctionComponent<OptInModalProps> = ({
149125 </ Link > { ' ' }
150126 for more information.
151127 </ div >
128+ }
129+ >
130+ < Body
131+ style = { {
132+ textAlign : 'left' ,
133+ marginTop : spacing [ 300 ] ,
134+ } }
135+ >
136+ Opt in now MongoDB’s intelligent AI-powered features:
137+ < ul
138+ style = { {
139+ textAlign : 'left' ,
140+ marginTop : spacing [ 100 ] ,
141+ listStyle : 'disc' ,
142+ } }
143+ >
144+ < li > AI Assistant allows you to ask questions across connections</ li >
145+ < li > Natural Language Bar to create queries and aggregations</ li >
146+ { /* <li>Mock Data Generator to create AI powered sample data</li> */ }
147+ </ ul >
148+ { isCloudOptIn && (
149+ < Banner
150+ data-testid = "ai-optin-cloud-banner"
151+ variant = { isProjectAIEnabled ? 'info' : 'warning' }
152+ style = { { marginTop : spacing [ 300 ] } }
153+ >
154+ { isProjectAIEnabled
155+ ? 'AI features are enabled for project users with data access.'
156+ : 'AI features are disabled for project users.' } { ' ' }
157+ Project Owners can { isProjectAIEnabled ? 'disable' : 'enable' } Data
158+ Explorer AI features in the{ ' ' }
159+ { PROJECT_SETTINGS_LINK !== null ? (
160+ < Link href = { PROJECT_SETTINGS_LINK } target = "_blank" >
161+ Project Settings
162+ </ Link >
163+ ) : (
164+ 'Project Settings'
165+ ) }
166+ .
167+ </ Banner >
168+ ) }
152169 </ Body >
153- </ ConfirmationModal >
170+ </ MarketingModal >
154171 ) ;
155172} ;
156173
0 commit comments