-
Notifications
You must be signed in to change notification settings - Fork 230
feat: Using the AtlasUserData class to demo save user data project COMPASS-9565 #7152
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
3f336ec
ad5e416
78026a3
b24d748
8413d43
dc38640
41abc96
e90412e
701adaf
daee65a
90573c7
0e997ff
5d39eb3
5edf5e2
729c6db
055b898
fed4e96
2058a32
296147a
d128447
18240da
31a8643
e88856f
3b8fc66
7d42eef
3c033fe
ef94ff8
3f8405a
7f07ddd
e09d426
04ba804
cf510ce
73b2bd1
51ab01e
df135f3
0bb77b8
f6efcd6
2c0de81
3eab096
61265d6
59e2a40
8e5d686
8e94ca9
905addd
8b17775
ce55bc5
5e554aa
814b21e
8e343f9
d11f522
e795442
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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -78,6 +78,16 @@ export class AtlasService { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// https://github.com/10gen/mms/blob/9f858bb987aac6aa80acfb86492dd74c89cbb862/client/packages/project/common/ajaxPrefilter.ts#L34-L49 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return this.cloudEndpoint(path); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
tempEndpoint(path?: string): string { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return `https://cluster-connection.cloud-dev.mongodb.com${normalizePath( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
)}`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
userDataEndpoint(path?: string): string { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return `https://cluster-connection.cloud-dev.mongodb.com/userData${normalizePath( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
)}`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+82
to
+89
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. Hard-coded development endpoint URL in production code poses security risks. This should be configurable or removed from production builds.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback 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. this will be fixed in follow up pr
Comment on lines
+82
to
+89
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. Hard-coded development endpoint URL in production code poses security risks. This should be configurable or removed from production builds.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
driverProxyEndpoint(path?: string): string { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return `${this.config.ccsBaseUrl}${normalizePath(path)}`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -91,13 +101,14 @@ export class AtlasService { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ url } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const headers = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
...this.options?.defaultHeaders, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
...(shouldAddCSRFHeaders(init?.method) && getCSRFHeaders()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
...init?.headers, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const res = await fetch(url, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
...init, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
headers: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
...this.options?.defaultHeaders, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
...(shouldAddCSRFHeaders(init?.method) && getCSRFHeaders()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
...init?.headers, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
headers, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
this.logger.log.info( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
this.logger.mongoLogId(1_001_000_309), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import React from 'react'; | ||
import { connect } from 'react-redux'; | ||
import { usePreference } from 'compass-preferences-model/provider'; | ||
import { Button, Icon, css, spacing } from '@mongodb-js/compass-components'; | ||
import { exportToLanguage } from '../../../modules/export-to-language'; | ||
import { SaveMenu } from './pipeline-menus'; | ||
|
@@ -49,7 +50,10 @@ export const PipelineSettings: React.FunctionComponent< | |
}) => { | ||
// TODO: remove direct check for storage existing, breaks single source of | ||
// truth rule and exposes services to UI, this breaks the rules for locators | ||
const enableSavedAggregationsQueries = !!usePipelineStorage(); | ||
const pipelineStorageAvailable = !!usePipelineStorage(); | ||
const isMyQueriesEnabled = usePreference('enableMyQueries'); | ||
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. Typescript error, not sure why though |
||
const enableSavedAggregationsQueries = | ||
pipelineStorageAvailable && isMyQueriesEnabled; | ||
const isPipelineNameDisplayed = | ||
!editViewName && !!enableSavedAggregationsQueries; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,10 @@ import { | |
createAIPlaceholderHTMLPlaceholder, | ||
} from '@mongodb-js/compass-generative-ai'; | ||
import { connect } from '../stores/context'; | ||
import { useIsAIFeatureEnabled } from 'compass-preferences-model/provider'; | ||
import { | ||
useIsAIFeatureEnabled, | ||
usePreference, | ||
} from 'compass-preferences-model/provider'; | ||
import { useTelemetry } from '@mongodb-js/compass-telemetry/provider'; | ||
|
||
import { | ||
|
@@ -202,8 +205,11 @@ export const QueryBar: React.FunctionComponent<QueryBarProps> = ({ | |
|
||
const favoriteQueryStorageAvailable = !!useFavoriteQueryStorageAccess(); | ||
const recentQueryStorageAvailable = !!useRecentQueryStorageAccess(); | ||
const isMyQueriesEnabled = usePreference('enableMyQueries'); | ||
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. TS |
||
const enableSavedAggregationsQueries = | ||
favoriteQueryStorageAvailable && recentQueryStorageAvailable; | ||
favoriteQueryStorageAvailable && | ||
recentQueryStorageAvailable && | ||
isMyQueriesEnabled; | ||
|
||
return ( | ||
<form | ||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -268,9 +268,20 @@ export const fetchRecents = (): QueryBarThunkAction< | |||||||||
return async ( | ||||||||||
dispatch, | ||||||||||
_getState, | ||||||||||
{ recentQueryStorage, logger: { debug } } | ||||||||||
{ recentQueryStorage, logger: { debug }, preferences } | ||||||||||
) => { | ||||||||||
try { | ||||||||||
// Check if My Queries feature is enabled | ||||||||||
const isMyQueriesEnabled = preferences.getPreferences().enableMyQueries; | ||||||||||
if (!isMyQueriesEnabled) { | ||||||||||
Comment on lines
+275
to
+276
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.
Suggested change
A nothingburger of a code suggestion, its bit easier to read than the dangling property access. FFTR w/o change. |
||||||||||
// If feature is disabled, dispatch empty array | ||||||||||
dispatch({ | ||||||||||
type: QueryBarActions.RecentQueriesFetched, | ||||||||||
recents: [], | ||||||||||
}); | ||||||||||
return; | ||||||||||
} | ||||||||||
|
||||||||||
const { | ||||||||||
queryBar: { namespace }, | ||||||||||
} = _getState(); | ||||||||||
|
@@ -286,7 +297,14 @@ export const fetchRecents = (): QueryBarThunkAction< | |||||||||
}; | ||||||||||
|
||||||||||
export const fetchSavedQueries = (): QueryBarThunkAction<void> => { | ||||||||||
return (dispatch) => { | ||||||||||
return (dispatch, _getState, { preferences }) => { | ||||||||||
// Check if My Queries feature is enabled | ||||||||||
const isMyQueriesEnabled = preferences.getPreferences().enableMyQueries; | ||||||||||
if (!isMyQueriesEnabled) { | ||||||||||
// If feature is disabled, don't fetch anything | ||||||||||
return; | ||||||||||
} | ||||||||||
|
||||||||||
void dispatch(fetchRecents()); | ||||||||||
void dispatch(fetchFavorites()); | ||||||||||
}; | ||||||||||
|
@@ -303,9 +321,20 @@ export const fetchFavorites = (): QueryBarThunkAction< | |||||||||
return async ( | ||||||||||
dispatch, | ||||||||||
_getState, | ||||||||||
{ favoriteQueryStorage, logger: { debug } } | ||||||||||
{ favoriteQueryStorage, logger: { debug }, preferences } | ||||||||||
) => { | ||||||||||
try { | ||||||||||
// Check if My Queries feature is enabled | ||||||||||
const isMyQueriesEnabled = preferences.getPreferences().enableMyQueries; | ||||||||||
if (!isMyQueriesEnabled) { | ||||||||||
// If feature is disabled, dispatch empty array | ||||||||||
dispatch({ | ||||||||||
type: QueryBarActions.FavoriteQueriesFetched, | ||||||||||
favorites: [], | ||||||||||
}); | ||||||||||
return; | ||||||||||
} | ||||||||||
|
||||||||||
const { | ||||||||||
queryBar: { namespace }, | ||||||||||
} = _getState(); | ||||||||||
|
@@ -356,10 +385,7 @@ export const saveRecentAsFavorite = ( | |||||||||
}; | ||||||||||
|
||||||||||
// add it in the favorite | ||||||||||
await favoriteQueryStorage?.updateAttributes( | ||||||||||
favoriteQuery._id, | ||||||||||
favoriteQuery | ||||||||||
); | ||||||||||
await favoriteQueryStorage?.saveQuery(favoriteQuery, favoriteQuery._id); | ||||||||||
|
||||||||||
// update favorites | ||||||||||
void dispatch(fetchFavorites()); | ||||||||||
|
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.
What is this for? I think this was added here by mistake compass top-level doesn't have any deps, all deps are tracked by the packages that need them. so this should be moved to a package.json inside
packages/XXX/package.json