enhancement(sidebar): hide note deletion button when not being owner

Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
Erik Michelson 2024-01-11 21:56:25 +01:00
parent 4b8f6da78a
commit 4755af4ac5

View file

@ -17,6 +17,7 @@ import styles from './style/sidebar.module.scss'
import { DocumentSidebarMenuSelection } from './types'
import React, { useCallback, useRef, useState } from 'react'
import { useClickAway } from 'react-use'
import { useIsOwner } from '../../../hooks/common/use-is-owner'
/**
* Renders the sidebar for the editor.
@ -24,6 +25,7 @@ import { useClickAway } from 'react-use'
export const Sidebar: React.FC = () => {
const sideBarRef = useRef<HTMLDivElement>(null)
const [selectedMenu, setSelectedMenu] = useState<DocumentSidebarMenuSelection>(DocumentSidebarMenuSelection.NONE)
const isOwner = useIsOwner()
useClickAway(sideBarRef, () => {
setSelectedMenu(DocumentSidebarMenuSelection.NONE)
@ -66,8 +68,7 @@ export const Sidebar: React.FC = () => {
onClick={toggleValue}
/>
<ShareNoteSidebarEntry hide={selectionIsNotNone} />
{/* TODO only show if user has permissions (Owner) (https://github.com/hedgedoc/hedgedoc/issues/5036) */}
<DeleteNoteSidebarEntry hide={selectionIsNotNone} />
{isOwner && <DeleteNoteSidebarEntry hide={selectionIsNotNone} />}
<PinNoteSidebarEntry hide={selectionIsNotNone} />
</div>
</div>