mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-27 12:51:41 +00:00
Compare commits
3 Commits
cloudshell
...
users/kche
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
29cdfbd3c3 | ||
|
|
7862946d1c | ||
|
|
0ec6495e69 |
@@ -398,6 +398,10 @@ export class Notebook {
|
|||||||
public static cosmosNotebookHomePageUrl = "https://aka.ms/cosmos-notebooks-limits";
|
public static cosmosNotebookHomePageUrl = "https://aka.ms/cosmos-notebooks-limits";
|
||||||
public static cosmosNotebookGitDocumentationUrl = "https://aka.ms/cosmos-notebooks-github";
|
public static cosmosNotebookGitDocumentationUrl = "https://aka.ms/cosmos-notebooks-github";
|
||||||
public static learnMore = "Learn more.";
|
public static learnMore = "Learn more.";
|
||||||
|
public static notebookDisabledText =
|
||||||
|
"This feature is disabled for this user, this can happen because of region restriction, key permissions etc..";
|
||||||
|
public static newShellDisabledText =
|
||||||
|
"This feature is disabled for this user, this is for users with region restriction, key permissions etc..";
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SparkLibrary {
|
export class SparkLibrary {
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ export interface TreeNode {
|
|||||||
timestamp?: number;
|
timestamp?: number;
|
||||||
isLeavesParentsSeparate?: boolean; // Display parents together first, then leaves
|
isLeavesParentsSeparate?: boolean; // Display parents together first, then leaves
|
||||||
isLoading?: boolean;
|
isLoading?: boolean;
|
||||||
|
isDisabled?: boolean;
|
||||||
|
toolTip?: string;
|
||||||
isSelected?: () => boolean;
|
isSelected?: () => boolean;
|
||||||
onClick?: (isExpanded: boolean) => void; // Only if a leaf, other click will expand/collapse
|
onClick?: (isExpanded: boolean) => void; // Only if a leaf, other click will expand/collapse
|
||||||
onExpanded?: () => void;
|
onExpanded?: () => void;
|
||||||
@@ -169,9 +171,15 @@ export class TreeNodeComponent extends React.Component<TreeNodeComponentProps, T
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={`${this.props.node.className || ""} main${generation} nodeItem ${showSelected ? "selected" : ""}`}
|
className={`${this.props.node.className || ""} main${generation} nodeItem ${showSelected ? "selected" : ""} ${
|
||||||
onClick={(event: React.MouseEvent<HTMLDivElement>) => this.onNodeClick(event, node)}
|
this.props.node.isDisabled ? "disable" : ""
|
||||||
onKeyPress={(event: React.KeyboardEvent<HTMLDivElement>) => this.onNodeKeyPress(event, node)}
|
}`}
|
||||||
|
onClick={(event: React.MouseEvent<HTMLDivElement>) =>
|
||||||
|
!this.props.node.isDisabled && this.onNodeClick(event, node)
|
||||||
|
}
|
||||||
|
onKeyPress={(event: React.KeyboardEvent<HTMLDivElement>) =>
|
||||||
|
!this.props.node.isDisabled && this.onNodeKeyPress(event, node)
|
||||||
|
}
|
||||||
role="treeitem"
|
role="treeitem"
|
||||||
id={node.id}
|
id={node.id}
|
||||||
>
|
>
|
||||||
@@ -184,7 +192,7 @@ export class TreeNodeComponent extends React.Component<TreeNodeComponentProps, T
|
|||||||
{this.renderCollapseExpandIcon(node)}
|
{this.renderCollapseExpandIcon(node)}
|
||||||
{node.iconSrc && <img className="nodeIcon" src={node.iconSrc} alt="" />}
|
{node.iconSrc && <img className="nodeIcon" src={node.iconSrc} alt="" />}
|
||||||
{node.label && (
|
{node.label && (
|
||||||
<span className="nodeLabel" title={node.label}>
|
<span className="nodeLabel" title={`${node.toolTip ? node.toolTip : node.label}`}>
|
||||||
{node.label}
|
{node.label}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
@@ -195,7 +203,7 @@ export class TreeNodeComponent extends React.Component<TreeNodeComponentProps, T
|
|||||||
</div>
|
</div>
|
||||||
{node.children && (
|
{node.children && (
|
||||||
<AnimateHeight duration={TreeNodeComponent.transitionDurationMS} height={this.state.isExpanded ? "auto" : 0}>
|
<AnimateHeight duration={TreeNodeComponent.transitionDurationMS} height={this.state.isExpanded ? "auto" : 0}>
|
||||||
<div className="nodeChildren" data-test={node.label}>
|
<div className="nodeChildren" data-test={node.label} aria-disabled={node.isDisabled}>
|
||||||
{TreeNodeComponent.getSortedChildren(node).map((childNode: TreeNode) => (
|
{TreeNodeComponent.getSortedChildren(node).map((childNode: TreeNode) => (
|
||||||
<TreeNodeComponent
|
<TreeNodeComponent
|
||||||
key={`${childNode.label}-${generation + 1}-${childNode.timestamp}`}
|
key={`${childNode.label}-${generation + 1}-${childNode.timestamp}`}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ exports[`TreeComponent renders a simple tree 1`] = `
|
|||||||
|
|
||||||
exports[`TreeNodeComponent does not render children by default 1`] = `
|
exports[`TreeNodeComponent does not render children by default 1`] = `
|
||||||
<div
|
<div
|
||||||
className=" main2 nodeItem "
|
className=" main2 nodeItem "
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
onKeyPress={[Function]}
|
onKeyPress={[Function]}
|
||||||
role="treeitem"
|
role="treeitem"
|
||||||
@@ -136,7 +136,7 @@ exports[`TreeNodeComponent does not render children by default 1`] = `
|
|||||||
|
|
||||||
exports[`TreeNodeComponent renders a simple node (sorted children, expanded) 1`] = `
|
exports[`TreeNodeComponent renders a simple node (sorted children, expanded) 1`] = `
|
||||||
<div
|
<div
|
||||||
className="nodeClassname main12 nodeItem "
|
className="nodeClassname main12 nodeItem "
|
||||||
id="id"
|
id="id"
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
onKeyPress={[Function]}
|
onKeyPress={[Function]}
|
||||||
@@ -287,7 +287,7 @@ exports[`TreeNodeComponent renders a simple node (sorted children, expanded) 1`]
|
|||||||
|
|
||||||
exports[`TreeNodeComponent renders loading icon 1`] = `
|
exports[`TreeNodeComponent renders loading icon 1`] = `
|
||||||
<div
|
<div
|
||||||
className=" main2 nodeItem "
|
className=" main2 nodeItem "
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
onKeyPress={[Function]}
|
onKeyPress={[Function]}
|
||||||
role="treeitem"
|
role="treeitem"
|
||||||
@@ -359,7 +359,7 @@ exports[`TreeNodeComponent renders loading icon 1`] = `
|
|||||||
|
|
||||||
exports[`TreeNodeComponent renders sorted children, expanded, leaves and parents separated 1`] = `
|
exports[`TreeNodeComponent renders sorted children, expanded, leaves and parents separated 1`] = `
|
||||||
<div
|
<div
|
||||||
className="nodeClassname main12 nodeItem "
|
className="nodeClassname main12 nodeItem "
|
||||||
id="id"
|
id="id"
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
onKeyPress={[Function]}
|
onKeyPress={[Function]}
|
||||||
@@ -529,7 +529,7 @@ exports[`TreeNodeComponent renders sorted children, expanded, leaves and parents
|
|||||||
|
|
||||||
exports[`TreeNodeComponent renders unsorted children by default 1`] = `
|
exports[`TreeNodeComponent renders unsorted children by default 1`] = `
|
||||||
<div
|
<div
|
||||||
className=" main2 nodeItem "
|
className=" main2 nodeItem "
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
onKeyPress={[Function]}
|
onKeyPress={[Function]}
|
||||||
role="treeitem"
|
role="treeitem"
|
||||||
|
|||||||
@@ -66,7 +66,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.disable{
|
||||||
|
background-color: rgb(255, 255, 255);
|
||||||
|
filter: grayscale();
|
||||||
|
color: rgb(161, 159, 157);
|
||||||
|
}
|
||||||
.treeComponentMenuItemContainer {
|
.treeComponentMenuItemContainer {
|
||||||
font-size: @mediumFontSize;
|
font-size: @mediumFontSize;
|
||||||
|
|
||||||
|
|||||||
@@ -1027,7 +1027,7 @@ export default class Explorer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async openNotebookTerminal(kind: ViewModels.TerminalKind): Promise<void> {
|
public async openNotebookTerminal(kind: ViewModels.TerminalKind): Promise<void> {
|
||||||
if (useNotebook.getState().isPhoenixFeatures) {
|
if (useNotebook.getState().isPhoenixFeatures && !useNotebook.getState().isPhoenixDisabled) {
|
||||||
await this.allocateContainer();
|
await this.allocateContainer();
|
||||||
const notebookServerInfo = useNotebook.getState().notebookServerInfo;
|
const notebookServerInfo = useNotebook.getState().notebookServerInfo;
|
||||||
if (notebookServerInfo && notebookServerInfo.notebookServerEndpoint !== undefined) {
|
if (notebookServerInfo && notebookServerInfo.notebookServerEndpoint !== undefined) {
|
||||||
|
|||||||
@@ -75,7 +75,11 @@ export function createStaticCommandBarButtons(
|
|||||||
if (container.notebookManager?.gitHubOAuthService) {
|
if (container.notebookManager?.gitHubOAuthService) {
|
||||||
notebookButtons.push(createManageGitHubAccountButton(container));
|
notebookButtons.push(createManageGitHubAccountButton(container));
|
||||||
}
|
}
|
||||||
if (useNotebook.getState().isPhoenixFeatures && configContext.isTerminalEnabled) {
|
if (
|
||||||
|
useNotebook.getState().isPhoenixFeatures &&
|
||||||
|
!useNotebook.getState().isPhoenixDisabled &&
|
||||||
|
configContext.isTerminalEnabled
|
||||||
|
) {
|
||||||
notebookButtons.push(createOpenTerminalButton(container));
|
notebookButtons.push(createOpenTerminalButton(container));
|
||||||
}
|
}
|
||||||
if (useNotebook.getState().isPhoenixNotebooks && selectedNodeState.isConnectedToContainer()) {
|
if (useNotebook.getState().isPhoenixNotebooks && selectedNodeState.isConnectedToContainer()) {
|
||||||
@@ -83,8 +87,8 @@ export function createStaticCommandBarButtons(
|
|||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
(userContext.apiType === "Mongo" &&
|
(userContext.apiType === "Mongo" &&
|
||||||
useNotebook.getState().isShellEnabled &&
|
selectedNodeState.isDatabaseNodeOrNoneSelected() &&
|
||||||
selectedNodeState.isDatabaseNodeOrNoneSelected()) ||
|
useNotebook.getState().isShellEnabled) ||
|
||||||
userContext.apiType === "Cassandra"
|
userContext.apiType === "Cassandra"
|
||||||
) {
|
) {
|
||||||
notebookButtons.push(createDivider());
|
notebookButtons.push(createDivider());
|
||||||
@@ -96,16 +100,26 @@ 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) {
|
if (isPhoenixFeaturesDownMsg) {
|
||||||
applyNotebooksTemporarilyDownStyle(btn, Constants.Notebook.cassandraShellTemporarilyDownMsg);
|
applyNotebooksStyleProps(btn, Constants.Notebook.cassandraShellTemporarilyDownMsg);
|
||||||
|
} else if (useNotebook.getState().isPhoenixDisabled) {
|
||||||
|
applyNotebooksStyleProps(btn, Constants.Notebook.notebookDisabledText);
|
||||||
}
|
}
|
||||||
} else if (btn.commandButtonLabel.indexOf("Mongo") !== -1) {
|
} else if (btn.commandButtonLabel.indexOf("Mongo") !== -1) {
|
||||||
if (!useNotebook.getState().isPhoenixFeatures) {
|
if (isPhoenixFeaturesDownMsg) {
|
||||||
applyNotebooksTemporarilyDownStyle(btn, Constants.Notebook.mongoShellTemporarilyDownMsg);
|
applyNotebooksStyleProps(btn, Constants.Notebook.mongoShellTemporarilyDownMsg);
|
||||||
|
} else if (useNotebook.getState().isPhoenixDisabled) {
|
||||||
|
applyNotebooksStyleProps(btn, Constants.Notebook.notebookDisabledText);
|
||||||
}
|
}
|
||||||
} else if (!useNotebook.getState().isPhoenixNotebooks) {
|
} else if (isPhoenixFeaturesDownMsg) {
|
||||||
applyNotebooksTemporarilyDownStyle(btn, Constants.Notebook.temporarilyDownMsg);
|
applyNotebooksStyleProps(btn, Constants.Notebook.temporarilyDownMsg);
|
||||||
|
} else if (useNotebook.getState().isPhoenixDisabled) {
|
||||||
|
applyNotebooksStyleProps(btn, Constants.Notebook.notebookDisabledText);
|
||||||
}
|
}
|
||||||
buttons.push(btn);
|
buttons.push(btn);
|
||||||
});
|
});
|
||||||
@@ -154,25 +168,38 @@ export function createContextCommandBarButtons(
|
|||||||
selectedNodeState: SelectedNodeState
|
selectedNodeState: SelectedNodeState
|
||||||
): CommandButtonComponentProps[] {
|
): CommandButtonComponentProps[] {
|
||||||
const buttons: CommandButtonComponentProps[] = [];
|
const buttons: CommandButtonComponentProps[] = [];
|
||||||
|
|
||||||
if (!selectedNodeState.isDatabaseNodeOrNoneSelected() && userContext.apiType === "Mongo") {
|
if (!selectedNodeState.isDatabaseNodeOrNoneSelected() && userContext.apiType === "Mongo") {
|
||||||
const label = useNotebook.getState().isShellEnabled ? "Open Mongo Shell" : "New Shell";
|
const isPhoenixShellDisabled = !useNotebook.getState().isShellEnabled || useNotebook.getState().isPhoenixDisabled;
|
||||||
const newMongoShellBtn: CommandButtonComponentProps = {
|
const phoenixMongoShellBtn: CommandButtonComponentProps = {
|
||||||
iconSrc: HostedTerminalIcon,
|
iconSrc: HostedTerminalIcon,
|
||||||
iconAlt: label,
|
iconAlt: "Open Mongo Shell",
|
||||||
onCommandClick: () => {
|
onCommandClick: () => {
|
||||||
const selectedCollection: ViewModels.Collection = selectedNodeState.findSelectedCollection();
|
container.openNotebookTerminal(ViewModels.TerminalKind.Mongo);
|
||||||
if (useNotebook.getState().isShellEnabled) {
|
|
||||||
container.openNotebookTerminal(ViewModels.TerminalKind.Mongo);
|
|
||||||
} else {
|
|
||||||
selectedCollection && selectedCollection.onNewMongoShellClick();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
commandButtonLabel: label,
|
commandButtonLabel: "Open Mongo Shell",
|
||||||
ariaLabel: label,
|
ariaLabel: "Open Mongo Shell",
|
||||||
hasPopup: true,
|
hasPopup: true,
|
||||||
|
disabled: isPhoenixShellDisabled,
|
||||||
|
tooltipText: isPhoenixShellDisabled ? Constants.Notebook.notebookDisabledText : undefined,
|
||||||
};
|
};
|
||||||
buttons.push(newMongoShellBtn);
|
buttons.push(phoenixMongoShellBtn);
|
||||||
|
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;
|
return buttons;
|
||||||
@@ -401,7 +428,7 @@ export function createScriptCommandButtons(selectedNodeState: SelectedNodeState)
|
|||||||
return buttons;
|
return buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyNotebooksTemporarilyDownStyle(buttonProps: CommandButtonComponentProps, tooltip: string): void {
|
function applyNotebooksStyleProps(buttonProps: CommandButtonComponentProps, tooltip: string): void {
|
||||||
if (!buttonProps.isDivider) {
|
if (!buttonProps.isDivider) {
|
||||||
buttonProps.disabled = true;
|
buttonProps.disabled = true;
|
||||||
buttonProps.tooltipText = tooltip;
|
buttonProps.tooltipText = tooltip;
|
||||||
@@ -477,10 +504,11 @@ function createOpenTerminalButton(container: Explorer): CommandButtonComponentPr
|
|||||||
|
|
||||||
function createOpenMongoTerminalButton(container: Explorer): CommandButtonComponentProps {
|
function createOpenMongoTerminalButton(container: Explorer): CommandButtonComponentProps {
|
||||||
const label = "Open Mongo Shell";
|
const label = "Open Mongo Shell";
|
||||||
const tooltip =
|
|
||||||
"This feature is not yet available in your account's region. View supported regions here: https://aka.ms/cosmos-enable-notebooks.";
|
|
||||||
const disableButton =
|
const disableButton =
|
||||||
!useNotebook.getState().isNotebooksEnabledForAccount && !useNotebook.getState().isNotebookEnabled;
|
!useNotebook.getState().isNotebooksEnabledForAccount &&
|
||||||
|
(!useNotebook.getState().isNotebookEnabled ||
|
||||||
|
!useNotebook.getState().isShellEnabled ||
|
||||||
|
useNotebook.getState().isPhoenixDisabled);
|
||||||
return {
|
return {
|
||||||
iconSrc: HostedTerminalIcon,
|
iconSrc: HostedTerminalIcon,
|
||||||
iconAlt: label,
|
iconAlt: label,
|
||||||
@@ -493,7 +521,7 @@ function createOpenMongoTerminalButton(container: Explorer): CommandButtonCompon
|
|||||||
hasPopup: false,
|
hasPopup: false,
|
||||||
disabled: disableButton,
|
disabled: disableButton,
|
||||||
ariaLabel: label,
|
ariaLabel: label,
|
||||||
tooltipText: !disableButton ? "" : tooltip,
|
tooltipText: !disableButton ? undefined : Constants.Notebook.notebookDisabledText,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,11 @@
|
|||||||
outline: 0px;
|
outline: 0px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.disableText{
|
||||||
|
background-color: rgb(255, 255, 255)!important;
|
||||||
|
filter: grayscale();
|
||||||
|
color: rgb(161, 159, 157)!important;
|
||||||
|
}
|
||||||
.connectIcon{
|
.connectIcon{
|
||||||
margin: 0px 4px;
|
margin: 0px 4px;
|
||||||
height: 18px;
|
height: 18px;
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ interface Props {
|
|||||||
}
|
}
|
||||||
export const ConnectionStatus: React.FC<Props> = ({ container }: Props): JSX.Element => {
|
export const ConnectionStatus: React.FC<Props> = ({ container }: Props): JSX.Element => {
|
||||||
const connectionInfo = useNotebook((state) => state.connectionInfo);
|
const connectionInfo = useNotebook((state) => state.connectionInfo);
|
||||||
|
const isPhoenixDisabled = useNotebook((state) => state.isPhoenixDisabled);
|
||||||
|
|
||||||
const [second, setSecond] = React.useState("00");
|
const [second, setSecond] = React.useState("00");
|
||||||
const [minute, setMinute] = React.useState("00");
|
const [minute, setMinute] = React.useState("00");
|
||||||
const [isActive, setIsActive] = React.useState(false);
|
const [isActive, setIsActive] = React.useState(false);
|
||||||
@@ -77,6 +79,12 @@ export const ConnectionStatus: React.FC<Props> = ({ container }: Props): JSX.Ele
|
|||||||
}
|
}
|
||||||
}, [connectionInfo.status]);
|
}, [connectionInfo.status]);
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (isPhoenixDisabled) {
|
||||||
|
setToolTipContent(Notebook.notebookDisabledText);
|
||||||
|
}
|
||||||
|
}, [isPhoenixDisabled]);
|
||||||
|
|
||||||
const stopTimer = () => {
|
const stopTimer = () => {
|
||||||
setIsActive(false);
|
setIsActive(false);
|
||||||
setCounter(0);
|
setCounter(0);
|
||||||
@@ -93,11 +101,18 @@ export const ConnectionStatus: React.FC<Props> = ({ container }: Props): JSX.Ele
|
|||||||
(connectionInfo.status === ConnectionStatusType.Connect || connectionInfo.status === ConnectionStatusType.Reconnect)
|
(connectionInfo.status === ConnectionStatusType.Connect || connectionInfo.status === ConnectionStatusType.Reconnect)
|
||||||
) {
|
) {
|
||||||
return (
|
return (
|
||||||
<ActionButton className="commandReactBtn" onClick={() => container.allocateContainer()}>
|
<ActionButton
|
||||||
|
className={isPhoenixDisabled ? "disableText commandReactBtn" : "commandReactBtn"}
|
||||||
|
disabled={isPhoenixDisabled}
|
||||||
|
onClick={() => !isPhoenixDisabled && container.allocateContainer()}
|
||||||
|
>
|
||||||
<TooltipHost content={toolTipContent}>
|
<TooltipHost content={toolTipContent}>
|
||||||
<Stack className="connectionStatusContainer" horizontal>
|
<Stack className="connectionStatusContainer" horizontal>
|
||||||
<Icon iconName="ConnectVirtualMachine" className="connectIcon" />
|
<Icon
|
||||||
<span>{connectionInfo.status}</span>
|
iconName="ConnectVirtualMachine"
|
||||||
|
className={isPhoenixDisabled ? "connectIcon disableText" : "connectIcon"}
|
||||||
|
/>
|
||||||
|
<span className={isPhoenixDisabled ? "disableText" : ""}>{connectionInfo.status}</span>
|
||||||
</Stack>
|
</Stack>
|
||||||
</TooltipHost>
|
</TooltipHost>
|
||||||
</ActionButton>
|
</ActionButton>
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ interface NotebookState {
|
|||||||
containerStatus: ContainerInfo;
|
containerStatus: ContainerInfo;
|
||||||
isPhoenixNotebooks: boolean;
|
isPhoenixNotebooks: boolean;
|
||||||
isPhoenixFeatures: boolean;
|
isPhoenixFeatures: boolean;
|
||||||
|
isPhoenixDisabled: boolean;
|
||||||
setIsNotebookEnabled: (isNotebookEnabled: boolean) => void;
|
setIsNotebookEnabled: (isNotebookEnabled: boolean) => void;
|
||||||
setIsNotebooksEnabledForAccount: (isNotebooksEnabledForAccount: boolean) => void;
|
setIsNotebooksEnabledForAccount: (isNotebooksEnabledForAccount: boolean) => void;
|
||||||
setNotebookServerInfo: (notebookServerInfo: DataModels.NotebookWorkspaceConnectionInfo) => void;
|
setNotebookServerInfo: (notebookServerInfo: DataModels.NotebookWorkspaceConnectionInfo) => void;
|
||||||
@@ -64,6 +65,7 @@ interface NotebookState {
|
|||||||
getPhoenixStatus: () => Promise<void>;
|
getPhoenixStatus: () => Promise<void>;
|
||||||
setIsPhoenixNotebooks: (isPhoenixNotebooks: boolean) => void;
|
setIsPhoenixNotebooks: (isPhoenixNotebooks: boolean) => void;
|
||||||
setIsPhoenixFeatures: (isPhoenixFeatures: boolean) => void;
|
setIsPhoenixFeatures: (isPhoenixFeatures: boolean) => void;
|
||||||
|
setIsPhoenixDisabled: (isPhoenixDisabled: boolean) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useNotebook: UseStore<NotebookState> = create((set, get) => ({
|
export const useNotebook: UseStore<NotebookState> = create((set, get) => ({
|
||||||
@@ -100,6 +102,7 @@ export const useNotebook: UseStore<NotebookState> = create((set, get) => ({
|
|||||||
},
|
},
|
||||||
isPhoenixNotebooks: undefined,
|
isPhoenixNotebooks: undefined,
|
||||||
isPhoenixFeatures: undefined,
|
isPhoenixFeatures: undefined,
|
||||||
|
isPhoenixDisabled: undefined,
|
||||||
setIsNotebookEnabled: (isNotebookEnabled: boolean) => set({ isNotebookEnabled }),
|
setIsNotebookEnabled: (isNotebookEnabled: boolean) => set({ isNotebookEnabled }),
|
||||||
setIsNotebooksEnabledForAccount: (isNotebooksEnabledForAccount: boolean) => set({ isNotebooksEnabledForAccount }),
|
setIsNotebooksEnabledForAccount: (isNotebooksEnabledForAccount: boolean) => set({ isNotebooksEnabledForAccount }),
|
||||||
setNotebookServerInfo: (notebookServerInfo: DataModels.NotebookWorkspaceConnectionInfo) =>
|
setNotebookServerInfo: (notebookServerInfo: DataModels.NotebookWorkspaceConnectionInfo) =>
|
||||||
@@ -305,6 +308,7 @@ export const useNotebook: UseStore<NotebookState> = create((set, get) => ({
|
|||||||
if (get().isPhoenixNotebooks === undefined || get().isPhoenixFeatures === undefined) {
|
if (get().isPhoenixNotebooks === undefined || get().isPhoenixFeatures === undefined) {
|
||||||
let isPhoenixNotebooks = false;
|
let isPhoenixNotebooks = false;
|
||||||
let isPhoenixFeatures = false;
|
let isPhoenixFeatures = false;
|
||||||
|
let isPhoenixDisabled = false;
|
||||||
|
|
||||||
const isPublicInternetAllowed = isPublicInternetAccessAllowed();
|
const isPublicInternetAllowed = isPublicInternetAccessAllowed();
|
||||||
const phoenixClient = new PhoenixClient();
|
const phoenixClient = new PhoenixClient();
|
||||||
@@ -312,18 +316,30 @@ export const useNotebook: UseStore<NotebookState> = create((set, get) => ({
|
|||||||
|
|
||||||
if (dbAccountAllowedInfo.status === HttpStatusCodes.OK) {
|
if (dbAccountAllowedInfo.status === HttpStatusCodes.OK) {
|
||||||
if (dbAccountAllowedInfo?.type === PhoenixErrorType.PhoenixFlightFallback) {
|
if (dbAccountAllowedInfo?.type === PhoenixErrorType.PhoenixFlightFallback) {
|
||||||
isPhoenixNotebooks = isPublicInternetAllowed && userContext.features.phoenixNotebooks;
|
isPhoenixNotebooks = userContext.features.phoenixNotebooks;
|
||||||
isPhoenixFeatures = isPublicInternetAllowed && userContext.features.phoenixFeatures;
|
isPhoenixFeatures = userContext.features.phoenixFeatures;
|
||||||
|
isPhoenixDisabled = !isPublicInternetAllowed && (isPhoenixNotebooks || isPhoenixFeatures);
|
||||||
} else {
|
} else {
|
||||||
isPhoenixNotebooks = isPhoenixFeatures = isPublicInternetAllowed;
|
isPhoenixNotebooks = isPhoenixFeatures = true;
|
||||||
|
isPhoenixDisabled = !isPublicInternetAllowed;
|
||||||
}
|
}
|
||||||
|
} else if (
|
||||||
|
dbAccountAllowedInfo.status === HttpStatusCodes.Forbidden &&
|
||||||
|
(userContext.features.phoenixNotebooks || userContext.features.phoenixFeatures)
|
||||||
|
) {
|
||||||
|
isPhoenixNotebooks = userContext.features.phoenixNotebooks;
|
||||||
|
isPhoenixFeatures = userContext.features.phoenixFeatures;
|
||||||
|
isPhoenixDisabled = true;
|
||||||
} else {
|
} else {
|
||||||
isPhoenixNotebooks = isPhoenixFeatures = false;
|
isPhoenixNotebooks = isPhoenixFeatures = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
set({ isPhoenixNotebooks: isPhoenixNotebooks });
|
set({ isPhoenixNotebooks: isPhoenixNotebooks });
|
||||||
set({ isPhoenixFeatures: isPhoenixFeatures });
|
set({ isPhoenixFeatures: isPhoenixFeatures });
|
||||||
|
set({ isPhoenixDisabled: isPhoenixDisabled });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setIsPhoenixNotebooks: (isPhoenixNotebooks: boolean) => set({ isPhoenixNotebooks: isPhoenixNotebooks }),
|
setIsPhoenixNotebooks: (isPhoenixNotebooks: boolean) => set({ isPhoenixNotebooks: isPhoenixNotebooks }),
|
||||||
setIsPhoenixFeatures: (isPhoenixFeatures: boolean) => set({ isPhoenixFeatures: isPhoenixFeatures }),
|
setIsPhoenixFeatures: (isPhoenixFeatures: boolean) => set({ isPhoenixFeatures: isPhoenixFeatures }),
|
||||||
|
setIsPhoenixDisabled: (isPhoenixDisabled: boolean) => set({ isPhoenixDisabled: isPhoenixDisabled }),
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -156,8 +156,10 @@ export const ResourceTree: React.FC<ResourceTreeProps> = ({ container }: Resourc
|
|||||||
label: "Gallery",
|
label: "Gallery",
|
||||||
iconSrc: GalleryIcon,
|
iconSrc: GalleryIcon,
|
||||||
className: "notebookHeader galleryHeader",
|
className: "notebookHeader galleryHeader",
|
||||||
|
toolTip: useNotebook.getState().isPhoenixDisabled ? Notebook.notebookDisabledText : undefined,
|
||||||
onClick: () => container.openGallery(),
|
onClick: () => container.openGallery(),
|
||||||
isSelected: () => activeTab?.tabKind === ViewModels.CollectionTabKind.Gallery,
|
isSelected: () => activeTab?.tabKind === ViewModels.CollectionTabKind.Gallery,
|
||||||
|
isDisabled: useNotebook.getState().isPhoenixDisabled,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -523,6 +525,8 @@ export const ResourceTree: React.FC<ResourceTreeProps> = ({ container }: Resourc
|
|||||||
children.push({
|
children.push({
|
||||||
label: "Schema (Preview)",
|
label: "Schema (Preview)",
|
||||||
onClick: collection.onSchemaAnalyzerClick.bind(collection),
|
onClick: collection.onSchemaAnalyzerClick.bind(collection),
|
||||||
|
toolTip: useNotebook.getState().isPhoenixDisabled ? Notebook.notebookDisabledText : undefined,
|
||||||
|
isDisabled: useNotebook.getState().isPhoenixDisabled,
|
||||||
isSelected: () =>
|
isSelected: () =>
|
||||||
useSelectedNode
|
useSelectedNode
|
||||||
.getState()
|
.getState()
|
||||||
|
|||||||
Reference in New Issue
Block a user