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 767d5090e..8fca6d079 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 @@ -274,6 +273,16 @@ export const ApplicationsTable: React.FC = () => { }); } ); + const RunningAnalysis = () => { + const runningAnalysisApp: DecoratedApplication[] = []; + selectedRows.forEach((app) => { + if (isTaskCancellable(app)) { + runningAnalysisApp.push(app); + } + }); + setApplicationsToCancel(runningAnalysisApp); + return applicationsToCancel.length > 0; + }; const discardReview = async (application: DecoratedApplication) => { if (application.review) { @@ -299,7 +308,6 @@ export const ApplicationsTable: React.FC = () => { }); } ); - const discardAssessment = async (application: DecoratedApplication) => { if (application.assessments) { application.assessments.forEach((assessment) => { @@ -577,15 +585,13 @@ export const ApplicationsTable: React.FC = () => { > {t("actions.delete")} , - ...(tasksReadAccess && - tasksWriteAccess && - selectedRows.every((application) => isTaskCancellable(application)) + ...(tasksReadAccess && tasksWriteAccess && RunningAnalysis() ? [ { - handleCancelBulkAnalysis(selectedRows); + handleCancelBulkAnalysis(); }} > {t("actions.cancelAnalysis")} @@ -655,14 +661,12 @@ export const ApplicationsTable: React.FC = () => { }) ); }; - const handleCancelBulkAnalysis = async ( - selectedRows: DecoratedApplication[] - ) => { - setApplicationsToCancel(selectedRows); - selectedRows.map((application) => { + const handleCancelBulkAnalysis = () => { + applicationsToCancel.map((application) => { cancelAnalysis(application); }); }; + const assessSelectedApp = async (application: DecoratedApplication) => { setApplicationToAssess(application);