From b636565c62502b91865d92abef0570b1b2654089 Mon Sep 17 00:00:00 2001 From: Deluan Date: Mon, 8 Jun 2020 19:19:38 -0400 Subject: [PATCH] Disable public toggle if user is not the playlist's owner --- ui/src/playlist/PlaylistList.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/ui/src/playlist/PlaylistList.js b/ui/src/playlist/PlaylistList.js index 9929af07..4e06e61e 100644 --- a/ui/src/playlist/PlaylistList.js +++ b/ui/src/playlist/PlaylistList.js @@ -20,7 +20,7 @@ const PlaylistFilter = (props) => ( ) -const TogglePublicInput = ({ resource, record, source }) => { +const TogglePublicInput = ({ permissions, resource, record, source }) => { const notify = useNotify() const [togglePublic] = useUpdate( resource, @@ -43,10 +43,20 @@ const TogglePublicInput = ({ resource, record, source }) => { e.stopPropagation() } - return + const canChange = + permissions === 'admin' || + localStorage.getItem('username') === record['owner'] + + return ( + + ) } -const PlaylistList = (props) => ( +const PlaylistList = ({ permissions, ...props }) => ( }> isWritable(r && r.owner)}> @@ -54,7 +64,7 @@ const PlaylistList = (props) => ( - +