Skip to content

Commit f116d9e

Browse files
PR comments
1 parent be9d03d commit f116d9e

File tree

7 files changed

+29
-10
lines changed

7 files changed

+29
-10
lines changed

packages/compass-generative-ai/src/atlas-ai-service.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { EJSON } from 'bson';
1212
import { signIntoAtlasWithModalPrompt } from './store/atlas-signin-reducer';
1313
import { getStore } from './store/atlas-ai-store';
1414
import { optIntoGenAIWithModalPrompt } from './store/atlas-optin-reducer';
15-
import { throwIfNotOk } from '../../atlas-service/src/util';
1615

1716
type GenerativeAiInput = {
1817
userInput: string;
@@ -452,15 +451,14 @@ export class AtlasAiService {
452451
{
453452
method: 'POST',
454453
body: JSON.stringify({
455-
isEnabled: true,
454+
value: true,
456455
}),
457456
headers: {
458457
'Content-Type': 'application/json',
459458
Accept: 'application/json',
460459
},
461460
}
462461
);
463-
await throwIfNotOk(res);
464462
await this.preferences.savePreferences({
465463
optInDataExplorerGenAIFeatures: true,
466464
});

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
Body,
55
Link,
66
MarketingModal,
7+
SpinLoader,
78
css,
89
spacing,
910
useDarkMode,
@@ -64,7 +65,22 @@ const AIOptInModal: React.FunctionComponent<OptInModalProps> = ({
6465
}
6566
open={isOptInModalVisible}
6667
onClose={onOptInModalClose}
67-
buttonText="Opt In to Generative AI Features"
68+
// @ts-expect-error leafygreen only allows strings, but we need to pass
69+
// icons
70+
buttonText={
71+
<>
72+
&nbsp;Opt in to Atlas to enable
73+
{isOptInInProgress && (
74+
<>
75+
&nbsp;
76+
<SpinLoader
77+
// Marketing modal button is always bright, spin loader in dark mode gets lost
78+
darkMode={false}
79+
></SpinLoader>
80+
</>
81+
)}
82+
</>
83+
}
6884
onButtonClick={() => {
6985
// We can't control buttons in marketing modal, so instead we just do
7086
// nothing when button is clicked and sign in is in progress
@@ -88,7 +104,7 @@ export default connect(
88104
(state: AtlasOptInState) => {
89105
return {
90106
isOptInModalVisible: state.optInReducer.isModalOpen,
91-
isOptInInProgress: state.state === 'in-progress',
107+
isOptInInProgress: state.optInReducer.state === 'in-progress',
92108
};
93109
},
94110
{ onOptInModalClose: closeOptInModal, onOptInClick: optIn }

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export default connect(
103103
(state: AtlasSignInState) => {
104104
return {
105105
isSignInModalVisible: state.signInReducer.isModalOpen,
106-
isSignInInProgress: state.state === 'in-progress',
106+
isSignInInProgress: state.signInReducer.state === 'in-progress',
107107
};
108108
},
109109
{ onSignInModalClose: closeSignInModal, onSignInClick: signIn }

packages/compass-generative-ai/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { atlasAuthServiceLocator } from '@mongodb-js/atlas-service/provider';
44
import { activatePlugin } from './store/atlas-ai-store';
55
import { AtlasAiPlugin } from './components';
66
import { atlasAiServiceLocator } from './provider';
7+
import { preferencesLocator } from 'compass-preferences-model/provider';
78

89
export const CompassGenerativeAIPlugin = registerHadronPlugin(
910
{
@@ -14,6 +15,7 @@ export const CompassGenerativeAIPlugin = registerHadronPlugin(
1415
{
1516
atlasAuthService: atlasAuthServiceLocator,
1617
atlasAiService: atlasAiServiceLocator,
18+
preferences: preferencesLocator,
1719
}
1820
);
1921

packages/compass-generative-ai/src/store/atlas-ai-store.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ export function getStore() {
1919
return store;
2020
}
2121
const reducer = combineReducers({
22-
signInReducer,
23-
optInReducer,
22+
signIn: signInReducer,
23+
optIn: optInReducer,
2424
});
2525

2626
export type CompassGenerativeAIExtraArgs = {

packages/compass-generative-ai/src/store/atlas-optin-reducer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export function getAttempt(id?: number | null): AttemptState {
115115
const attemptState = AttemptStateMap.get(id);
116116
if (!attemptState) {
117117
throw new Error(
118-
'Trying to get the state for a non-existing sign in attempt'
118+
'Trying to get the state for a non-existing opt in attempt'
119119
);
120120
}
121121
return attemptState;
@@ -297,7 +297,7 @@ export const closeOptInModal = (
297297

298298
export const cancelOptIn = (reason?: any): GenAIAtlasOptInThunkAction<void> => {
299299
return (dispatch, getState) => {
300-
// Can't cancel sign in after the flow was finished indicated by current
300+
// Can't cancel opt in after the flow was finished indicated by current
301301
// attempt id being set to null.
302302
if (getState().attemptId === null) {
303303
return;

packages/compass-web/src/entrypoint.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,9 @@ const CompassWeb = ({
270270
enableAggregationBuilderExtraOptions: true,
271271
enableImportExport: false,
272272
enableGenAIFeatures: true,
273+
enableGenAIFeaturesAtlasProject: false,
274+
enableGenAISampleDocumentPassingOnAtlasProject: false,
275+
enableGenAIFeaturesAtlasOrg: false,
273276
enableMultipleConnectionSystem: true,
274277
enablePerformanceAdvisorBanner: true,
275278
cloudFeatureRolloutAccess: {

0 commit comments

Comments
 (0)