Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
c2025de
moving prefs up nit from prev ticket
ruchitharajaghatta Nov 8, 2024
c8ae0da
new modal and plugin
ruchitharajaghatta Nov 13, 2024
ae6fa98
removing console log
ruchitharajaghatta Nov 13, 2024
ab8a8eb
review comments and checking for userPref
ruchitharajaghatta Nov 13, 2024
842007a
review comments and checking for userPref
ruchitharajaghatta Nov 13, 2024
be9d03d
PR comments
ruchitharajaghatta Nov 14, 2024
f116d9e
PR comments
ruchitharajaghatta Nov 14, 2024
ee684c7
reducer name change bug
ruchitharajaghatta Nov 14, 2024
cdbfa92
fixing post request
ruchitharajaghatta Nov 14, 2024
c09dd67
fixing test setup failures
ruchitharajaghatta Nov 14, 2024
8cda9e9
new test and sign in test fixes
ruchitharajaghatta Nov 14, 2024
102306b
Merge branch 'main' of github.com:mongodb-js/compass into COMPASS-8378
ruchitharajaghatta Nov 14, 2024
514816c
test fixes and package.json fix
ruchitharajaghatta Nov 15, 2024
59bdf04
state name update
ruchitharajaghatta Nov 15, 2024
d2c0290
test and reducer bug fixes
ruchitharajaghatta Nov 15, 2024
3803589
commenting out errors for evg patch
ruchitharajaghatta Nov 15, 2024
ce2cccd
fixing reducer type and entrypoint
ruchitharajaghatta Nov 18, 2024
b41dbda
npm check fix
ruchitharajaghatta Nov 18, 2024
618d1de
removing ts-expect-errors
ruchitharajaghatta Nov 18, 2024
222487e
Merge branch 'main' of github.com:mongodb-js/compass into COMPASS-8378
ruchitharajaghatta Nov 18, 2024
5feb8fd
prettier fix
ruchitharajaghatta Nov 18, 2024
ce93dd2
taking out duplicated function
ruchitharajaghatta Nov 18, 2024
587e4ec
addressing changes to modal
ruchitharajaghatta Nov 19, 2024
e0c897d
fixing flag for disabling opt in
ruchitharajaghatta Nov 19, 2024
5fbf83f
nit:
ruchitharajaghatta Nov 19, 2024
0f554dc
nits and fixing optin modal/refctoring for projid
ruchitharajaghatta Nov 20, 2024
712aefb
merge main
ruchitharajaghatta Nov 20, 2024
072e8d6
fixing projectID prop
ruchitharajaghatta Nov 20, 2024
b69f37f
optin modal test
ruchitharajaghatta Nov 21, 2024
f93424a
test tweak
ruchitharajaghatta Nov 21, 2024
baedb84
nit comment
ruchitharajaghatta Nov 21, 2024
2860198
Merge branch 'main' of github.com:mongodb-js/compass into COMPASS-8378
ruchitharajaghatta Nov 22, 2024
70d3566
fixing projectId
ruchitharajaghatta Nov 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/compass-generative-ai/src/atlas-ai-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { EJSON } from 'bson';
import { signIntoAtlasWithModalPrompt } from './store/atlas-signin-reducer';
import { getStore } from './store/atlas-ai-store';
import { optIntoGenAIWithModalPrompt } from './store/atlas-optin-reducer';
import { throwIfNotOk } from '../../atlas-service/src/util';

type GenerativeAiInput = {
userInput: string;
Expand Down Expand Up @@ -459,11 +460,10 @@ export class AtlasAiService {
},
}
);
if (res.ok) {
await this.preferences.savePreferences({
optInDataExplorerGenAIFeatures: true,
});
}
await throwIfNotOk(res);
await this.preferences.savePreferences({
optInDataExplorerGenAIFeatures: true,
});
}

private validateAIFeatureEnablementResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const AIOptInModal: React.FunctionComponent<OptInModalProps> = ({
if (isOptInInProgress) {
return;
}
onOptInClick?.();
onOptInClick();
}}
linkText="Cancel"
onLinkClick={onOptInModalClose}
Expand Down
19 changes: 7 additions & 12 deletions packages/compass-generative-ai/src/store/atlas-ai-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import thunk from 'redux-thunk';
import signInReducer, {
atlasServiceSignedOut,
atlasServiceSignedIn,
//atlasServiceSignInTokenRefreshFailed,
} from './atlas-signin-reducer';
import optInReducer, {
atlasServiceSignInTokenRefreshFailed,
} from './atlas-signin-reducer';
import optInReducer from './atlas-optin-reducer';
import type { AtlasAuthService } from '@mongodb-js/atlas-service/provider';
import type { ActivateHelpers } from 'hadron-app-registry';
import type { AtlasAiService } from '../atlas-ai-service';
Expand All @@ -25,13 +23,14 @@ const reducer = combineReducers({
optInReducer,
});

export type CompassGenerativeAIPluginServices = {
export type CompassGenerativeAIExtraArgs = {
atlasAuthService: AtlasAuthService;
atlasAiService: AtlasAiService;
preferences: PreferencesAccess;
};
export function activatePlugin(
_: Record<string, never>,
services: CompassGenerativeAIPluginServices,
services: CompassGenerativeAIExtraArgs,
{ cleanup }: ActivateHelpers
) {
store = configureStore(services);
Expand All @@ -52,19 +51,15 @@ export function activatePlugin(
export function configureStore({
atlasAuthService,
atlasAiService,
}: CompassGenerativeAIPluginServices) {
preferences,
}: CompassGenerativeAIExtraArgs) {
const store = createStore(
reducer,
applyMiddleware(
thunk.withExtraArgument({ atlasAuthService, atlasAiService })
thunk.withExtraArgument({ atlasAuthService, atlasAiService, preferences })
)
);
return store;
}

export type GenAIAtlasExtraArgs = {
preferences: PreferencesAccess;
atlasAiService: AtlasAiService;
};

export type CompassGenerativeAIServiceStore = ReturnType<typeof configureStore>;
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { Action, AnyAction, Reducer } from 'redux';
import type { ThunkAction } from 'redux-thunk';
import type { GenAIAtlasExtraArgs } from './atlas-ai-store';
import { throwIfAborted } from '@mongodb-js/compass-utils';
import type { AtlasAiService } from '../atlas-ai-service';
import type { PreferencesAccess } from 'compass-preferences-model';

function isAction<A extends AnyAction>(
action: AnyAction,
Expand All @@ -28,7 +29,12 @@ export type AtlasOptInState = {
export type GenAIAtlasOptInThunkAction<
R,
A extends AnyAction = AnyAction
> = ThunkAction<R, AtlasOptInState, GenAIAtlasExtraArgs, A>;
> = ThunkAction<
R,
AtlasOptInState,
{ atlasAiService: AtlasAiService; preferences: PreferencesAccess },
A
>;

export const enum AtlasOptInActions {
OpenOptInModal = 'compass-generative-ai/atlas-optin/OpenOptInModal',
Expand Down
Loading