Fix permission checks for bulk delete actions (#7796)

This commit is contained in:
Oliver 2024-08-03 16:13:28 +10:00 committed by GitHub
parent 6fd5a9941b
commit 85fc709fc7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 11 additions and 5 deletions

View File

@ -554,7 +554,7 @@ export function BomTable({
modelField: 'sub_part',
rowActions: rowActions,
enableSelection: !partLocked,
enableBulkDelete: !partLocked,
enableBulkDelete: !partLocked && user.hasDeleteRole(UserRoles.part),
enableDownload: true
}}
/>

View File

@ -154,7 +154,7 @@ export default function BuildAllocatedStockTable({
stock_detail: true,
supplier_detail: true
},
enableBulkDelete: true,
enableBulkDelete: user.hasDeleteRole(UserRoles.build),
enableDownload: true,
enableSelection: true,
rowActions: rowActions,

View File

@ -8,6 +8,7 @@ import { ApiEndpoints } from '../../enums/ApiEndpoints';
import { useDeleteApiFormModal } from '../../hooks/UseForm';
import { useTable } from '../../hooks/UseTable';
import { apiUrl } from '../../states/ApiState';
import { useUserState } from '../../states/UserState';
import { TableColumn } from '../Column';
import { InvenTreeTable } from '../InvenTreeTable';
import { RowAction, RowDeleteAction } from '../RowActions';
@ -17,6 +18,7 @@ import { RowAction, RowDeleteAction } from '../RowActions';
*/
export default function ErrorReportTable() {
const table = useTable('error-report');
const user = useUserState();
const [error, setError] = useState<string>('');
@ -90,7 +92,7 @@ export default function ErrorReportTable() {
tableState={table}
columns={columns}
props={{
enableBulkDelete: true,
enableBulkDelete: user.isStaff(),
enableSelection: true,
rowActions: rowActions,
onRowClick: (row) => {

View File

@ -7,11 +7,13 @@ import { StylishText } from '../../components/items/StylishText';
import { ApiEndpoints } from '../../enums/ApiEndpoints';
import { useTable } from '../../hooks/UseTable';
import { apiUrl } from '../../states/ApiState';
import { useUserState } from '../../states/UserState';
import { TableColumn } from '../Column';
import { InvenTreeTable } from '../InvenTreeTable';
export default function FailedTasksTable() {
const table = useTable('tasks-failed');
const user = useUserState();
const [error, setError] = useState<string>('');
@ -70,7 +72,7 @@ export default function FailedTasksTable() {
tableState={table}
columns={columns}
props={{
enableBulkDelete: true,
enableBulkDelete: user.isStaff(),
enableSelection: true,
onRowClick: (row: any) => {
setError(row.result);

View File

@ -4,11 +4,13 @@ import { useMemo } from 'react';
import { ApiEndpoints } from '../../enums/ApiEndpoints';
import { useTable } from '../../hooks/UseTable';
import { apiUrl } from '../../states/ApiState';
import { useUserState } from '../../states/UserState';
import { TableColumn } from '../Column';
import { InvenTreeTable } from '../InvenTreeTable';
export default function PendingTasksTable() {
const table = useTable('tasks-pending');
const user = useUserState();
const columns: TableColumn[] = useMemo(() => {
return [
@ -48,7 +50,7 @@ export default function PendingTasksTable() {
tableState={table}
columns={columns}
props={{
enableBulkDelete: true,
enableBulkDelete: user.isStaff(),
enableSelection: true
}}
/>