From 2a6dfdea5d5028ac46491caef79e98795b72cbd3 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sat, 10 Apr 2021 13:54:05 -0700 Subject: [PATCH] fix: Highlight states and dropzones when user does not have permission to import --- app/components/Sidebar/components/DropToImport.js | 6 ++++-- app/scenes/Collection.js | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/components/Sidebar/components/DropToImport.js b/app/components/Sidebar/components/DropToImport.js index 0521abdfa..a63342cca 100644 --- a/app/components/Sidebar/components/DropToImport.js +++ b/app/components/Sidebar/components/DropToImport.js @@ -18,12 +18,14 @@ type Props = {| function DropToImport({ disabled, children, collectionId, documentId }: Props) { const { t } = useTranslation(); - const { ui, documents } = useStores(); + const { ui, documents, policies } = useStores(); const { handleFiles, isImporting } = useImportDocument( collectionId, documentId ); + const can = policies.abilities(collectionId); + const handleRejection = React.useCallback(() => { ui.showToast( t("Document not supported – try Markdown, Plain text, HTML, or Word"), @@ -31,7 +33,7 @@ function DropToImport({ disabled, children, collectionId, documentId }: Props) { ); }, [t, ui]); - if (disabled) { + if (disabled || !can.update) { return children; } diff --git a/app/scenes/Collection.js b/app/scenes/Collection.js index 850346449..e497f28d1 100644 --- a/app/scenes/Collection.js +++ b/app/scenes/Collection.js @@ -170,6 +170,7 @@ function CollectionScene() { accept={documents.importFileTypes.join(", ")} onDropAccepted={handleFiles} onDropRejected={handleRejection} + disabled={!can.update} noClick multiple >