-
Notifications
You must be signed in to change notification settings - Fork 228
chore(compass-generative-ai): update Gen AI opt-in modal COMPASS-9593 #7164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,12 +4,12 @@ import { | |
Banner, | ||
Body, | ||
Link, | ||
ConfirmationModal, | ||
SpinLoader, | ||
MarketingModal, | ||
css, | ||
spacing, | ||
H3, | ||
palette, | ||
useDarkMode, | ||
SpinLoader, | ||
} from '@mongodb-js/compass-components'; | ||
import { AiImageBanner } from './ai-image-banner'; | ||
import { closeOptInModal, optIn } from '../store/atlas-optin-reducer'; | ||
|
@@ -22,50 +22,42 @@ const GEN_AI_FAQ_LINK = 'https://www.mongodb.com/docs/generative-ai-faq/'; | |
type OptInModalProps = { | ||
isOptInModalVisible: boolean; | ||
isOptInInProgress: boolean; | ||
isCloudOptIn: boolean; | ||
onOptInModalClose: () => void; | ||
onOptInClick: () => void; | ||
projectId?: string; | ||
}; | ||
|
||
const titleStyles = css({ | ||
marginBottom: spacing[400], | ||
marginTop: spacing[400], | ||
marginLeft: spacing[500], | ||
marginRight: spacing[500], | ||
textAlign: 'center', | ||
}); | ||
|
||
const bodyStyles = css({ | ||
marginBottom: spacing[400], | ||
marginTop: spacing[400], | ||
marginLeft: spacing[300], | ||
marginRight: spacing[300], | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
textAlign: 'center', | ||
}); | ||
|
||
const disclaimerStyles = css({ | ||
color: palette.gray.dark1, | ||
marginTop: spacing[400], | ||
marginLeft: spacing[800], | ||
marginRight: spacing[800], | ||
paddingLeft: spacing[800], | ||
paddingRight: spacing[800], | ||
}); | ||
|
||
const bannerStyles = css({ | ||
padding: spacing[400], | ||
marginTop: spacing[400], | ||
textAlign: 'left', | ||
// TODO: The LG MarketingModal does not provide a way to disable a button | ||
// so this is a temporary workaround to make the button look disabled. | ||
const disableOptInButtonStyles = css({ | ||
button: { | ||
opacity: 0.5, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would we want to try to match the LG disabled styles, as in https://github.com/mongodb/leafygreen-ui/blob/f9f9ed34f21b561986c46c502cf13ef82a0e7c3c/packages/button/src/Button/Button.styles.ts#L360? Using |
||
pointerEvents: 'none', | ||
cursor: 'not-allowed', | ||
}, | ||
}); | ||
const getButtonText = (isOptInInProgress: boolean) => { | ||
|
||
const getButtonText = ({ | ||
isOptInInProgress, | ||
darkMode, | ||
}: { | ||
isOptInInProgress: boolean; | ||
darkMode: boolean | undefined; | ||
}) => { | ||
return ( | ||
<> | ||
Use Natural Language | ||
Opt-in AI features | ||
{isOptInInProgress && ( | ||
<> | ||
| ||
<SpinLoader darkMode={true}></SpinLoader> | ||
<SpinLoader darkMode={darkMode}></SpinLoader> | ||
</> | ||
)} | ||
</> | ||
|
@@ -75,12 +67,14 @@ const getButtonText = (isOptInInProgress: boolean) => { | |
export const AIOptInModal: React.FunctionComponent<OptInModalProps> = ({ | ||
isOptInModalVisible, | ||
isOptInInProgress, | ||
isCloudOptIn, | ||
onOptInModalClose, | ||
onOptInClick, | ||
projectId, | ||
}) => { | ||
const isProjectAIEnabled = usePreference('enableGenAIFeaturesAtlasProject'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
const track = useTelemetry(); | ||
const darkMode = useDarkMode(); | ||
const PROJECT_SETTINGS_LINK = projectId | ||
? window.location.origin + '/v2/' + projectId + '#/settings/groupSettings' | ||
: null; | ||
|
@@ -92,7 +86,7 @@ export const AIOptInModal: React.FunctionComponent<OptInModalProps> = ({ | |
}, [isOptInModalVisible, track]); | ||
|
||
const onConfirmClick = () => { | ||
if (isOptInInProgress) { | ||
if (isOptInInProgress || !isProjectAIEnabled) { | ||
return; | ||
} | ||
onOptInClick(); | ||
|
@@ -104,43 +98,22 @@ export const AIOptInModal: React.FunctionComponent<OptInModalProps> = ({ | |
}, [track, onOptInModalClose]); | ||
|
||
return ( | ||
<ConfirmationModal | ||
open={isOptInModalVisible} | ||
title="" | ||
confirmButtonProps={{ | ||
children: getButtonText(isOptInInProgress), | ||
disabled: !isProjectAIEnabled, | ||
onClick: onConfirmClick, | ||
}} | ||
cancelButtonProps={{ | ||
onClick: handleModalClose, | ||
}} | ||
> | ||
<Body className={bodyStyles}> | ||
<AiImageBanner></AiImageBanner> | ||
<H3 className={titleStyles}> | ||
Use natural language to generate queries and pipelines | ||
</H3> | ||
Atlas users can now quickly create queries and aggregations with | ||
MongoDB's intelligent AI-powered feature, available today. | ||
<Banner | ||
variant={isProjectAIEnabled ? 'info' : 'warning'} | ||
className={bannerStyles} | ||
> | ||
{isProjectAIEnabled | ||
? 'AI features are enabled for project users with data access.' | ||
: 'AI features are disabled for project users.'}{' '} | ||
Project Owners can {isProjectAIEnabled ? 'disable' : 'enable'} Data | ||
Explorer AI features in the{' '} | ||
{PROJECT_SETTINGS_LINK !== null ? ( | ||
<Link href={PROJECT_SETTINGS_LINK} target="_blank"> | ||
Project Settings | ||
</Link> | ||
) : ( | ||
'Project Settings' | ||
)} | ||
. | ||
</Banner> | ||
<MarketingModal | ||
open={true} | ||
onClose={handleModalClose} | ||
className={isCloudOptIn ? disableOptInButtonStyles : undefined} | ||
onButtonClick={onConfirmClick} | ||
title="Opt-in Gen AI-Powered features" | ||
// @ts-expect-error - buttonText expects a string but supports ReactNode as well. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also maybe a LG ticket for this? |
||
buttonText={getButtonText({ | ||
isOptInInProgress, | ||
darkMode, | ||
})} | ||
linkText="Not now" | ||
onLinkClick={handleModalClose} | ||
graphic={<AiImageBanner />} | ||
darkMode={darkMode} | ||
disclaimer={ | ||
<div className={disclaimerStyles}> | ||
This is a feature powered by generative AI, and may give inaccurate | ||
responses. Please see our{' '} | ||
|
@@ -149,8 +122,49 @@ export const AIOptInModal: React.FunctionComponent<OptInModalProps> = ({ | |
</Link>{' '} | ||
for more information. | ||
</div> | ||
} | ||
> | ||
<Body | ||
style={{ | ||
textAlign: 'left', | ||
marginTop: spacing[300], | ||
}} | ||
> | ||
Opt in now MongoDB’s intelligent AI-powered features: | ||
<ul | ||
style={{ | ||
textAlign: 'left', | ||
marginTop: spacing[100], | ||
listStyle: 'disc', | ||
}} | ||
> | ||
<li>AI Assistant allows you to ask questions across connections</li> | ||
<li>Natural Language Bar to create queries and aggregations</li> | ||
{/* <li>Mock Data Generator to create AI powered sample data</li> */} | ||
</ul> | ||
{isCloudOptIn && ( | ||
<Banner | ||
data-testid="ai-optin-cloud-banner" | ||
variant={isProjectAIEnabled ? 'info' : 'warning'} | ||
style={{ marginTop: spacing[300] }} | ||
> | ||
{isProjectAIEnabled | ||
? 'AI features are enabled for project users with data access.' | ||
: 'AI features are disabled for project users.'}{' '} | ||
Project Owners can {isProjectAIEnabled ? 'disable' : 'enable'} Data | ||
Explorer AI features in the{' '} | ||
{PROJECT_SETTINGS_LINK !== null ? ( | ||
<Link href={PROJECT_SETTINGS_LINK} target="_blank"> | ||
Project Settings | ||
</Link> | ||
) : ( | ||
'Project Settings' | ||
)} | ||
. | ||
</Banner> | ||
)} | ||
</Body> | ||
</ConfirmationModal> | ||
</MarketingModal> | ||
); | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seemed like the best solution, I can open a LG ticket and link it here if this sounds good.