mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-26 12:21:23 +00:00
* Add Security Warning Bar for untrusted notebooks * Update * Another update * Add a snapshot test * UX updates * More updates * Add tests * Update test snapshot * Update string * Update security message
60 lines
1.9 KiB
TypeScript
60 lines
1.9 KiB
TypeScript
import { IconButton, Spinner, SpinnerSize } from "@fluentui/react";
|
|
import * as React from "react";
|
|
import { NotebookUtil } from "../NotebookUtil";
|
|
import { PassedPromptProps } from "./Prompt";
|
|
import "./Prompt.less";
|
|
|
|
export const promptContent = (props: PassedPromptProps): JSX.Element => {
|
|
if (props.status === "busy") {
|
|
const stopButtonText = "Stop cell execution";
|
|
return (
|
|
<div
|
|
style={{ position: "sticky", width: "100%", maxHeight: "100%", left: 0, top: 0, zIndex: 300 }}
|
|
className={props.isHovered ? "" : "greyStopButton"}
|
|
>
|
|
<IconButton
|
|
className="runCellButton"
|
|
iconProps={{ iconName: "CircleStopSolid" }}
|
|
title={stopButtonText}
|
|
ariaLabel={stopButtonText}
|
|
onClick={props.stopCell}
|
|
style={{ position: "absolute" }}
|
|
/>
|
|
<Spinner size={SpinnerSize.large} style={{ position: "absolute", width: "100%", paddingTop: 5 }} />
|
|
</div>
|
|
);
|
|
} else if (props.isHovered) {
|
|
const playButtonText = props.isRunDisabled ? NotebookUtil.UntrustedNotebookRunHint : "Run cell";
|
|
return (
|
|
<div className={props.isRunDisabled ? "disabledRunCellButton" : ""}>
|
|
<IconButton
|
|
className="runCellButton"
|
|
iconProps={{ iconName: "MSNVideosSolid" }}
|
|
title={playButtonText}
|
|
ariaLabel={playButtonText}
|
|
disabled={props.isRunDisabled}
|
|
onClick={props.runCell}
|
|
/>
|
|
</div>
|
|
);
|
|
} else {
|
|
return <div style={{ paddingTop: 7 }}>{promptText(props)}</div>;
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Generate what text goes inside the prompt based on the props to the prompt
|
|
*/
|
|
const promptText = (props: PassedPromptProps): string => {
|
|
if (props.status === "busy") {
|
|
return "[*]";
|
|
}
|
|
if (props.status === "queued") {
|
|
return "[…]";
|
|
}
|
|
if (typeof props.executionCount === "number") {
|
|
return `[${props.executionCount}]`;
|
|
}
|
|
return "[ ]";
|
|
};
|