8
8
spacing ,
9
9
palette ,
10
10
MarketingModal ,
11
+ Theme ,
12
+ useDarkMode ,
11
13
} from '@mongodb-js/compass-components' ;
12
14
import { AiImageBanner } from './ai-image-banner' ;
13
15
import { closeOptInModal , optIn } from '../store/atlas-optin-reducer' ;
@@ -49,6 +51,49 @@ const bannerStyles = css({
49
51
textAlign : 'left' ,
50
52
} ) ;
51
53
54
+ // TODO: The LG MarketingModal does not provide a way to disable the button
55
+ // so this is a temporary workaround to make the button look disabled.
56
+ const focusSelector = `&:focus-visible, &[data-focus="true"]` ;
57
+ const hoverSelector = `&:hover, &[data-hover="true"]` ;
58
+ const activeSelector = `&:active, &[data-active="true"]` ;
59
+ const focusBoxShadow = ( color : string ) => `
60
+ 0 0 0 2px ${ color } ,
61
+ 0 0 0 4px ${ palette . blue . light1 } ;
62
+ ` ;
63
+ const disabledButtonStyles : Record < Theme , string > = {
64
+ [ Theme . Light ] : css `
65
+ & ,
66
+ ${ hoverSelector } , ${ activeSelector } {
67
+ background-color : ${ palette . gray . light2 } ;
68
+ border-color : ${ palette . gray . light1 } ;
69
+ color : ${ palette . gray . base } ;
70
+ box-shadow : none;
71
+ cursor : not-allowed;
72
+ }
73
+
74
+ ${ focusSelector } {
75
+ color : ${ palette . gray . base } ;
76
+ box-shadow : ${ focusBoxShadow ( palette . white ) } ;
77
+ }
78
+ ` ,
79
+
80
+ [ Theme . Dark ] : css `
81
+ & ,
82
+ ${ hoverSelector } , ${ activeSelector } {
83
+ background-color : ${ palette . gray . dark3 } ;
84
+ border-color : ${ palette . gray . dark2 } ;
85
+ color : ${ palette . gray . dark1 } ;
86
+ box-shadow : none;
87
+ cursor : not-allowed;
88
+ }
89
+
90
+ ${ focusSelector } {
91
+ color : ${ palette . gray . dark1 } ;
92
+ box-shadow : ${ focusBoxShadow ( palette . black ) } ;
93
+ }
94
+ ` ,
95
+ } ;
96
+
52
97
export const AIOptInModal : React . FunctionComponent < OptInModalProps > = ( {
53
98
isOptInModalVisible,
54
99
isOptInInProgress,
@@ -61,6 +106,9 @@ export const AIOptInModal: React.FunctionComponent<OptInModalProps> = ({
61
106
'enableGenAISampleDocumentPassingOnAtlasProject'
62
107
) ;
63
108
const track = useTelemetry ( ) ;
109
+ const darkMode = useDarkMode ( ) ;
110
+ const currentDisabledButtonStyles =
111
+ disabledButtonStyles [ darkMode ? Theme . Dark : Theme . Light ] ;
64
112
const PROJECT_SETTINGS_LINK = projectId
65
113
? window . location . origin + '/v2/' + projectId + '#/settings/groupSettings'
66
114
: null ;
@@ -90,6 +138,7 @@ export const AIOptInModal: React.FunctionComponent<OptInModalProps> = ({
90
138
open = { isOptInModalVisible }
91
139
onClose = { handleModalClose }
92
140
// TODO Button Disabling
141
+ className = { ! isProjectAIEnabled ? currentDisabledButtonStyles : undefined }
93
142
buttonText = "Use AI Features"
94
143
onButtonClick = { onConfirmClick }
95
144
linkText = "Not now"
0 commit comments