Fix for attachment table (#8021)

- Allow bulk deletion of attachments from PUI
This commit is contained in:
Oliver 2024-08-28 15:42:15 +10:00 committed by GitHub
parent 93e06a0db5
commit c096f2f43a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -107,6 +107,11 @@ export function AttachmentTable({
const validPk = useMemo(() => model_id > 0, [model_id]); const validPk = useMemo(() => model_id > 0, [model_id]);
const canDelete = useMemo(
() => user.hasDeletePermission(model_type),
[user, model_type]
);
const [isUploading, setIsUploading] = useState<boolean>(false); const [isUploading, setIsUploading] = useState<boolean>(false);
const allowDragAndDrop: boolean = useMemo(() => { const allowDragAndDrop: boolean = useMemo(() => {
@ -272,7 +277,7 @@ export function AttachmentTable({
} }
}), }),
RowDeleteAction({ RowDeleteAction({
hidden: !user.hasDeletePermission(model_type), hidden: !canDelete,
onClick: () => { onClick: () => {
setSelectedAttachment(record.pk); setSelectedAttachment(record.pk);
deleteAttachment.open(); deleteAttachment.open();
@ -297,7 +302,8 @@ export function AttachmentTable({
columns={tableColumns} columns={tableColumns}
props={{ props={{
noRecordsText: t`No attachments found`, noRecordsText: t`No attachments found`,
enableSelection: true, enableSelection: canDelete,
enableBulkDelete: canDelete,
tableActions: tableActions, tableActions: tableActions,
tableFilters: tableFilters, tableFilters: tableFilters,
rowActions: rowActions, rowActions: rowActions,