1
Fork 0
mirror of https://github.com/Steffo99/sophon.git synced 2024-12-22 23:04:21 +00:00
sophon/frontend/src/components/notebook/NotebookDeleteButton.tsx

32 lines
983 B
TypeScript
Raw Normal View History

2021-10-14 03:05:01 +00:00
import {faTrash} from "@fortawesome/free-solid-svg-icons"
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
import * as React from "react"
import {ManagedResource} from "../../hooks/useManagedViewSet"
import {SophonNotebook} from "../../types/SophonTypes"
import {SafetyButton} from "../elements/SafetyButton"
2021-10-20 20:39:19 +00:00
import {useGroupMembership} from "../group/useGroupMembership"
2021-10-14 03:05:01 +00:00
export interface NotebookDeleteButtonProps {
resource: ManagedResource<SophonNotebook>,
}
export function NotebookDeleteButton({resource}: NotebookDeleteButtonProps): JSX.Element | null {
2021-10-20 20:39:19 +00:00
if(!useGroupMembership()) {
2021-10-14 03:05:01 +00:00
return null
}
if(resource.value.is_running) {
return null
}
if(resource.value.locked_by) {
return null
}
2021-10-14 03:05:01 +00:00
return (
<SafetyButton timeout={3} onClick={() => resource.destroy()} disabled={resource.busy}>
<FontAwesomeIcon icon={faTrash} spin={resource.busy}/>&nbsp;Delete
</SafetyButton>
)
}