fix: Highlight states and dropzones when user does not have permission to import
This commit is contained in:
parent
de25ea0ed9
commit
2a6dfdea5d
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -170,6 +170,7 @@ function CollectionScene() {
|
|||
accept={documents.importFileTypes.join(", ")}
|
||||
onDropAccepted={handleFiles}
|
||||
onDropRejected={handleRejection}
|
||||
disabled={!can.update}
|
||||
noClick
|
||||
multiple
|
||||
>
|
||||
|
|
Reference in New Issue