mirror of
https://github.com/Steffo99/sophon.git
synced 2024-12-23 15:24:21 +00:00
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import {faFlask} from "@fortawesome/free-solid-svg-icons"
|
|
import * as React from "react"
|
|
import {useAuthorizationContext} from "../../contexts/authorization"
|
|
import {useNotebookContext} from "../../contexts/notebook"
|
|
import {IconText} from "../elements/IconText"
|
|
import {NavigateButton} from "../elements/NavigateButton"
|
|
|
|
|
|
export function NotebookLabButton(): JSX.Element | null {
|
|
const authorization = useAuthorizationContext()
|
|
const notebook = useNotebookContext()
|
|
|
|
const canOpen =
|
|
React.useMemo(
|
|
() => authorization &&
|
|
notebook &&
|
|
(
|
|
notebook.value.locked_by === null || notebook.value.locked_by === authorization?.state.user?.id
|
|
),
|
|
[notebook, authorization],
|
|
)
|
|
|
|
if(!notebook) {
|
|
return null
|
|
}
|
|
if(!notebook.value.lab_url) {
|
|
return null
|
|
}
|
|
|
|
return (
|
|
<NavigateButton href={notebook.value.lab_url} disabled={!canOpen}>
|
|
<IconText icon={faFlask}>
|
|
Open JupyterLab
|
|
</IconText>
|
|
</NavigateButton>
|
|
)
|
|
}
|