mirror of
https://github.com/Steffo99/sophon.git
synced 2024-12-23 07:14:21 +00:00
31 lines
983 B
TypeScript
31 lines
983 B
TypeScript
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"
|
|
import {useGroupMembership} from "../group/useGroupMembership"
|
|
|
|
|
|
export interface NotebookDeleteButtonProps {
|
|
resource: ManagedResource<SophonNotebook>,
|
|
}
|
|
|
|
|
|
export function NotebookDeleteButton({resource}: NotebookDeleteButtonProps): JSX.Element | null {
|
|
if(!useGroupMembership()) {
|
|
return null
|
|
}
|
|
if(resource.value.is_running) {
|
|
return null
|
|
}
|
|
if(resource.value.locked_by) {
|
|
return null
|
|
}
|
|
|
|
return (
|
|
<SafetyButton timeout={3} onClick={() => resource.destroy()} disabled={resource.busy}>
|
|
<FontAwesomeIcon icon={faTrash} spin={resource.busy}/> Delete
|
|
</SafetyButton>
|
|
)
|
|
}
|