mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-12-23 01:02:12 +00:00
enhancement(sidebar): hide delete note button when not being the owner
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
parent
f786fe538b
commit
e53ad15bfe
1 changed files with 6 additions and 0 deletions
|
@ -16,6 +16,7 @@ import type { PropsWithChildren } from 'react'
|
|||
import React, { Fragment, useCallback } from 'react'
|
||||
import { Trash as IconTrash } from 'react-bootstrap-icons'
|
||||
import { Trans, useTranslation } from 'react-i18next'
|
||||
import { useIsOwner } from '../../../../../hooks/common/use-is-owner'
|
||||
|
||||
/**
|
||||
* Sidebar entry that can be used to delete the current note.
|
||||
|
@ -25,6 +26,7 @@ import { Trans, useTranslation } from 'react-i18next'
|
|||
*/
|
||||
export const DeleteNoteSidebarEntry: React.FC<PropsWithChildren<SpecificSidebarEntryProps>> = ({ hide, className }) => {
|
||||
useTranslation()
|
||||
const userIsOwner = useIsOwner()
|
||||
const router = useRouter()
|
||||
const noteId = useApplicationState((state) => state.noteDetails?.id)
|
||||
const [modalVisibility, showModal, closeModal] = useBooleanState()
|
||||
|
@ -40,6 +42,10 @@ export const DeleteNoteSidebarEntry: React.FC<PropsWithChildren<SpecificSidebarE
|
|||
.finally(closeModal)
|
||||
}, [closeModal, noteId, router, showErrorNotification])
|
||||
|
||||
if (!userIsOwner) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
<SidebarButton
|
||||
|
|
Loading…
Reference in a new issue