Skip to content

Commit be9d03d

Browse files
PR comments
1 parent 842007a commit be9d03d

File tree

4 files changed

+21
-20
lines changed

4 files changed

+21
-20
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ 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';
1516

1617
type GenerativeAiInput = {
1718
userInput: string;
@@ -459,11 +460,10 @@ export class AtlasAiService {
459460
},
460461
}
461462
);
462-
if (res.ok) {
463-
await this.preferences.savePreferences({
464-
optInDataExplorerGenAIFeatures: true,
465-
});
466-
}
463+
await throwIfNotOk(res);
464+
await this.preferences.savePreferences({
465+
optInDataExplorerGenAIFeatures: true,
466+
});
467467
}
468468

469469
private validateAIFeatureEnablementResponse(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ const AIOptInModal: React.FunctionComponent<OptInModalProps> = ({
7171
if (isOptInInProgress) {
7272
return;
7373
}
74-
onOptInClick?.();
74+
onOptInClick();
7575
}}
7676
linkText="Cancel"
7777
onLinkClick={onOptInModalClose}

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

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ import thunk from 'redux-thunk';
33
import signInReducer, {
44
atlasServiceSignedOut,
55
atlasServiceSignedIn,
6-
//atlasServiceSignInTokenRefreshFailed,
7-
} from './atlas-signin-reducer';
8-
import optInReducer, {
96
atlasServiceSignInTokenRefreshFailed,
107
} from './atlas-signin-reducer';
8+
import optInReducer from './atlas-optin-reducer';
119
import type { AtlasAuthService } from '@mongodb-js/atlas-service/provider';
1210
import type { ActivateHelpers } from 'hadron-app-registry';
1311
import type { AtlasAiService } from '../atlas-ai-service';
@@ -25,13 +23,14 @@ const reducer = combineReducers({
2523
optInReducer,
2624
});
2725

28-
export type CompassGenerativeAIPluginServices = {
26+
export type CompassGenerativeAIExtraArgs = {
2927
atlasAuthService: AtlasAuthService;
3028
atlasAiService: AtlasAiService;
29+
preferences: PreferencesAccess;
3130
};
3231
export function activatePlugin(
3332
_: Record<string, never>,
34-
services: CompassGenerativeAIPluginServices,
33+
services: CompassGenerativeAIExtraArgs,
3534
{ cleanup }: ActivateHelpers
3635
) {
3736
store = configureStore(services);
@@ -52,19 +51,15 @@ export function activatePlugin(
5251
export function configureStore({
5352
atlasAuthService,
5453
atlasAiService,
55-
}: CompassGenerativeAIPluginServices) {
54+
preferences,
55+
}: CompassGenerativeAIExtraArgs) {
5656
const store = createStore(
5757
reducer,
5858
applyMiddleware(
59-
thunk.withExtraArgument({ atlasAuthService, atlasAiService })
59+
thunk.withExtraArgument({ atlasAuthService, atlasAiService, preferences })
6060
)
6161
);
6262
return store;
6363
}
6464

65-
export type GenAIAtlasExtraArgs = {
66-
preferences: PreferencesAccess;
67-
atlasAiService: AtlasAiService;
68-
};
69-
7065
export type CompassGenerativeAIServiceStore = ReturnType<typeof configureStore>;

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import type { Action, AnyAction, Reducer } from 'redux';
22
import type { ThunkAction } from 'redux-thunk';
3-
import type { GenAIAtlasExtraArgs } from './atlas-ai-store';
43
import { throwIfAborted } from '@mongodb-js/compass-utils';
4+
import type { AtlasAiService } from '../atlas-ai-service';
5+
import type { PreferencesAccess } from 'compass-preferences-model';
56

67
function isAction<A extends AnyAction>(
78
action: AnyAction,
@@ -28,7 +29,12 @@ export type AtlasOptInState = {
2829
export type GenAIAtlasOptInThunkAction<
2930
R,
3031
A extends AnyAction = AnyAction
31-
> = ThunkAction<R, AtlasOptInState, GenAIAtlasExtraArgs, A>;
32+
> = ThunkAction<
33+
R,
34+
AtlasOptInState,
35+
{ atlasAiService: AtlasAiService; preferences: PreferencesAccess },
36+
A
37+
>;
3238

3339
export const enum AtlasOptInActions {
3440
OpenOptInModal = 'compass-generative-ai/atlas-optin/OpenOptInModal',

0 commit comments

Comments
 (0)