1
Fork 0
mirror of https://github.com/Steffo99/sophon.git synced 2024-12-22 14:54:22 +00:00
This commit is contained in:
Steffo 2021-10-20 22:19:21 +02:00
parent fae22ac62c
commit a7f8cbd57c

View file

@ -1,6 +1,7 @@
import {Box, Details, Form, Idiomatic as I, useFormState} from "@steffo/bluelib-react" import {Box, Details, Form, Idiomatic as I, useFormState} from "@steffo/bluelib-react"
import * as React from "react" import * as React from "react"
import {useAuthorizationContext} from "../../contexts/authorization" import {useAuthorizationContext} from "../../contexts/authorization"
import {useGroupContext} from "../../contexts/group"
import {useProjectContext} from "../../contexts/project" import {useProjectContext} from "../../contexts/project"
import {useApplyChanges} from "../../hooks/useApplyChanges" import {useApplyChanges} from "../../hooks/useApplyChanges"
import {useFormSlug} from "../../hooks/useFormSlug" import {useFormSlug} from "../../hooks/useFormSlug"
@ -17,6 +18,7 @@ export interface NotebookCreateBoxProps {
export function NotebookCreateBox({viewSet, resource}: NotebookCreateBoxProps): JSX.Element | null { export function NotebookCreateBox({viewSet, resource}: NotebookCreateBoxProps): JSX.Element | null {
const authorization = useAuthorizationContext() const authorization = useAuthorizationContext()
const group = useGroupContext()
const project = useProjectContext() const project = useProjectContext()
const name = const name =
@ -57,9 +59,17 @@ export function NotebookCreateBox({viewSet, resource}: NotebookCreateBoxProps):
if(!authorization) { if(!authorization) {
return null return null
} }
if(!group) {
return null
}
if(!authorization.state.token) { if(!authorization.state.token) {
return null return null
} }
if(!(
group.value.members.includes(authorization.state.user.id) || group.value.owner === authorization.state.user.id
)) {
return null
}
if(resource) { if(resource) {
if(resource.value.locked_by) { if(resource.value.locked_by) {
return null return null