Skip to content

Commit c8170e1

Browse files
jcobisncarbon
authored andcommitted
WIP
1 parent a700444 commit c8170e1

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

packages/compass-generative-ai/src/components/ai-optin-modal.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ describe('AIOptInModal Component', function () {
9191
</PreferencesProvider>
9292
);
9393
const button = screen.getByText('Use AI Features').closest('button');
94-
expect(button?.getAttribute('aria-disabled')).to.equal('true');
94+
expect(button?.style.cursor).to.equal('not-allowed');
9595
});
9696

9797
describe('conditional banner messages', function () {

packages/compass-generative-ai/src/components/ai-optin-modal.tsx

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {
88
spacing,
99
palette,
1010
MarketingModal,
11+
Theme,
12+
useDarkMode,
1113
} from '@mongodb-js/compass-components';
1214
import { AiImageBanner } from './ai-image-banner';
1315
import { closeOptInModal, optIn } from '../store/atlas-optin-reducer';
@@ -49,6 +51,49 @@ const bannerStyles = css({
4951
textAlign: 'left',
5052
});
5153

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+
5297
export const AIOptInModal: React.FunctionComponent<OptInModalProps> = ({
5398
isOptInModalVisible,
5499
isOptInInProgress,
@@ -61,6 +106,9 @@ export const AIOptInModal: React.FunctionComponent<OptInModalProps> = ({
61106
'enableGenAISampleDocumentPassingOnAtlasProject'
62107
);
63108
const track = useTelemetry();
109+
const darkMode = useDarkMode();
110+
const currentDisabledButtonStyles =
111+
disabledButtonStyles[darkMode ? Theme.Dark : Theme.Light];
64112
const PROJECT_SETTINGS_LINK = projectId
65113
? window.location.origin + '/v2/' + projectId + '#/settings/groupSettings'
66114
: null;
@@ -90,6 +138,7 @@ export const AIOptInModal: React.FunctionComponent<OptInModalProps> = ({
90138
open={isOptInModalVisible}
91139
onClose={handleModalClose}
92140
// TODO Button Disabling
141+
className={!isProjectAIEnabled ? currentDisabledButtonStyles : undefined}
93142
buttonText="Use AI Features"
94143
onButtonClick={onConfirmClick}
95144
linkText="Not now"

0 commit comments

Comments
 (0)