mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-04-15 14:17:29 +01:00
Disable notebooks temporarily (#978)
* Disable notebooks temporarily * Updates
This commit is contained in:
parent
f8ac36962b
commit
24d0a16123
@ -350,6 +350,11 @@ export class Notebook {
|
|||||||
public static readonly kernelRestartInitialDelayMs = 1000;
|
public static readonly kernelRestartInitialDelayMs = 1000;
|
||||||
public static readonly kernelRestartMaxDelayMs = 20000;
|
public static readonly kernelRestartMaxDelayMs = 20000;
|
||||||
public static readonly autoSaveIntervalMs = 120000;
|
public static readonly autoSaveIntervalMs = 120000;
|
||||||
|
public static readonly temporarilyDownMsg = "Notebooks is currently not available. We are working on it.";
|
||||||
|
public static readonly mongoShellTemporarilyDownMsg =
|
||||||
|
"We have identified an issue with the Mongo Shell and it is unavailable right now. We are actively working on the mitigation.";
|
||||||
|
public static readonly cassandraShellTemporarilyDownMsg =
|
||||||
|
"We have identified an issue with the Cassandra Shell and it is unavailable right now. We are actively working on the mitigation.";
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SparkLibrary {
|
export class SparkLibrary {
|
||||||
|
@ -83,6 +83,7 @@ export const createCollectionContextMenuButton = (
|
|||||||
|
|
||||||
items.push({
|
items.push({
|
||||||
iconSrc: HostedTerminalIcon,
|
iconSrc: HostedTerminalIcon,
|
||||||
|
isDisabled: useNotebook.getState().isShellEnabled && userContext.features.notebooksTemporarilyDown,
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
const selectedCollection: ViewModels.Collection = useSelectedNode.getState().findSelectedCollection();
|
const selectedCollection: ViewModels.Collection = useSelectedNode.getState().findSelectedCollection();
|
||||||
if (useNotebook.getState().isShellEnabled) {
|
if (useNotebook.getState().isShellEnabled) {
|
||||||
|
@ -70,30 +70,45 @@ export function createStaticCommandBarButtons(
|
|||||||
buttons.push(createDivider());
|
buttons.push(createDivider());
|
||||||
|
|
||||||
if (useNotebook.getState().isNotebookEnabled) {
|
if (useNotebook.getState().isNotebookEnabled) {
|
||||||
|
const notebookButtons: CommandButtonComponentProps[] = [];
|
||||||
|
|
||||||
const newNotebookButton = createNewNotebookButton(container);
|
const newNotebookButton = createNewNotebookButton(container);
|
||||||
newNotebookButton.children = [createNewNotebookButton(container), createuploadNotebookButton(container)];
|
newNotebookButton.children = [createNewNotebookButton(container), createuploadNotebookButton(container)];
|
||||||
buttons.push(newNotebookButton);
|
notebookButtons.push(newNotebookButton);
|
||||||
|
|
||||||
if (container.notebookManager?.gitHubOAuthService) {
|
if (container.notebookManager?.gitHubOAuthService) {
|
||||||
buttons.push(createManageGitHubAccountButton(container));
|
notebookButtons.push(createManageGitHubAccountButton(container));
|
||||||
}
|
}
|
||||||
|
|
||||||
buttons.push(createOpenTerminalButton(container));
|
notebookButtons.push(createOpenTerminalButton(container));
|
||||||
|
|
||||||
buttons.push(createNotebookWorkspaceResetButton(container));
|
notebookButtons.push(createNotebookWorkspaceResetButton(container));
|
||||||
if (
|
if (
|
||||||
(userContext.apiType === "Mongo" &&
|
(userContext.apiType === "Mongo" &&
|
||||||
useNotebook.getState().isShellEnabled &&
|
useNotebook.getState().isShellEnabled &&
|
||||||
selectedNodeState.isDatabaseNodeOrNoneSelected()) ||
|
selectedNodeState.isDatabaseNodeOrNoneSelected()) ||
|
||||||
userContext.apiType === "Cassandra"
|
userContext.apiType === "Cassandra"
|
||||||
) {
|
) {
|
||||||
buttons.push(createDivider());
|
notebookButtons.push(createDivider());
|
||||||
if (userContext.apiType === "Cassandra") {
|
if (userContext.apiType === "Cassandra") {
|
||||||
buttons.push(createOpenCassandraTerminalButton(container));
|
notebookButtons.push(createOpenCassandraTerminalButton(container));
|
||||||
} else {
|
} else {
|
||||||
buttons.push(createOpenMongoTerminalButton(container));
|
notebookButtons.push(createOpenMongoTerminalButton(container));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
notebookButtons.forEach((btn) => {
|
||||||
|
if (userContext.features.notebooksTemporarilyDown) {
|
||||||
|
if (btn.commandButtonLabel.indexOf("Cassandra") !== -1) {
|
||||||
|
applyNotebooksTemporarilyDownStyle(btn, Constants.Notebook.cassandraShellTemporarilyDownMsg);
|
||||||
|
} else if (btn.commandButtonLabel.indexOf("Mongo") !== -1) {
|
||||||
|
applyNotebooksTemporarilyDownStyle(btn, Constants.Notebook.mongoShellTemporarilyDownMsg);
|
||||||
|
} else {
|
||||||
|
applyNotebooksTemporarilyDownStyle(btn, Constants.Notebook.temporarilyDownMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
buttons.push(btn);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
if (!isRunningOnNationalCloud()) {
|
if (!isRunningOnNationalCloud()) {
|
||||||
buttons.push(createEnableNotebooksButton(container));
|
buttons.push(createEnableNotebooksButton(container));
|
||||||
@ -152,7 +167,9 @@ export function createContextCommandBarButtons(
|
|||||||
onCommandClick: () => {
|
onCommandClick: () => {
|
||||||
const selectedCollection: ViewModels.Collection = selectedNodeState.findSelectedCollection();
|
const selectedCollection: ViewModels.Collection = selectedNodeState.findSelectedCollection();
|
||||||
if (useNotebook.getState().isShellEnabled) {
|
if (useNotebook.getState().isShellEnabled) {
|
||||||
container.openNotebookTerminal(ViewModels.TerminalKind.Mongo);
|
if (!userContext.features.notebooksTemporarilyDown) {
|
||||||
|
container.openNotebookTerminal(ViewModels.TerminalKind.Mongo);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
selectedCollection && selectedCollection.onNewMongoShellClick();
|
selectedCollection && selectedCollection.onNewMongoShellClick();
|
||||||
}
|
}
|
||||||
@ -160,7 +177,13 @@ export function createContextCommandBarButtons(
|
|||||||
commandButtonLabel: label,
|
commandButtonLabel: label,
|
||||||
ariaLabel: label,
|
ariaLabel: label,
|
||||||
hasPopup: true,
|
hasPopup: true,
|
||||||
disabled: selectedNodeState.isDatabaseNodeOrNoneSelected() && userContext.apiType === "Mongo",
|
tooltipText:
|
||||||
|
useNotebook.getState().isShellEnabled && userContext.features.notebooksTemporarilyDown
|
||||||
|
? Constants.Notebook.mongoShellTemporarilyDownMsg
|
||||||
|
: undefined,
|
||||||
|
disabled:
|
||||||
|
(selectedNodeState.isDatabaseNodeOrNoneSelected() && userContext.apiType === "Mongo") ||
|
||||||
|
(useNotebook.getState().isShellEnabled && userContext.features.notebooksTemporarilyDown),
|
||||||
};
|
};
|
||||||
buttons.push(newMongoShellBtn);
|
buttons.push(newMongoShellBtn);
|
||||||
}
|
}
|
||||||
@ -388,6 +411,13 @@ export function createScriptCommandButtons(selectedNodeState: SelectedNodeState)
|
|||||||
return buttons;
|
return buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function applyNotebooksTemporarilyDownStyle(buttonProps: CommandButtonComponentProps, tooltip: string): void {
|
||||||
|
if (!buttonProps.isDivider) {
|
||||||
|
buttonProps.disabled = true;
|
||||||
|
buttonProps.tooltipText = tooltip;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function createNewNotebookButton(container: Explorer): CommandButtonComponentProps {
|
function createNewNotebookButton(container: Explorer): CommandButtonComponentProps {
|
||||||
const label = "New Notebook";
|
const label = "New Notebook";
|
||||||
return {
|
return {
|
||||||
|
@ -83,7 +83,11 @@ export class SplashScreen extends React.Component<SplashScreenProps> {
|
|||||||
public render(): JSX.Element {
|
public render(): JSX.Element {
|
||||||
const mainItems = this.createMainItems();
|
const mainItems = this.createMainItems();
|
||||||
const commonTaskItems = this.createCommonTaskItems();
|
const commonTaskItems = this.createCommonTaskItems();
|
||||||
const recentItems = this.createRecentItems();
|
let recentItems = this.createRecentItems();
|
||||||
|
if (userContext.features.notebooksTemporarilyDown) {
|
||||||
|
recentItems = recentItems.filter((item) => item.description !== "Notebook");
|
||||||
|
}
|
||||||
|
|
||||||
const tipsItems = this.createTipsItems();
|
const tipsItems = this.createTipsItems();
|
||||||
const onClearRecent = this.clearMostRecent;
|
const onClearRecent = this.clearMostRecent;
|
||||||
|
|
||||||
@ -219,7 +223,7 @@ export class SplashScreen extends React.Component<SplashScreenProps> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useNotebook.getState().isNotebookEnabled) {
|
if (useNotebook.getState().isNotebookEnabled && !userContext.features.notebooksTemporarilyDown) {
|
||||||
heroes.push({
|
heroes.push({
|
||||||
iconSrc: NewNotebookIcon,
|
iconSrc: NewNotebookIcon,
|
||||||
title: "New Notebook",
|
title: "New Notebook",
|
||||||
|
@ -11,7 +11,7 @@ import NotebookIcon from "../../../images/notebook/Notebook-resource.svg";
|
|||||||
import PublishIcon from "../../../images/notebook/publish_content.svg";
|
import PublishIcon from "../../../images/notebook/publish_content.svg";
|
||||||
import RefreshIcon from "../../../images/refresh-cosmos.svg";
|
import RefreshIcon from "../../../images/refresh-cosmos.svg";
|
||||||
import CollectionIcon from "../../../images/tree-collection.svg";
|
import CollectionIcon from "../../../images/tree-collection.svg";
|
||||||
import { Areas } from "../../Common/Constants";
|
import { Areas, Notebook } from "../../Common/Constants";
|
||||||
import { isPublicInternetAccessAllowed } from "../../Common/DatabaseAccountUtility";
|
import { isPublicInternetAccessAllowed } from "../../Common/DatabaseAccountUtility";
|
||||||
import * as DataModels from "../../Contracts/DataModels";
|
import * as DataModels from "../../Contracts/DataModels";
|
||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
@ -121,23 +121,33 @@ export const ResourceTree: React.FC<ResourceTreeProps> = ({ container }: Resourc
|
|||||||
children: [],
|
children: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
if (galleryContentRoot) {
|
if (userContext.features.notebooksTemporarilyDown) {
|
||||||
notebooksTree.children.push(buildGalleryNotebooksTree());
|
notebooksTree.children.push(buildNotebooksTemporarilyDownTree());
|
||||||
}
|
} else {
|
||||||
|
if (galleryContentRoot) {
|
||||||
|
notebooksTree.children.push(buildGalleryNotebooksTree());
|
||||||
|
}
|
||||||
|
|
||||||
if (myNotebooksContentRoot) {
|
if (myNotebooksContentRoot) {
|
||||||
notebooksTree.children.push(buildMyNotebooksTree());
|
notebooksTree.children.push(buildMyNotebooksTree());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (container.notebookManager?.gitHubOAuthService.isLoggedIn()) {
|
if (container.notebookManager?.gitHubOAuthService.isLoggedIn()) {
|
||||||
// collapse all other notebook nodes
|
// collapse all other notebook nodes
|
||||||
notebooksTree.children.forEach((node) => (node.isExpanded = false));
|
notebooksTree.children.forEach((node) => (node.isExpanded = false));
|
||||||
notebooksTree.children.push(buildGitHubNotebooksTree());
|
notebooksTree.children.push(buildGitHubNotebooksTree());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return notebooksTree;
|
return notebooksTree;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const buildNotebooksTemporarilyDownTree = (): TreeNode => {
|
||||||
|
return {
|
||||||
|
label: Notebook.temporarilyDownMsg,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
const buildGalleryNotebooksTree = (): TreeNode => {
|
const buildGalleryNotebooksTree = (): TreeNode => {
|
||||||
return {
|
return {
|
||||||
label: "Gallery",
|
label: "Gallery",
|
||||||
@ -503,7 +513,12 @@ export const ResourceTree: React.FC<ResourceTreeProps> = ({ container }: Resourc
|
|||||||
contextMenu: ResourceTreeContextMenuButtonFactory.createCollectionContextMenuButton(container, collection),
|
contextMenu: ResourceTreeContextMenuButtonFactory.createCollectionContextMenuButton(container, collection),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isNotebookEnabled && userContext.apiType === "Mongo" && isPublicInternetAccessAllowed()) {
|
if (
|
||||||
|
isNotebookEnabled &&
|
||||||
|
userContext.apiType === "Mongo" &&
|
||||||
|
isPublicInternetAccessAllowed() &&
|
||||||
|
!userContext.features.notebooksTemporarilyDown
|
||||||
|
) {
|
||||||
children.push({
|
children.push({
|
||||||
label: "Schema (Preview)",
|
label: "Schema (Preview)",
|
||||||
onClick: collection.onSchemaAnalyzerClick.bind(collection),
|
onClick: collection.onSchemaAnalyzerClick.bind(collection),
|
||||||
|
@ -28,6 +28,7 @@ export type Features = {
|
|||||||
readonly pr?: string;
|
readonly pr?: string;
|
||||||
readonly showMinRUSurvey: boolean;
|
readonly showMinRUSurvey: boolean;
|
||||||
readonly ttl90Days: boolean;
|
readonly ttl90Days: boolean;
|
||||||
|
readonly notebooksTemporarilyDown: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function extractFeatures(given = new URLSearchParams(window.location.search)): Features {
|
export function extractFeatures(given = new URLSearchParams(window.location.search)): Features {
|
||||||
@ -74,5 +75,6 @@ export function extractFeatures(given = new URLSearchParams(window.location.sear
|
|||||||
autoscaleDefault: "true" === get("autoscaledefault"),
|
autoscaleDefault: "true" === get("autoscaledefault"),
|
||||||
partitionKeyDefault: "true" === get("partitionkeytest"),
|
partitionKeyDefault: "true" === get("partitionkeytest"),
|
||||||
partitionKeyDefault2: "true" === get("pkpartitionkeytest"),
|
partitionKeyDefault2: "true" === get("pkpartitionkeytest"),
|
||||||
|
notebooksTemporarilyDown: "true" === get("notebooksTemporarilyDown", "true"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user