diff --git a/src/Explorer/Menus/CommandBar/CommandBarComponentAdapter.tsx b/src/Explorer/Menus/CommandBar/CommandBarComponentAdapter.tsx index 2b2e83787..8827994e4 100644 --- a/src/Explorer/Menus/CommandBar/CommandBarComponentAdapter.tsx +++ b/src/Explorer/Menus/CommandBar/CommandBarComponentAdapter.tsx @@ -53,11 +53,7 @@ export const CommandBar: React.FC = ({ container }: Props) => { const uiFabricControlButtons = CommandBarUtil.convertButton(controlButtons, backgroundColor); uiFabricControlButtons.forEach((btn: ICommandBarItemProps) => (btn.iconOnly = true)); - if ( - useNotebook.getState().isPhoenixNotebooks || - useNotebook.getState().isPhoenixFeatures || - useNotebook.getState().isPhoenixDisabled - ) { + if (useNotebook.getState().isPhoenixNotebooks || useNotebook.getState().isPhoenixFeatures) { uiFabricControlButtons.unshift(CommandBarUtil.createConnectionStatus(container, "connectionStatus")); } diff --git a/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.test.ts b/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.test.ts index 03ed48368..b5cca5db6 100644 --- a/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.test.ts +++ b/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.test.ts @@ -204,14 +204,14 @@ describe("CommandBarComponentButtonFactory tests", () => { //expect(openMongoShellBtn.tooltipText).toBe(""); }); - it("Notebooks is enabled and is available, terminal is unavailable due to ipRules - button should be in disable state", () => { + it("Notebooks is enabled and is available, terminal is unavailable due to ipRules - button should be hidden", () => { useNotebook.getState().setIsNotebookEnabled(true); useNotebook.getState().setIsNotebooksEnabledForAccount(true); useNotebook.getState().setIsShellEnabled(false); const buttons = CommandBarComponentButtonFactory.createStaticCommandBarButtons(mockExplorer, selectedNodeState); const openMongoShellBtn = buttons.find((button) => button.commandButtonLabel === openMongoShellBtnLabel); - expect(openMongoShellBtn.disabled).toBe(true); + expect(openMongoShellBtn).toBeUndefined(); }); }); diff --git a/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.tsx b/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.tsx index c29fee049..e0bb5cda5 100644 --- a/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.tsx +++ b/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.tsx @@ -86,7 +86,9 @@ export function createStaticCommandBarButtons( notebookButtons.push(createNotebookWorkspaceResetButton(container)); } if ( - (userContext.apiType === "Mongo" && selectedNodeState.isDatabaseNodeOrNoneSelected()) || + (userContext.apiType === "Mongo" && + selectedNodeState.isDatabaseNodeOrNoneSelected() && + useNotebook.getState().isShellEnabled) || userContext.apiType === "Cassandra" ) { notebookButtons.push(createDivider()); @@ -98,19 +100,23 @@ export function createStaticCommandBarButtons( } notebookButtons.forEach((btn) => { + const isPhoenixFeaturesDownMsg = + (!useNotebook.getState().isPhoenixFeatures && !useNotebook.getState().isPhoenixDisabled) || + (!useNotebook.getState().isPhoenixFeatures && useNotebook.getState().isPhoenixDisabled); + if (btn.commandButtonLabel.indexOf("Cassandra") !== -1) { - if (!useNotebook.getState().isPhoenixFeatures && !useNotebook.getState().isPhoenixDisabled) { + if (isPhoenixFeaturesDownMsg) { applyNotebooksStyleProps(btn, Constants.Notebook.cassandraShellTemporarilyDownMsg); } else if (useNotebook.getState().isPhoenixDisabled) { applyNotebooksStyleProps(btn, Constants.Notebook.notebookDisabledText); } } else if (btn.commandButtonLabel.indexOf("Mongo") !== -1) { - if (!useNotebook.getState().isPhoenixFeatures && !useNotebook.getState().isPhoenixDisabled) { + if (isPhoenixFeaturesDownMsg) { applyNotebooksStyleProps(btn, Constants.Notebook.mongoShellTemporarilyDownMsg); } else if (useNotebook.getState().isPhoenixDisabled) { applyNotebooksStyleProps(btn, Constants.Notebook.notebookDisabledText); } - } else if (!useNotebook.getState().isPhoenixNotebooks && !useNotebook.getState().isPhoenixDisabled) { + } else if (isPhoenixFeaturesDownMsg) { applyNotebooksStyleProps(btn, Constants.Notebook.temporarilyDownMsg); } else if (useNotebook.getState().isPhoenixDisabled) { applyNotebooksStyleProps(btn, Constants.Notebook.notebookDisabledText); @@ -177,23 +183,23 @@ export function createContextCommandBarButtons( tooltipText: isPhoenixShellDisabled ? Constants.Notebook.notebookDisabledText : undefined, }; buttons.push(phoenixMongoShellBtn); - - const label = "New Shell"; - const isNewMongoShellDisabled = useNotebook.getState().isShellEnabled && !useNotebook.getState().isPhoenixDisabled; - const newMongoShellBtn: CommandButtonComponentProps = { - iconSrc: HostedTerminalIcon, - iconAlt: label, - onCommandClick: () => { - const selectedCollection: ViewModels.Collection = selectedNodeState.findSelectedCollection(); - selectedCollection && selectedCollection.onNewMongoShellClick(); - }, - commandButtonLabel: label, - ariaLabel: label, - hasPopup: true, - disabled: isNewMongoShellDisabled, - tooltipText: isNewMongoShellDisabled ? Constants.Notebook.newShellDisabledText : undefined, - }; - buttons.push(newMongoShellBtn); + if (!useNotebook.getState().isShellEnabled) { + const label = "New Shell"; + const newMongoShellBtn: CommandButtonComponentProps = { + iconSrc: HostedTerminalIcon, + iconAlt: label, + onCommandClick: () => { + const selectedCollection: ViewModels.Collection = selectedNodeState.findSelectedCollection(); + selectedCollection && selectedCollection.onNewMongoShellClick(); + }, + commandButtonLabel: label, + ariaLabel: label, + hasPopup: true, + disabled: false, + tooltipText: label, + }; + buttons.push(newMongoShellBtn); + } } return buttons; diff --git a/src/Explorer/Notebook/useNotebook.ts b/src/Explorer/Notebook/useNotebook.ts index 9713ba0a1..b253383f8 100644 --- a/src/Explorer/Notebook/useNotebook.ts +++ b/src/Explorer/Notebook/useNotebook.ts @@ -320,7 +320,7 @@ export const useNotebook: UseStore = create((set, get) => ({ isPhoenixFeatures = userContext.features.phoenixFeatures; isPhoenixDisabled = !isPublicInternetAllowed && (isPhoenixNotebooks || isPhoenixFeatures); } else { - isPhoenixNotebooks = isPhoenixFeatures = isPublicInternetAllowed; + isPhoenixNotebooks = isPhoenixFeatures = true; isPhoenixDisabled = !isPublicInternetAllowed; } } else if ( diff --git a/src/Explorer/Tree/ResourceTree.tsx b/src/Explorer/Tree/ResourceTree.tsx index 15143be94..ecbf0d7a9 100644 --- a/src/Explorer/Tree/ResourceTree.tsx +++ b/src/Explorer/Tree/ResourceTree.tsx @@ -121,7 +121,7 @@ export const ResourceTree: React.FC = ({ container }: Resourc children: [], }; - if (!useNotebook.getState().isPhoenixNotebooks && !useNotebook.getState().isPhoenixDisabled) { + if (!useNotebook.getState().isPhoenixNotebooks) { notebooksTree.children.push(buildNotebooksTemporarilyDownTree()); } else { if (galleryContentRoot) {