mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 11:16:31 -05: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 React, { Fragment, useCallback } from 'react'
|
||||||
import { Trash as IconTrash } from 'react-bootstrap-icons'
|
import { Trash as IconTrash } from 'react-bootstrap-icons'
|
||||||
import { Trans, useTranslation } from 'react-i18next'
|
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.
|
* 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 }) => {
|
export const DeleteNoteSidebarEntry: React.FC<PropsWithChildren<SpecificSidebarEntryProps>> = ({ hide, className }) => {
|
||||||
useTranslation()
|
useTranslation()
|
||||||
|
const userIsOwner = useIsOwner()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const noteId = useApplicationState((state) => state.noteDetails?.id)
|
const noteId = useApplicationState((state) => state.noteDetails?.id)
|
||||||
const [modalVisibility, showModal, closeModal] = useBooleanState()
|
const [modalVisibility, showModal, closeModal] = useBooleanState()
|
||||||
|
@ -40,6 +42,10 @@ export const DeleteNoteSidebarEntry: React.FC<PropsWithChildren<SpecificSidebarE
|
||||||
.finally(closeModal)
|
.finally(closeModal)
|
||||||
}, [closeModal, noteId, router, showErrorNotification])
|
}, [closeModal, noteId, router, showErrorNotification])
|
||||||
|
|
||||||
|
if (!userIsOwner) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<SidebarButton
|
<SidebarButton
|
||||||
|
|
Loading…
Reference in a new issue