fix: Highlight states and dropzones when user does not have permission to import
This commit is contained in:
@@ -18,12 +18,14 @@ type Props = {|
|
|||||||
|
|
||||||
function DropToImport({ disabled, children, collectionId, documentId }: Props) {
|
function DropToImport({ disabled, children, collectionId, documentId }: Props) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { ui, documents } = useStores();
|
const { ui, documents, policies } = useStores();
|
||||||
const { handleFiles, isImporting } = useImportDocument(
|
const { handleFiles, isImporting } = useImportDocument(
|
||||||
collectionId,
|
collectionId,
|
||||||
documentId
|
documentId
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const can = policies.abilities(collectionId);
|
||||||
|
|
||||||
const handleRejection = React.useCallback(() => {
|
const handleRejection = React.useCallback(() => {
|
||||||
ui.showToast(
|
ui.showToast(
|
||||||
t("Document not supported – try Markdown, Plain text, HTML, or Word"),
|
t("Document not supported – try Markdown, Plain text, HTML, or Word"),
|
||||||
@@ -31,7 +33,7 @@ function DropToImport({ disabled, children, collectionId, documentId }: Props) {
|
|||||||
);
|
);
|
||||||
}, [t, ui]);
|
}, [t, ui]);
|
||||||
|
|
||||||
if (disabled) {
|
if (disabled || !can.update) {
|
||||||
return children;
|
return children;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -170,6 +170,7 @@ function CollectionScene() {
|
|||||||
accept={documents.importFileTypes.join(", ")}
|
accept={documents.importFileTypes.join(", ")}
|
||||||
onDropAccepted={handleFiles}
|
onDropAccepted={handleFiles}
|
||||||
onDropRejected={handleRejection}
|
onDropRejected={handleRejection}
|
||||||
|
disabled={!can.update}
|
||||||
noClick
|
noClick
|
||||||
multiple
|
multiple
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user