2021-10-15 15:22:11 +00:00
|
|
|
import {faBook} from "@fortawesome/free-solid-svg-icons"
|
|
|
|
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
|
2021-10-16 14:31:03 +00:00
|
|
|
import {Box, BringAttention as B, Code, Form, Heading, Idiomatic as I} from "@steffo/bluelib-react"
|
2021-10-15 15:22:11 +00:00
|
|
|
import * as React from "react"
|
|
|
|
import {useCacheContext} from "../../contexts/cache"
|
|
|
|
import {useNotebookContext} from "../../contexts/notebook"
|
2021-10-16 14:31:03 +00:00
|
|
|
import {NotebookLabButton} from "./NotebookLabButton"
|
|
|
|
import {NotebookLegacyButton} from "./NotebookLegacyButton"
|
2021-10-15 15:22:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
export function NotebookDescriptionBox(): JSX.Element | null {
|
|
|
|
const cache = useCacheContext()
|
|
|
|
const notebook = useNotebookContext()
|
|
|
|
|
|
|
|
if(notebook) {
|
|
|
|
var locked_by = cache?.getUserById(notebook.value.locked_by)?.value.username
|
|
|
|
}
|
|
|
|
|
|
|
|
const locked_text =
|
|
|
|
React.useMemo(
|
|
|
|
() => {
|
|
|
|
if(!locked_by) {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>, currently <B>locked by {locked_by}</B></>
|
|
|
|
)
|
|
|
|
},
|
|
|
|
[locked_by],
|
|
|
|
)
|
|
|
|
|
|
|
|
if(!notebook) {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2021-10-16 14:00:18 +00:00
|
|
|
<Box builtinColor={locked_by ? "blue" : undefined}>
|
2021-10-15 15:22:11 +00:00
|
|
|
<Heading level={3}>
|
|
|
|
<FontAwesomeIcon icon={faBook}/> About <I>{notebook.value.name}</I>
|
|
|
|
</Heading>
|
|
|
|
<p>
|
|
|
|
A <B>{notebook.value.is_running ? "running" : "stopped"}</B> notebook using <B><Code>{notebook.value.container_image}</Code></B>{locked_text}.
|
|
|
|
</p>
|
2021-10-16 14:31:03 +00:00
|
|
|
<Form>
|
|
|
|
<Form.Row>
|
|
|
|
<NotebookLabButton/>
|
|
|
|
<NotebookLegacyButton/>
|
|
|
|
</Form.Row>
|
|
|
|
</Form>
|
2021-10-15 15:22:11 +00:00
|
|
|
</Box>
|
|
|
|
)
|
|
|
|
}
|