2021-10-07 03:32:38 +00:00
|
|
|
import {faBook} from "@fortawesome/free-solid-svg-icons"
|
|
|
|
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
|
|
|
|
import * as React from "react"
|
2021-10-14 03:05:01 +00:00
|
|
|
import {useCacheContext} from "../../contexts/cache"
|
2021-10-07 03:32:38 +00:00
|
|
|
import {ManagedResource} from "../../hooks/useManagedViewSet"
|
|
|
|
import {SophonNotebook} from "../../types/SophonTypes"
|
|
|
|
import {Link} from "../elements/Link"
|
|
|
|
import {ResourcePanel} from "../elements/ResourcePanel"
|
2021-10-14 03:05:01 +00:00
|
|
|
import {NotebookDeleteButton} from "./NotebookDeleteButton"
|
|
|
|
import {NotebookLockButton} from "./NotebookLockButton"
|
|
|
|
import {NotebookStartButton} from "./NotebookStartButton"
|
|
|
|
import {NotebookStopButton} from "./NotebookStopButton"
|
|
|
|
import {NotebookUnlockButton} from "./NotebookUnlockButton"
|
2021-10-07 03:32:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
export interface NotebookResourcePanelProps {
|
|
|
|
resource: ManagedResource<SophonNotebook>,
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function NotebookResourcePanel({resource}: NotebookResourcePanelProps): JSX.Element {
|
2021-10-14 03:05:01 +00:00
|
|
|
const cache = useCacheContext()
|
|
|
|
|
|
|
|
const locked_by = cache?.getUserById(resource.value.locked_by)?.value.username
|
2021-10-07 03:32:38 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<ResourcePanel>
|
|
|
|
<ResourcePanel.Icon>
|
|
|
|
<FontAwesomeIcon icon={faBook}/>
|
|
|
|
</ResourcePanel.Icon>
|
|
|
|
<ResourcePanel.Name>
|
|
|
|
<Link href={`n/${resource.value.slug}/`}>
|
|
|
|
{resource.value.name}
|
|
|
|
</Link>
|
|
|
|
</ResourcePanel.Name>
|
|
|
|
<ResourcePanel.Text>
|
2021-10-14 03:05:01 +00:00
|
|
|
{
|
|
|
|
resource.value.locked_by
|
|
|
|
?
|
|
|
|
`Locked by ${locked_by}`
|
|
|
|
:
|
|
|
|
null
|
|
|
|
}
|
2021-10-07 03:32:38 +00:00
|
|
|
</ResourcePanel.Text>
|
|
|
|
<ResourcePanel.Buttons>
|
2021-10-14 03:05:01 +00:00
|
|
|
<NotebookStopButton resource={resource}/>
|
|
|
|
<NotebookStartButton resource={resource}/>
|
|
|
|
<NotebookUnlockButton resource={resource}/>
|
|
|
|
<NotebookLockButton resource={resource}/>
|
|
|
|
<NotebookDeleteButton resource={resource}/>
|
2021-10-07 03:32:38 +00:00
|
|
|
</ResourcePanel.Buttons>
|
|
|
|
</ResourcePanel>
|
|
|
|
)
|
|
|
|
}
|