From c88b6b608a7170c3c89b9b2bcdb41b69bcc3ef21 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Tue, 18 Jul 2023 18:31:57 +0100 Subject: [PATCH] Desktop: Enable share permission handling for Joplin Cloud --- .../ShareFolderDialog/ShareFolderDialog.tsx | 16 +++++++----- packages/app-desktop/runForTesting.sh | 26 +++++++------------ 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/packages/app-desktop/gui/ShareFolderDialog/ShareFolderDialog.tsx b/packages/app-desktop/gui/ShareFolderDialog/ShareFolderDialog.tsx index 1020d1041..4e31ec9ef 100644 --- a/packages/app-desktop/gui/ShareFolderDialog/ShareFolderDialog.tsx +++ b/packages/app-desktop/gui/ShareFolderDialog/ShareFolderDialog.tsx @@ -96,6 +96,7 @@ interface Props { onClose(): void; shares: StateShare[]; shareUsers: Record; + isJoplinCloud: boolean; } interface RecipientDeleteEvent { @@ -111,12 +112,12 @@ enum ShareState { function ShareFolderDialog(props: Props) { const permissionOptions: DropdownOptions = { 'can_read': _('Can view'), - 'can_read_and_write': _('Can edit'), + 'can_read_and_write': _('Can view and edit'), }; const [folder, setFolder] = useState(null); const [recipientEmail, setRecipientEmail] = useState(''); - const [recipientPermissions, setRecipientPermissions] = useState('can_read'); + const [recipientPermissions, setRecipientPermissions] = useState('can_read_and_write'); const [latestError, setLatestError] = useState(null); const [share, setShare] = useState(null); const [shareUsers, setShareUsers] = useState([]); @@ -148,8 +149,7 @@ function ShareFolderDialog(props: Props) { useEffect(() => { const s = props.shares.find(s => s.folder_id === props.folderId); setShare(s); - // eslint-disable-next-line @seiyab/react-hooks/exhaustive-deps -- Old code before rule was applied - }, [props.shares]); + }, [props.shares, props.folderId]); useEffect(() => { if (!share) return; @@ -261,12 +261,14 @@ function ShareFolderDialog(props: Props) { function renderAddRecipient() { const disabled = shareState !== ShareState.Idle; + const dropdown = !props.isJoplinCloud ? null : ; + return ( {_('Add recipient:')} - + {dropdown} @@ -304,11 +306,12 @@ function ShareFolderDialog(props: Props) { const permission = shareUser.can_write ? 'can_read_and_write' : 'can_read'; const enabled = !recipientsBeingUpdated[shareUser.id]; + const dropdown = !props.isJoplinCloud ? null : recipient_permissionChange(shareUser.id, event.value)}/>; return ( {shareUser.user.email} - recipient_permissionChange(shareUser.id, event.value)}/> + {dropdown}