mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-17 08:34:54 -04:00
enhancement(sidebar): hide note deletion button when not being owner
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
parent
4b8f6da78a
commit
4755af4ac5
1 changed files with 3 additions and 2 deletions
|
@ -17,6 +17,7 @@ import styles from './style/sidebar.module.scss'
|
||||||
import { DocumentSidebarMenuSelection } from './types'
|
import { DocumentSidebarMenuSelection } from './types'
|
||||||
import React, { useCallback, useRef, useState } from 'react'
|
import React, { useCallback, useRef, useState } from 'react'
|
||||||
import { useClickAway } from 'react-use'
|
import { useClickAway } from 'react-use'
|
||||||
|
import { useIsOwner } from '../../../hooks/common/use-is-owner'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders the sidebar for the editor.
|
* Renders the sidebar for the editor.
|
||||||
|
@ -24,6 +25,7 @@ import { useClickAway } from 'react-use'
|
||||||
export const Sidebar: React.FC = () => {
|
export const Sidebar: React.FC = () => {
|
||||||
const sideBarRef = useRef<HTMLDivElement>(null)
|
const sideBarRef = useRef<HTMLDivElement>(null)
|
||||||
const [selectedMenu, setSelectedMenu] = useState<DocumentSidebarMenuSelection>(DocumentSidebarMenuSelection.NONE)
|
const [selectedMenu, setSelectedMenu] = useState<DocumentSidebarMenuSelection>(DocumentSidebarMenuSelection.NONE)
|
||||||
|
const isOwner = useIsOwner()
|
||||||
|
|
||||||
useClickAway(sideBarRef, () => {
|
useClickAway(sideBarRef, () => {
|
||||||
setSelectedMenu(DocumentSidebarMenuSelection.NONE)
|
setSelectedMenu(DocumentSidebarMenuSelection.NONE)
|
||||||
|
@ -66,8 +68,7 @@ export const Sidebar: React.FC = () => {
|
||||||
onClick={toggleValue}
|
onClick={toggleValue}
|
||||||
/>
|
/>
|
||||||
<ShareNoteSidebarEntry hide={selectionIsNotNone} />
|
<ShareNoteSidebarEntry hide={selectionIsNotNone} />
|
||||||
{/* TODO only show if user has permissions (Owner) (https://github.com/hedgedoc/hedgedoc/issues/5036) */}
|
{isOwner && <DeleteNoteSidebarEntry hide={selectionIsNotNone} />}
|
||||||
<DeleteNoteSidebarEntry hide={selectionIsNotNone} />
|
|
||||||
<PinNoteSidebarEntry hide={selectionIsNotNone} />
|
<PinNoteSidebarEntry hide={selectionIsNotNone} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue