Skip to content

Commit

Permalink
chore(preferences): rename multiple connections option to work around…
Browse files Browse the repository at this point in the history
… stored default issue (#6155)
  • Loading branch information
gribnoysup authored Aug 26, 2024
1 parent 31d597d commit d29d513
Show file tree
Hide file tree
Showing 37 changed files with 51 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ const CollectionHeaderActions: React.FunctionComponent<
const {
readOnly: preferencesReadOnly,
enableShell,
enableNewMultipleConnectionSystem,
enableMultipleConnectionSystem,
} = usePreferences([
'readOnly',
'enableShell',
'enableNewMultipleConnectionSystem',
'enableMultipleConnectionSystem',
]);
const track = useTelemetry();

const { database, collection } = toNS(namespace);

const showOpenShellButton = enableShell && enableNewMultipleConnectionSystem;
const showOpenShellButton = enableShell && enableMultipleConnectionSystem;

return (
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function ImportConnectionsModal({
trackingProps?: Record<string, unknown>;
}): React.ReactElement {
const multipleConnectionsEnabled = usePreference(
'enableNewMultipleConnectionSystem'
'enableMultipleConnectionSystem'
);
const { openToast } = useToast('compass-connection-import-export');
const finish = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ describe('useExportConnections', function () {
beforeEach(async function () {
const preferences = await createSandboxFromDefaultPreferences();
await preferences.savePreferences({
enableNewMultipleConnectionSystem: true,
enableMultipleConnectionSystem: true,
});
const wrapper: React.FC = ({ children }) =>
createElement(PreferencesProvider, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function useExportConnections({
state: ExportConnectionsState;
} {
const multipleConnectionsEnabled = usePreference(
'enableNewMultipleConnectionSystem'
'enableMultipleConnectionSystem'
);
const { favoriteConnections, nonFavoriteConnections } =
useConnectionRepository();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ describe('useImportConnections', function () {
beforeEach(async function () {
const preferences = await createSandboxFromDefaultPreferences();
await preferences.savePreferences({
enableNewMultipleConnectionSystem: true,
enableMultipleConnectionSystem: true,
});
const wrapper: React.FC = ({ children }) =>
React.createElement(PreferencesProvider, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export function useImportConnections({
state: ImportConnectionsState;
} {
const multipleConnectionsEnabled = usePreference(
'enableNewMultipleConnectionSystem'
'enableMultipleConnectionSystem'
);
const { favoriteConnections, nonFavoriteConnections } =
useConnectionRepository();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ describe('ConnectionsNavigationTree', function () {
preferences = await createSandboxFromDefaultPreferences();
await preferences.savePreferences({
enableRenameCollectionModal: true,
enableNewMultipleConnectionSystem: true,
enableMultipleConnectionSystem: true,
...preferencesOverrides,
});
return render(
Expand Down Expand Up @@ -659,7 +659,7 @@ describe('ConnectionsNavigationTree', function () {
preferences = await createSandboxFromDefaultPreferences();
await preferences.savePreferences({
enableRenameCollectionModal: true,
enableNewMultipleConnectionSystem: true,
enableMultipleConnectionSystem: true,
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ const ConnectionsNavigationTree: React.FunctionComponent<
}) => {
const preferencesShellEnabled = usePreference('enableShell');
const preferencesReadOnly = usePreference('readOnly');
const isSingleConnection = !usePreference(
'enableNewMultipleConnectionSystem'
);
const isSingleConnection = !usePreference('enableMultipleConnectionSystem');
const isRenameCollectionEnabled = usePreference(
'enableRenameCollectionModal'
);
Expand Down
4 changes: 1 addition & 3 deletions packages/compass-connections-navigation/src/placeholder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ export const PlaceholderItem: React.FunctionComponent<{
level: number;
style?: CSSProperties;
}> = ({ level, style }) => {
const isSingleConnection = !usePreference(
'enableNewMultipleConnectionSystem'
);
const isSingleConnection = !usePreference('enableMultipleConnectionSystem');
const itemPaddingStyles = useMemo(
() => getTreeItemStyles({ level, isExpandable: false }),
[level]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const activeWorkspace = {
const dummyPreferences = {
getPreferences() {
return {
enableNewMultipleConnectionSystem: false,
enableMultipleConnectionSystem: false,
};
},
onPreferenceValueChanged() {},
Expand Down Expand Up @@ -107,7 +107,7 @@ describe.skip('ConnectionsNavigationTree -- Single connection usage', function (
beforeEach(async function () {
await preferences.savePreferences({
enableRenameCollectionModal: true,
enableNewMultipleConnectionSystem: false,
enableMultipleConnectionSystem: false,
});

renderComponent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ export default function StyledNavigationItem({
const isDarkMode = useDarkMode();
const { connectionColorToHex, connectionColorToHexActive } =
useConnectionColor();
const isSingleConnection = !usePreference(
'enableNewMultipleConnectionSystem'
);
const isSingleConnection = !usePreference('enableMultipleConnectionSystem');
const { colorCode } = item;
const isDisconnectedConnection =
item.type === 'connection' &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ const deviceAuthModalContentStyles = css({
* is the default behavior
*/
export function useConnectionStatusNotifications() {
const enableNewMultipleConnectionSystem = usePreference(
'enableNewMultipleConnectionSystem'
const enableMultipleConnectionSystem = usePreference(
'enableMultipleConnectionSystem'
);
const { openToast, closeToast } = useToast('connection-status');

Expand Down Expand Up @@ -234,7 +234,7 @@ export function useConnectionStatusNotifications() {
// Gated by the feature flag: if flag is on, we return trigger functions, if
// flag is off, we return noop functions so that we can call them
// unconditionally in the actual flow
return enableNewMultipleConnectionSystem
return enableMultipleConnectionSystem
? {
openNotifyDeviceAuthModal,
openConnectionStartedToast,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function Connections({
const darkMode = useDarkMode();
const connectionFormPreferences = useConnectionFormPreferences();
const isMultiConnectionEnabled = usePreference(
'enableNewMultipleConnectionSystem'
'enableMultipleConnectionSystem'
);

const activeConnectionInfo = useActiveConnectionInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('useTabConnectionTheme', function () {
beforeEach(async function () {
preferencesAccess = await createSandboxFromDefaultPreferences();
await preferencesAccess.savePreferences({
enableNewMultipleConnectionSystem: true,
enableMultipleConnectionSystem: true,
});

mockStorage = new InMemoryConnectionStorage([CONNECTION_INFO]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function useTabConnectionTheme(): ThemeProvider {
const { getConnectionInfoById } = useConnectionRepository();
const darkTheme = useDarkMode();
const isMultipleConnectionsEnabled = usePreference(
'enableNewMultipleConnectionSystem'
'enableMultipleConnectionSystem'
);

const getThemeOf = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ describe('useConnections', function () {

beforeEach(async function () {
await preferences.savePreferences({
enableNewMultipleConnectionSystem: true,
enableMultipleConnectionSystem: true,
maximumNumberOfActiveConnections: undefined,
});
mockConnectionStorage = new InMemoryConnectionStorage([...mockConnections]);
Expand Down Expand Up @@ -310,7 +310,7 @@ describe('useConnections', function () {
}`, function () {
it('should NOT update existing connection with new props when existing connection is successfull', async function () {
await preferences.savePreferences({
enableNewMultipleConnectionSystem: multipleConnectionsEnabled,
enableMultipleConnectionSystem: multipleConnectionsEnabled,
});

const connections = renderHookWithContext();
Expand All @@ -332,7 +332,7 @@ describe('useConnections', function () {

it('should not update existing connection if connection failed', async function () {
await preferences.savePreferences({
enableNewMultipleConnectionSystem: multipleConnectionsEnabled,
enableMultipleConnectionSystem: multipleConnectionsEnabled,
});

const saveSpy = sinon.spy(mockConnectionStorage, 'save');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export const createConnectionsReducer = (preferences: PreferencesAccess) => {
if (
// In multiple connections mode we don't allow to start another edit
// when one is already in progress
preferences.getPreferences().enableNewMultipleConnectionSystem &&
preferences.getPreferences().enableMultipleConnectionSystem &&
state.isEditingConnectionInfoModalOpen
) {
return state;
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-e2e-tests/multiple-connections.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
enableNewMultipleConnectionSystem: true
enableMultipleConnectionSystem: true
4 changes: 2 additions & 2 deletions packages/compass-preferences-model/src/preferences-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export type UserConfigurablePreferences = PermanentFeatureFlags &
enablePerformanceAdvisorBanner: boolean;
maximumNumberOfActiveConnections?: number;
enableShowDialogOnQuit: boolean;
enableNewMultipleConnectionSystem: boolean;
enableMultipleConnectionSystem: boolean;
enableProxySupport: boolean;
proxy: string;
};
Expand Down Expand Up @@ -781,7 +781,7 @@ export const storedUserPreferencesProps: Required<{
type: 'boolean',
},

enableNewMultipleConnectionSystem: {
enableMultipleConnectionSystem: {
ui: true,
cli: true,
global: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe('SavedItemCard', function () {
it('should render an "Open in" action', async function () {
const preferences = await createSandboxFromDefaultPreferences();
await preferences.savePreferences({
enableNewMultipleConnectionSystem: true,
enableMultipleConnectionSystem: true,
});
const onAction = Sinon.spy();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ const CardActions: React.FunctionComponent<{
onAction: SavedItemCardProps['onAction'];
}> = ({ itemId, isVisible, onAction }) => {
const multiConnectionsEnabled = usePreference(
'enableNewMultipleConnectionSystem'
'enableMultipleConnectionSystem'
);
const actions: MenuAction<SavedItemAction>[] = useMemo(() => {
return multiConnectionsEnabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ describe('AggregationsQueriesList', function () {
instancesManager = new TestMongoDBInstanceManager();
preferencesAccess = await createSandboxFromDefaultPreferences();
await preferencesAccess.savePreferences({
enableNewMultipleConnectionSystem: true,
enableMultipleConnectionSystem: true,
});
workspaces = {
openCollectionWorkspace() {},
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-shell/src/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type ShellPluginProps = {

export function ShellPlugin(props: ShellPluginProps) {
const multiConnectionsEnabled = usePreference(
'enableNewMultipleConnectionSystem'
'enableMultipleConnectionSystem'
);
const ShellComponent = multiConnectionsEnabled ? TabShell : Shell;
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ describe('Multiple Connections Sidebar Component', function () {
]);
preferences = await createSandboxFromDefaultPreferences();
await preferences.savePreferences({
enableNewMultipleConnectionSystem: true,
enableMultipleConnectionSystem: true,
});
({ store, deactivate } = createSidebarStore(
{
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-sidebar/src/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const SidebarPlugin: React.FunctionComponent<SidebarPluginProps> = ({
}) => {
const [activeConnection] = useActiveConnections();
const isMultiConnectionEnabled = usePreference(
'enableNewMultipleConnectionSystem'
'enableMultipleConnectionSystem'
);

const activeWorkspace = useActiveWorkspace();
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-web/src/entrypoint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ const CompassWeb = ({
enableAggregationBuilderExtraOptions: true,
enableImportExport: false,
enableGenAIFeatures: false,
enableNewMultipleConnectionSystem: false,
enableMultipleConnectionSystem: false,
enablePerformanceAdvisorBanner: true,
cloudFeatureRolloutAccess: {
GEN_AI_COMPASS: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-workspaces/src/components/workspaces.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ const CompassWorkspaces: React.FunctionComponent<CompassWorkspacesProps> = ({
const { getThemeOf } = useTabConnectionTheme();
const { getConnectionTitleById } = useConnectionRepository();
const multipleConnectionsEnabled = usePreference(
'enableNewMultipleConnectionSystem'
'enableMultipleConnectionSystem'
);

const tabDescriptions = useMemo(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-workspaces/src/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ describe('WorkspacesPlugin', function () {
connectionStorage = new InMemoryConnectionStorage([TEST_CONNECTION_INFO]);
preferences = await createSandboxFromDefaultPreferences();
await preferences.savePreferences({
enableNewMultipleConnectionSystem: true,
enableMultipleConnectionSystem: true,
});
});

Expand Down
4 changes: 2 additions & 2 deletions packages/compass/src/app/components/home.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('Home [Component]', function () {
return {
showedNetworkOptIn: true,
networkTraffic: true,
enableNewMultipleConnectionSystem: false,
enableMultipleConnectionSystem: false,
...preferences,
};
},
Expand Down Expand Up @@ -155,7 +155,7 @@ describe('Home [Component]', function () {
describe('and multi connections is enabled', function () {
it('renders only the workspaces', function () {
renderHome({}, createDataService(), {
enableNewMultipleConnectionSystem: true,
enableMultipleConnectionSystem: true,
});
expect(screen.getByTestId('home')).to.be.displayed;
expect(() => screen.getByTestId('connections-wrapper')).to.throw;
Expand Down
2 changes: 1 addition & 1 deletion packages/compass/src/app/components/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ function Home({
);

const multiConnectionsEnabled = usePreference(
'enableNewMultipleConnectionSystem'
'enableMultipleConnectionSystem'
);

return (
Expand Down
2 changes: 1 addition & 1 deletion packages/compass/src/app/components/workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default function Workspace({
}): React.ReactElement {
const [activeConnection] = useActiveConnections();
const multiConnectionsEnabled = usePreference(
'enableNewMultipleConnectionSystem'
'enableMultipleConnectionSystem'
);

const { getConnectionInfoById } = useConnectionRepository();
Expand Down
4 changes: 2 additions & 2 deletions packages/compass/src/main/menu.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ describe('CompassMenu', function () {

it('[multiple-connection] should generate a menu template for darwin', async function () {
await App.preferences.savePreferences({
enableNewMultipleConnectionSystem: true,
enableMultipleConnectionSystem: true,
});
sinon.stub(process, 'platform').value('darwin');
expect(serializable(CompassMenu.getTemplate(0))).to.deep.equal([
Expand Down Expand Up @@ -525,7 +525,7 @@ describe('CompassMenu', function () {

it(`[multiple-connection] should generate a menu template for ${platform}`, async function () {
await App.preferences.savePreferences({
enableNewMultipleConnectionSystem: true,
enableMultipleConnectionSystem: true,
});
sinon.stub(process, 'platform').value(platform);

Expand Down
4 changes: 2 additions & 2 deletions packages/compass/src/main/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ function connectSubMenu(
nonDarwin: boolean,
app: typeof CompassApplication
): MenuItemConstructorOptions {
const { enableNewMultipleConnectionSystem: isMultiConnectionsEnabled } =
const { enableMultipleConnectionSystem: isMultiConnectionsEnabled } =
app.preferences.getPreferences();

const singleConnectionItems: MenuTemplate = [
Expand Down Expand Up @@ -440,7 +440,7 @@ function viewSubMenu(
function windowSubMenu(
app: typeof CompassApplication
): MenuItemConstructorOptions {
const { enableNewMultipleConnectionSystem: isMultiConnectionsEnabled } =
const { enableMultipleConnectionSystem: isMultiConnectionsEnabled } =
app.preferences.getPreferences();

const submenu: MenuTemplate = [
Expand Down
Loading

0 comments on commit d29d513

Please sign in to comment.