From 89c7ebdd2019630031679dd642dcbf3c72ef541a Mon Sep 17 00:00:00 2001 From: Karthik chakravarthy <88904658+kcheekuri@users.noreply.github.com> Date: Wed, 10 Aug 2022 09:29:23 -0400 Subject: [PATCH] Hide connect button incase Phoenix Notebooks flight is false (#1314) * Hide connect button id flight notebooks is false and show only if features are used --- .../Menus/CommandBar/CommandBarComponentAdapter.tsx | 11 +++++++++-- .../CommandBar/CommandBarComponentButtonFactory.tsx | 4 ++++ src/Explorer/Notebook/useNotebook.ts | 4 ++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/Explorer/Menus/CommandBar/CommandBarComponentAdapter.tsx b/src/Explorer/Menus/CommandBar/CommandBarComponentAdapter.tsx index 8827994e4..0c49ca961 100644 --- a/src/Explorer/Menus/CommandBar/CommandBarComponentAdapter.tsx +++ b/src/Explorer/Menus/CommandBar/CommandBarComponentAdapter.tsx @@ -7,7 +7,7 @@ import { CommandBar as FluentCommandBar, ICommandBarItemProps } from "@fluentui/ import { useNotebook } from "Explorer/Notebook/useNotebook"; import * as React from "react"; import create, { UseStore } from "zustand"; -import { StyleConstants } from "../../../Common/Constants"; +import { ConnectionStatusType, StyleConstants } from "../../../Common/Constants"; import { CommandButtonComponentProps } from "../../Controls/CommandButton/CommandButtonComponent"; import Explorer from "../../Explorer"; import { useSelectedNode } from "../../useSelectedNode"; @@ -53,7 +53,14 @@ 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) { + const connectionInfo = useNotebook((state) => state.connectionInfo); + + if ( + useNotebook.getState().isPhoenixNotebooks || + (useNotebook.getState().isPhoenixFeatures && + connectionInfo?.status !== ConnectionStatusType.Connect && + connectionInfo?.status !== ConnectionStatusType.Reconnect) + ) { uiFabricControlButtons.unshift(CommandBarUtil.createConnectionStatus(container, "connectionStatus")); } diff --git a/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.tsx b/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.tsx index 3a1a9c9db..b37b86c2d 100644 --- a/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.tsx +++ b/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.tsx @@ -104,6 +104,10 @@ export function createStaticCommandBarButtons( if (!useNotebook.getState().isPhoenixFeatures) { applyNotebooksTemporarilyDownStyle(btn, Constants.Notebook.mongoShellTemporarilyDownMsg); } + } else if (btn.commandButtonLabel.indexOf("Open Terminal") !== -1) { + if (!useNotebook.getState().isPhoenixFeatures) { + applyNotebooksTemporarilyDownStyle(btn, Constants.Notebook.temporarilyDownMsg); + } } else if (!useNotebook.getState().isPhoenixNotebooks) { applyNotebooksTemporarilyDownStyle(btn, Constants.Notebook.temporarilyDownMsg); } diff --git a/src/Explorer/Notebook/useNotebook.ts b/src/Explorer/Notebook/useNotebook.ts index d283b7a7b..b32d60eaf 100644 --- a/src/Explorer/Notebook/useNotebook.ts +++ b/src/Explorer/Notebook/useNotebook.ts @@ -312,8 +312,8 @@ export const useNotebook: UseStore = create((set, get) => ({ if (dbAccountAllowedInfo.status === HttpStatusCodes.OK) { if (dbAccountAllowedInfo?.type === PhoenixErrorType.PhoenixFlightFallback) { - isPhoenixNotebooks = isPublicInternetAllowed && userContext.features.phoenixNotebooks; - isPhoenixFeatures = isPublicInternetAllowed && userContext.features.phoenixFeatures; + isPhoenixNotebooks = isPublicInternetAllowed && userContext.features.phoenixNotebooks === true; + isPhoenixFeatures = isPublicInternetAllowed && userContext.features.phoenixFeatures === true; } else { isPhoenixNotebooks = isPhoenixFeatures = isPublicInternetAllowed; }