-
Notifications
You must be signed in to change notification settings - Fork 238
chore(my-queries): make feature flag ready for saving user data COMPASS-9657 #7264
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
Changes from 10 commits
6b01986
893e6f7
505d90d
d13312d
6ea3db4
208a602
f484042
56e1223
c56a395
97ffb20
923e0d5
95fe0d7
eed1621
8f742a0
d117d7c
72d7115
6e9dfc8
0c8fea4
775d7e6
7d765a2
b8efa1c
de5fbff
2d86489
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import React from 'react'; | ||
import { connect } from 'react-redux'; | ||
import { Button, Icon, css, spacing } from '@mongodb-js/compass-components'; | ||
import { Button, css, Icon, spacing } from '@mongodb-js/compass-components'; | ||
import { exportToLanguage } from '../../../modules/export-to-language'; | ||
import { SaveMenu } from './pipeline-menus'; | ||
import PipelineName from './pipeline-name'; | ||
|
@@ -11,6 +11,7 @@ import { confirmNewPipeline } from '../../../modules/is-new-pipeline-confirm'; | |
import { hiddenOnNarrowPipelineToolbarStyles } from '../pipeline-toolbar-container'; | ||
import ModifySourceBanner from '../../modify-source-banner'; | ||
import { usePipelineStorage } from '@mongodb-js/my-queries-storage/provider'; | ||
import { usePreference } from 'compass-preferences-model/provider'; | ||
|
||
const containerStyles = css({ | ||
display: 'flex', | ||
|
@@ -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'); | ||
const enableSavedAggregationsQueries = | ||
pipelineStorageAvailable && isMyQueriesEnabled; | ||
const isPipelineNameDisplayed = | ||
!editViewName && !!enableSavedAggregationsQueries; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import React, { useCallback, useLayoutEffect, useRef } from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { | ||
resetGlobalCSS, | ||
css, | ||
Body, | ||
css, | ||
openToast, | ||
resetGlobalCSS, | ||
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. Alphabetical 🙌 big fan. |
||
} from '@mongodb-js/compass-components'; | ||
import type { AllPreferences } from 'compass-preferences-model'; | ||
import { CompassWeb } from '../src/index'; | ||
|
@@ -137,6 +137,7 @@ const App = () => { | |
isAtlas && !!enableGenAIFeaturesAtlasOrg, | ||
optInGenAIFeatures: isAtlas && !!optInGenAIFeatures, | ||
enableDataModeling: true, | ||
enableMyQueries: true, | ||
}} | ||
onTrack={sandboxTelemetry.track} | ||
onDebug={sandboxLogger.debug} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,17 +15,20 @@ import WorkspacesPlugin, { | |
WorkspacesProvider, | ||
} from '@mongodb-js/compass-workspaces'; | ||
import { | ||
DatabasesWorkspaceTab, | ||
CollectionsWorkspaceTab, | ||
CreateNamespacePlugin, | ||
DatabasesWorkspaceTab, | ||
DropNamespacePlugin, | ||
RenameCollectionPlugin, | ||
} from '@mongodb-js/compass-databases-collections'; | ||
import { CompassComponentsProvider, css } from '@mongodb-js/compass-components'; | ||
import { | ||
WorkspaceTab as CollectionWorkspace, | ||
CollectionTabsProvider, | ||
WorkspaceTab as CollectionWorkspace, | ||
} from '@mongodb-js/compass-collection'; | ||
import { | ||
CompassSidebarPlugin, | ||
AtlasClusterConnectionsOnlyProvider, | ||
CompassSidebarPlugin, | ||
} from '@mongodb-js/compass-sidebar'; | ||
import CompassQueryBarPlugin from '@mongodb-js/compass-query-bar'; | ||
import { CompassDocumentsPlugin } from '@mongodb-js/compass-crud'; | ||
|
@@ -40,13 +43,8 @@ import { CompassGlobalWritesPlugin } from '@mongodb-js/compass-global-writes'; | |
import { CompassGenerativeAIPlugin } from '@mongodb-js/compass-generative-ai'; | ||
import ExplainPlanCollectionTabModal from '@mongodb-js/compass-explain-plan'; | ||
import ExportToLanguageCollectionTabModal from '@mongodb-js/compass-export-to-language'; | ||
import { | ||
CreateNamespacePlugin, | ||
DropNamespacePlugin, | ||
RenameCollectionPlugin, | ||
} from '@mongodb-js/compass-databases-collections'; | ||
import { PreferencesProvider } from 'compass-preferences-model/provider'; | ||
import type { AllPreferences } from 'compass-preferences-model/provider'; | ||
import { PreferencesProvider } from 'compass-preferences-model/provider'; | ||
import FieldStorePlugin from '@mongodb-js/compass-field-store'; | ||
import { AtlasServiceProvider } from '@mongodb-js/atlas-service/provider'; | ||
import { AtlasAiServiceProvider } from '@mongodb-js/compass-generative-ai/provider'; | ||
|
@@ -55,13 +53,22 @@ import { TelemetryProvider } from '@mongodb-js/compass-telemetry/provider'; | |
import CompassConnections from '@mongodb-js/compass-connections'; | ||
import { AtlasCloudConnectionStorageProvider } from './connection-storage'; | ||
import { AtlasCloudAuthServiceProvider } from './atlas-auth-service'; | ||
import type { LogFunction, DebugFunction } from './logger'; | ||
import type { DebugFunction, LogFunction } from './logger'; | ||
import { useCompassWebLogger } from './logger'; | ||
import { type TelemetryServiceOptions } from '@mongodb-js/compass-telemetry'; | ||
import { WebWorkspaceTab as WelcomeWorkspaceTab } from '@mongodb-js/compass-welcome'; | ||
import { useCompassWebPreferences } from './preferences'; | ||
import { DataModelingWorkspaceTab as DataModelingWorkspace } from '@mongodb-js/compass-data-modeling'; | ||
import { DataModelStorageServiceProviderInMemory } from '@mongodb-js/compass-data-modeling/web'; | ||
import { WorkspaceTab as MyQueriesWorkspace } from '@mongodb-js/compass-saved-aggregations-queries'; | ||
import { | ||
compassFavoriteQueryStorageAccess, | ||
compassRecentQueryStorageAccess, | ||
CompassPipelineStorage, | ||
FavoriteQueryStorageProvider, | ||
RecentQueryStorageProvider, | ||
PipelineStorageProvider, | ||
} from '@mongodb-js/my-queries-storage'; | ||
import { CompassAssistantProvider } from '@mongodb-js/compass-assistant'; | ||
import { CompassAssistantDrawerWithConnections } from './compass-assistant-drawer'; | ||
|
||
|
@@ -179,62 +186,72 @@ function CompassWorkspace({ | |
onActiveWorkspaceTabChange, | ||
onOpenConnectViaModal, | ||
}: CompassWorkspaceProps) { | ||
// Create a simple pipeline storage instance for sandbox | ||
const pipelineStorage = new CompassPipelineStorage(); | ||
|
||
return ( | ||
<WorkspacesProvider | ||
value={[ | ||
WelcomeWorkspaceTab, | ||
DatabasesWorkspaceTab, | ||
CollectionsWorkspaceTab, | ||
CollectionWorkspace, | ||
DataModelingWorkspace, | ||
]} | ||
> | ||
<CollectionTabsProvider | ||
queryBar={CompassQueryBarPlugin} | ||
tabs={[ | ||
CompassDocumentsPlugin, | ||
CompassAggregationsPlugin, | ||
CompassSchemaPlugin, | ||
CompassIndexesPlugin, | ||
CompassSchemaValidationPlugin, | ||
CompassGlobalWritesPlugin, | ||
]} | ||
modals={[ | ||
ExplainPlanCollectionTabModal, | ||
ExportToLanguageCollectionTabModal, | ||
]} | ||
> | ||
<div | ||
data-testid="compass-web-connected" | ||
className={connectedContainerStyles} | ||
> | ||
<WorkspacesPlugin | ||
initialWorkspaceTabs={initialWorkspaceTabs} | ||
openOnEmptyWorkspace={{ type: 'Welcome' }} | ||
onActiveWorkspaceTabChange={onActiveWorkspaceTabChange} | ||
renderSidebar={() => { | ||
return ( | ||
<CompassSidebarPlugin | ||
onOpenConnectViaModal={onOpenConnectViaModal} | ||
isCompassWeb={true} | ||
></CompassSidebarPlugin> | ||
); | ||
}} | ||
renderModals={() => { | ||
return ( | ||
<> | ||
<CreateViewPlugin></CreateViewPlugin> | ||
<CreateNamespacePlugin></CreateNamespacePlugin> | ||
<DropNamespacePlugin></DropNamespacePlugin> | ||
<RenameCollectionPlugin></RenameCollectionPlugin> | ||
<CompassAssistantDrawerWithConnections /> | ||
</> | ||
); | ||
}} | ||
></WorkspacesPlugin> | ||
</div> | ||
</CollectionTabsProvider> | ||
</WorkspacesProvider> | ||
<PipelineStorageProvider value={pipelineStorage}> | ||
|
||
<FavoriteQueryStorageProvider value={compassFavoriteQueryStorageAccess}> | ||
<RecentQueryStorageProvider value={compassRecentQueryStorageAccess}> | ||
<WorkspacesProvider | ||
value={[ | ||
WelcomeWorkspaceTab, | ||
DatabasesWorkspaceTab, | ||
CollectionsWorkspaceTab, | ||
CollectionWorkspace, | ||
DataModelingWorkspace, | ||
MyQueriesWorkspace, | ||
]} | ||
> | ||
<CollectionTabsProvider | ||
queryBar={CompassQueryBarPlugin} | ||
tabs={[ | ||
CompassDocumentsPlugin, | ||
CompassAggregationsPlugin, | ||
CompassSchemaPlugin, | ||
CompassIndexesPlugin, | ||
CompassSchemaValidationPlugin, | ||
CompassGlobalWritesPlugin, | ||
]} | ||
modals={[ | ||
ExplainPlanCollectionTabModal, | ||
ExportToLanguageCollectionTabModal, | ||
]} | ||
> | ||
<div | ||
data-testid="compass-web-connected" | ||
className={connectedContainerStyles} | ||
> | ||
<WorkspacesPlugin | ||
initialWorkspaceTabs={initialWorkspaceTabs} | ||
openOnEmptyWorkspace={{ type: 'Welcome' }} | ||
onActiveWorkspaceTabChange={onActiveWorkspaceTabChange} | ||
renderSidebar={() => { | ||
return ( | ||
<CompassSidebarPlugin | ||
onOpenConnectViaModal={onOpenConnectViaModal} | ||
isCompassWeb={true} | ||
></CompassSidebarPlugin> | ||
); | ||
}} | ||
renderModals={() => { | ||
return ( | ||
<> | ||
<CreateViewPlugin></CreateViewPlugin> | ||
<CreateNamespacePlugin></CreateNamespacePlugin> | ||
<DropNamespacePlugin></DropNamespacePlugin> | ||
<RenameCollectionPlugin></RenameCollectionPlugin> | ||
<CompassAssistantDrawerWithConnections /> | ||
</> | ||
); | ||
}} | ||
></WorkspacesPlugin> | ||
</div> | ||
</CollectionTabsProvider> | ||
</WorkspacesProvider> | ||
</RecentQueryStorageProvider> | ||
</FavoriteQueryStorageProvider> | ||
</PipelineStorageProvider> | ||
); | ||
} | ||
|
||
|
@@ -286,6 +303,7 @@ const CompassWeb = ({ | |
onDebug, | ||
}); | ||
const preferencesAccess = useCompassWebPreferences(initialPreferences); | ||
// TODO (COMPASS-9565): My Queries feature flag will be used to conditionally provide storage providers | ||
const initialWorkspaceRef = useRef(initialWorkspace); | ||
const initialWorkspaceTabsRef = useRef( | ||
initialWorkspaceRef.current ? [initialWorkspaceRef.current] : [] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,13 @@ export { | |
} from './compass-query-storage'; | ||
export type { RecentQuery, FavoriteQuery } from './query-storage-schema'; | ||
|
||
// Export providers for use in applications | ||
export { | ||
FavoriteQueryStorageProvider, | ||
RecentQueryStorageProvider, | ||
PipelineStorageProvider, | ||
} from './provider'; | ||
|
||
|
||
// These are exported to aid in testing | ||
export const compassFavoriteQueryStorageAccess: FavoriteQueryStorageAccess = { | ||
getStorage() { | ||
|
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.
if I'm not mistaken we can now replace this check with the new flag. tagging @gribnoysup to confirm that the check was for compass-web and not some other case.
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.
Yep, should replace this with a preference if we have one now