From 36a5c119cc73dfc86ee43803a157741440b42554 Mon Sep 17 00:00:00 2001 From: Paula Stachova Date: Fri, 29 Nov 2024 14:38:27 +0100 Subject: [PATCH] fix: global writes feature flag COMPAS-8524 (#6539) fix: global writes feture flag COMPAS-8524 --- .../src/components/collection-tab.tsx | 7 ++++++- .../compass-preferences-model/src/feature-flags.ts | 8 ++++++++ .../src/preferences-schema.ts | 10 ---------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/packages/compass-collection/src/components/collection-tab.tsx b/packages/compass-collection/src/components/collection-tab.tsx index 305a115204d..58f24ed4e06 100644 --- a/packages/compass-collection/src/components/collection-tab.tsx +++ b/packages/compass-collection/src/components/collection-tab.tsx @@ -18,6 +18,7 @@ import { useConnectionInfoRef, useConnectionSupports, } from '@mongodb-js/compass-connections/provider'; +import { usePreference } from 'compass-preferences-model/provider'; type CollectionSubtabTrackingId = Lowercase extends infer U ? U extends string @@ -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; diff --git a/packages/compass-preferences-model/src/feature-flags.ts b/packages/compass-preferences-model/src/feature-flags.ts index 85b12aca7e3..ec0e14dd434 100644 --- a/packages/compass-preferences-model/src/feature-flags.ts +++ b/packages/compass-preferences-model/src/feature-flags.ts @@ -21,6 +21,7 @@ export type FeatureFlags = { enableQueryHistoryAutocomplete: boolean; enableProxySupport: boolean; enableRollingIndexes: boolean; + enableGlobalWrites: boolean; }; export const featureFlags: Required<{ @@ -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', + }, + }, }; diff --git a/packages/compass-preferences-model/src/preferences-schema.ts b/packages/compass-preferences-model/src/preferences-schema.ts index f3cfdb565a1..2cf49d575b9 100644 --- a/packages/compass-preferences-model/src/preferences-schema.ts +++ b/packages/compass-preferences-model/src/preferences-schema.ts @@ -88,7 +88,6 @@ export type InternalUserPreferences = { telemetryAnonymousId?: string; telemetryAtlasUserId?: string; userCreatedAt: number; - enableGlobalWrites: boolean; }; // UserPreferences contains all preferences stored to disk. @@ -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,