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
This commit is contained in:
Karthik chakravarthy 2022-08-10 09:29:23 -04:00 committed by GitHub
parent d0c2f72ed3
commit 89c7ebdd20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 4 deletions

View File

@ -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<Props> = ({ 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"));
}

View File

@ -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);
}

View File

@ -312,8 +312,8 @@ export const useNotebook: UseStore<NotebookState> = 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;
}