mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-28 16:36:46 +00:00
Update use cases
This commit is contained in:
parent
7862946d1c
commit
29cdfbd3c3
@ -53,11 +53,7 @@ export const CommandBar: React.FC<Props> = ({ container }: Props) => {
|
|||||||
const uiFabricControlButtons = CommandBarUtil.convertButton(controlButtons, backgroundColor);
|
const uiFabricControlButtons = CommandBarUtil.convertButton(controlButtons, backgroundColor);
|
||||||
uiFabricControlButtons.forEach((btn: ICommandBarItemProps) => (btn.iconOnly = true));
|
uiFabricControlButtons.forEach((btn: ICommandBarItemProps) => (btn.iconOnly = true));
|
||||||
|
|
||||||
if (
|
if (useNotebook.getState().isPhoenixNotebooks || useNotebook.getState().isPhoenixFeatures) {
|
||||||
useNotebook.getState().isPhoenixNotebooks ||
|
|
||||||
useNotebook.getState().isPhoenixFeatures ||
|
|
||||||
useNotebook.getState().isPhoenixDisabled
|
|
||||||
) {
|
|
||||||
uiFabricControlButtons.unshift(CommandBarUtil.createConnectionStatus(container, "connectionStatus"));
|
uiFabricControlButtons.unshift(CommandBarUtil.createConnectionStatus(container, "connectionStatus"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,14 +204,14 @@ describe("CommandBarComponentButtonFactory tests", () => {
|
|||||||
//expect(openMongoShellBtn.tooltipText).toBe("");
|
//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().setIsNotebookEnabled(true);
|
||||||
useNotebook.getState().setIsNotebooksEnabledForAccount(true);
|
useNotebook.getState().setIsNotebooksEnabledForAccount(true);
|
||||||
useNotebook.getState().setIsShellEnabled(false);
|
useNotebook.getState().setIsShellEnabled(false);
|
||||||
|
|
||||||
const buttons = CommandBarComponentButtonFactory.createStaticCommandBarButtons(mockExplorer, selectedNodeState);
|
const buttons = CommandBarComponentButtonFactory.createStaticCommandBarButtons(mockExplorer, selectedNodeState);
|
||||||
const openMongoShellBtn = buttons.find((button) => button.commandButtonLabel === openMongoShellBtnLabel);
|
const openMongoShellBtn = buttons.find((button) => button.commandButtonLabel === openMongoShellBtnLabel);
|
||||||
expect(openMongoShellBtn.disabled).toBe(true);
|
expect(openMongoShellBtn).toBeUndefined();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -86,7 +86,9 @@ export function createStaticCommandBarButtons(
|
|||||||
notebookButtons.push(createNotebookWorkspaceResetButton(container));
|
notebookButtons.push(createNotebookWorkspaceResetButton(container));
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
(userContext.apiType === "Mongo" && selectedNodeState.isDatabaseNodeOrNoneSelected()) ||
|
(userContext.apiType === "Mongo" &&
|
||||||
|
selectedNodeState.isDatabaseNodeOrNoneSelected() &&
|
||||||
|
useNotebook.getState().isShellEnabled) ||
|
||||||
userContext.apiType === "Cassandra"
|
userContext.apiType === "Cassandra"
|
||||||
) {
|
) {
|
||||||
notebookButtons.push(createDivider());
|
notebookButtons.push(createDivider());
|
||||||
@ -98,19 +100,23 @@ export function createStaticCommandBarButtons(
|
|||||||
}
|
}
|
||||||
|
|
||||||
notebookButtons.forEach((btn) => {
|
notebookButtons.forEach((btn) => {
|
||||||
|
const isPhoenixFeaturesDownMsg =
|
||||||
|
(!useNotebook.getState().isPhoenixFeatures && !useNotebook.getState().isPhoenixDisabled) ||
|
||||||
|
(!useNotebook.getState().isPhoenixFeatures && useNotebook.getState().isPhoenixDisabled);
|
||||||
|
|
||||||
if (btn.commandButtonLabel.indexOf("Cassandra") !== -1) {
|
if (btn.commandButtonLabel.indexOf("Cassandra") !== -1) {
|
||||||
if (!useNotebook.getState().isPhoenixFeatures && !useNotebook.getState().isPhoenixDisabled) {
|
if (isPhoenixFeaturesDownMsg) {
|
||||||
applyNotebooksStyleProps(btn, Constants.Notebook.cassandraShellTemporarilyDownMsg);
|
applyNotebooksStyleProps(btn, Constants.Notebook.cassandraShellTemporarilyDownMsg);
|
||||||
} else if (useNotebook.getState().isPhoenixDisabled) {
|
} else if (useNotebook.getState().isPhoenixDisabled) {
|
||||||
applyNotebooksStyleProps(btn, Constants.Notebook.notebookDisabledText);
|
applyNotebooksStyleProps(btn, Constants.Notebook.notebookDisabledText);
|
||||||
}
|
}
|
||||||
} else if (btn.commandButtonLabel.indexOf("Mongo") !== -1) {
|
} else if (btn.commandButtonLabel.indexOf("Mongo") !== -1) {
|
||||||
if (!useNotebook.getState().isPhoenixFeatures && !useNotebook.getState().isPhoenixDisabled) {
|
if (isPhoenixFeaturesDownMsg) {
|
||||||
applyNotebooksStyleProps(btn, Constants.Notebook.mongoShellTemporarilyDownMsg);
|
applyNotebooksStyleProps(btn, Constants.Notebook.mongoShellTemporarilyDownMsg);
|
||||||
} else if (useNotebook.getState().isPhoenixDisabled) {
|
} else if (useNotebook.getState().isPhoenixDisabled) {
|
||||||
applyNotebooksStyleProps(btn, Constants.Notebook.notebookDisabledText);
|
applyNotebooksStyleProps(btn, Constants.Notebook.notebookDisabledText);
|
||||||
}
|
}
|
||||||
} else if (!useNotebook.getState().isPhoenixNotebooks && !useNotebook.getState().isPhoenixDisabled) {
|
} else if (isPhoenixFeaturesDownMsg) {
|
||||||
applyNotebooksStyleProps(btn, Constants.Notebook.temporarilyDownMsg);
|
applyNotebooksStyleProps(btn, Constants.Notebook.temporarilyDownMsg);
|
||||||
} else if (useNotebook.getState().isPhoenixDisabled) {
|
} else if (useNotebook.getState().isPhoenixDisabled) {
|
||||||
applyNotebooksStyleProps(btn, Constants.Notebook.notebookDisabledText);
|
applyNotebooksStyleProps(btn, Constants.Notebook.notebookDisabledText);
|
||||||
@ -177,23 +183,23 @@ export function createContextCommandBarButtons(
|
|||||||
tooltipText: isPhoenixShellDisabled ? Constants.Notebook.notebookDisabledText : undefined,
|
tooltipText: isPhoenixShellDisabled ? Constants.Notebook.notebookDisabledText : undefined,
|
||||||
};
|
};
|
||||||
buttons.push(phoenixMongoShellBtn);
|
buttons.push(phoenixMongoShellBtn);
|
||||||
|
if (!useNotebook.getState().isShellEnabled) {
|
||||||
const label = "New Shell";
|
const label = "New Shell";
|
||||||
const isNewMongoShellDisabled = useNotebook.getState().isShellEnabled && !useNotebook.getState().isPhoenixDisabled;
|
const newMongoShellBtn: CommandButtonComponentProps = {
|
||||||
const newMongoShellBtn: CommandButtonComponentProps = {
|
iconSrc: HostedTerminalIcon,
|
||||||
iconSrc: HostedTerminalIcon,
|
iconAlt: label,
|
||||||
iconAlt: label,
|
onCommandClick: () => {
|
||||||
onCommandClick: () => {
|
const selectedCollection: ViewModels.Collection = selectedNodeState.findSelectedCollection();
|
||||||
const selectedCollection: ViewModels.Collection = selectedNodeState.findSelectedCollection();
|
selectedCollection && selectedCollection.onNewMongoShellClick();
|
||||||
selectedCollection && selectedCollection.onNewMongoShellClick();
|
},
|
||||||
},
|
commandButtonLabel: label,
|
||||||
commandButtonLabel: label,
|
ariaLabel: label,
|
||||||
ariaLabel: label,
|
hasPopup: true,
|
||||||
hasPopup: true,
|
disabled: false,
|
||||||
disabled: isNewMongoShellDisabled,
|
tooltipText: label,
|
||||||
tooltipText: isNewMongoShellDisabled ? Constants.Notebook.newShellDisabledText : undefined,
|
};
|
||||||
};
|
buttons.push(newMongoShellBtn);
|
||||||
buttons.push(newMongoShellBtn);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return buttons;
|
return buttons;
|
||||||
|
@ -320,7 +320,7 @@ export const useNotebook: UseStore<NotebookState> = create((set, get) => ({
|
|||||||
isPhoenixFeatures = userContext.features.phoenixFeatures;
|
isPhoenixFeatures = userContext.features.phoenixFeatures;
|
||||||
isPhoenixDisabled = !isPublicInternetAllowed && (isPhoenixNotebooks || isPhoenixFeatures);
|
isPhoenixDisabled = !isPublicInternetAllowed && (isPhoenixNotebooks || isPhoenixFeatures);
|
||||||
} else {
|
} else {
|
||||||
isPhoenixNotebooks = isPhoenixFeatures = isPublicInternetAllowed;
|
isPhoenixNotebooks = isPhoenixFeatures = true;
|
||||||
isPhoenixDisabled = !isPublicInternetAllowed;
|
isPhoenixDisabled = !isPublicInternetAllowed;
|
||||||
}
|
}
|
||||||
} else if (
|
} else if (
|
||||||
|
@ -121,7 +121,7 @@ export const ResourceTree: React.FC<ResourceTreeProps> = ({ container }: Resourc
|
|||||||
children: [],
|
children: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!useNotebook.getState().isPhoenixNotebooks && !useNotebook.getState().isPhoenixDisabled) {
|
if (!useNotebook.getState().isPhoenixNotebooks) {
|
||||||
notebooksTree.children.push(buildNotebooksTemporarilyDownTree());
|
notebooksTree.children.push(buildNotebooksTemporarilyDownTree());
|
||||||
} else {
|
} else {
|
||||||
if (galleryContentRoot) {
|
if (galleryContentRoot) {
|
||||||
|
Loading…
Reference in New Issue
Block a user