Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export type InternalUserPreferences = {
id: string;
cloudFeatureRolloutAccess?: {
GEN_AI_COMPASS?: boolean;
MY_QUERIES_DATA_EXPLORER?: boolean;
};
lastKnownVersion: string;
highestInstalledVersion?: string;
Expand Down Expand Up @@ -470,6 +471,7 @@ export const storedUserPreferencesProps: Required<{
validator: z
.object({
GEN_AI_COMPASS: z.boolean().optional(),
MY_QUERIES_DATA_EXPLORER: z.boolean().optional(),
})
.optional(),
type: 'object',
Expand Down
12 changes: 10 additions & 2 deletions packages/compass-query-bar/src/components/query-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -202,8 +205,13 @@ export const QueryBar: React.FunctionComponent<QueryBarProps> = ({

const favoriteQueryStorageAvailable = !!useFavoriteQueryStorageAccess();
const recentQueryStorageAvailable = !!useRecentQueryStorageAccess();
const cloudFeatureRolloutAccess = usePreference('cloudFeatureRolloutAccess');
const isMyQueriesEnabled =
cloudFeatureRolloutAccess?.MY_QUERIES_DATA_EXPLORER ?? false;
const enableSavedAggregationsQueries =
favoriteQueryStorageAvailable && recentQueryStorageAvailable;
favoriteQueryStorageAvailable &&
recentQueryStorageAvailable &&
isMyQueriesEnabled;

return (
<form
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,12 @@ export function Navigation({
const { openMyQueriesWorkspace, openDataModelingWorkspace } =
useOpenWorkspace();
const isDataModelingEnabled = usePreference('enableDataModeling');
const cloudFeatureRolloutAccess = usePreference('cloudFeatureRolloutAccess');
const isMyQueriesEnabled =
cloudFeatureRolloutAccess?.MY_QUERIES_DATA_EXPLORER ?? false;
return (
<div>
{hasWorkspacePlugin('My Queries') && (
{hasWorkspacePlugin('My Queries') && isMyQueriesEnabled && (
<NavigationItem
onClick={openMyQueriesWorkspace}
glyph="CurlyBraces"
Expand Down
3 changes: 3 additions & 0 deletions packages/compass-web/sandbox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ const App = () => {
isAtlas && !!enableGenAIFeaturesAtlasOrg,
optInGenAIFeatures: isAtlas && !!optInGenAIFeatures,
enableDataModeling: true,
cloudFeatureRolloutAccess: {
MY_QUERIES_DATA_EXPLORER: false, // Disabled by default
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shouldn't be necessary

}}
onTrack={sandboxTelemetry.track}
onDebug={sandboxLogger.debug}
Expand Down
3 changes: 3 additions & 0 deletions packages/compass-web/src/entrypoint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import {
CompassAssistantDrawer,
CompassAssistantProvider,
} from '@mongodb-js/compass-assistant';
import { useMyQueriesFeature } from './hooks/use-my-queries-feature';

export type TrackFunction = (
event: string,
Expand Down Expand Up @@ -280,6 +281,8 @@ const CompassWeb = ({
onDebug,
});
const preferencesAccess = useCompassWebPreferences(initialPreferences);
const isMyQueriesEnabled = useMyQueriesFeature();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lint will complain about unused variables, you can just leave this commented out together with the todo. we also try to add ticket numbers to todos, I don't think it'll be forgotten in this instance but it's a good habit

// TODO: This will be used to conditionally provide My Queries storage providers in the implementation PR
const initialWorkspaceRef = useRef(initialWorkspace);
const initialWorkspaceTabsRef = useRef(
initialWorkspaceRef.current ? [initialWorkspaceRef.current] : []
Expand Down
13 changes: 13 additions & 0 deletions packages/compass-web/src/hooks/use-my-queries-feature.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { usePreference } from 'compass-preferences-model/provider';

/**
* Hook to check if the My Queries Data Explorer feature is enabled.
* This controls access to:
* - Saved queries and aggregations
* - Recent queries autocomplete
* - Favorite queries/aggregations
*/
export function useMyQueriesFeature(): boolean {
const cloudFeatureRolloutAccess = usePreference('cloudFeatureRolloutAccess');
return cloudFeatureRolloutAccess?.MY_QUERIES_DATA_EXPLORER ?? false;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compass-web is not the best place for the hook, check out the compass-preferences-model package. there are similar hooks in the utils.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

once moved, you can use the hook in the sidebar and query bar

1 change: 1 addition & 0 deletions packages/compass-web/src/preferences.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export function useCompassWebPreferences(
enablePerformanceAdvisorBanner: true,
cloudFeatureRolloutAccess: {
GEN_AI_COMPASS: false,
MY_QUERIES_DATA_EXPLORER: false,
},
maximumNumberOfActiveConnections: 10,
trackUsageStatistics: true,
Expand Down
Loading