diff --git a/client/src/app/pages/applications/applications-table/applications-table.tsx b/client/src/app/pages/applications/applications-table/applications-table.tsx index d102d69a2a..747b91b225 100644 --- a/client/src/app/pages/applications/applications-table/applications-table.tsx +++ b/client/src/app/pages/applications/applications-table/applications-table.tsx @@ -116,7 +116,6 @@ export const ApplicationsTable: React.FC = () => { const history = useHistory(); const token = keycloak.tokenParsed; - // ----- State for the modals const [saveApplicationModalState, setSaveApplicationModalState] = useState< "create" | DecoratedApplication | null @@ -156,7 +155,9 @@ export const ApplicationsTable: React.FC = () => { const [applicationsToDelete, setApplicationsToDelete] = useState< DecoratedApplication[] >([]); - + const [applicationsToCancel, setApplicationsToCancel] = useState< + DecoratedApplication[] + >([]); const [assessmentToDiscard, setAssessmentToDiscard] = useState(null); @@ -272,7 +273,6 @@ export const ApplicationsTable: React.FC = () => { }); } ); - const discardReview = async (application: DecoratedApplication) => { if (application.review) { deleteReview({ @@ -297,7 +297,6 @@ export const ApplicationsTable: React.FC = () => { }); } ); - const discardAssessment = async (application: DecoratedApplication) => { if (application.assessments) { application.assessments.forEach((assessment) => { @@ -575,6 +574,23 @@ export const ApplicationsTable: React.FC = () => { > {t("actions.delete")} , + ...(tasksReadAccess && + tasksWriteAccess && + selectedRows.some((application: DecoratedApplication) => + isTaskCancellable(application) + ) + ? [ + { + handleCancelBulkAnalysis(); + }} + > + {t("actions.cancelAnalysis")} + , + ] + : []), ...(credentialsReadAccess ? [ { }) ); }; + const handleCancelBulkAnalysis = () => { + const runningAppsToCancel = selectedRows.filter((application) => + isTaskCancellable(application) + ); + setApplicationsToCancel(runningAppsToCancel); + runningAppsToCancel.forEach((application) => { + cancelAnalysis(application); + }); + }; const assessSelectedApp = async (application: DecoratedApplication) => { setApplicationToAssess(application);