Skip to content

Commit

Permalink
fix: global writes feature flag COMPAS-8524 (#6539)
Browse files Browse the repository at this point in the history
fix: global writes feture flag COMPAS-8524
  • Loading branch information
paula-stacho authored Nov 29, 2024
1 parent 77c23bf commit 36a5c11
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
useConnectionInfoRef,
useConnectionSupports,
} from '@mongodb-js/compass-connections/provider';
import { usePreference } from 'compass-preferences-model/provider';

type CollectionSubtabTrackingId = Lowercase<CollectionSubtab> extends infer U
? U extends string
Expand Down Expand Up @@ -119,13 +120,17 @@ function WithErrorBoundary({
function useCollectionTabs(props: CollectionMetadata) {
const pluginTabs = useCollectionSubTabs();
const connectionInfoRef = useConnectionInfoRef();
const isGlobalWritesEnabled = usePreference('enableGlobalWrites');
const isGlobalWritesSupported =
useConnectionSupports(connectionInfoRef.current.id, 'globalWrites') &&
!props.isReadonly &&
!toNS(props.namespace).specialish;
return pluginTabs
.filter((x) => {
if (x.name === 'GlobalWrites' && !isGlobalWritesSupported) {
if (
x.name === 'GlobalWrites' &&
(!isGlobalWritesEnabled || !isGlobalWritesSupported)
) {
return false;
}
return true;
Expand Down
8 changes: 8 additions & 0 deletions packages/compass-preferences-model/src/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type FeatureFlags = {
enableQueryHistoryAutocomplete: boolean;
enableProxySupport: boolean;
enableRollingIndexes: boolean;
enableGlobalWrites: boolean;
};

export const featureFlags: Required<{
Expand Down Expand Up @@ -92,4 +93,11 @@ export const featureFlags: Required<{
short: 'Enable creating indexes with the rolling build in Atlas Cloud',
},
},

enableGlobalWrites: {
stage: 'development',
description: {
short: 'Enable Global Writes tab in Atlas Cloud',
},
},
};
10 changes: 0 additions & 10 deletions packages/compass-preferences-model/src/preferences-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ export type InternalUserPreferences = {
telemetryAnonymousId?: string;
telemetryAtlasUserId?: string;
userCreatedAt: number;
enableGlobalWrites: boolean;
};

// UserPreferences contains all preferences stored to disk.
Expand Down Expand Up @@ -877,15 +876,6 @@ export const storedUserPreferencesProps: Required<{
validator: z.boolean().default(true),
type: 'boolean',
},

enableGlobalWrites: {
ui: false,
cli: false,
global: false,
description: null,
validator: z.boolean().default(false),
type: 'boolean',
},
enableGenAIFeaturesAtlasProject: {
ui: false,
cli: true,
Expand Down

0 comments on commit 36a5c11

Please sign in to comment.