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