Skip to content

Commit

Permalink
Update feature to cancel multiple analyses at once
Browse files Browse the repository at this point in the history
Signed-off-by: MiriSafra <[email protected]>
  • Loading branch information
MiriSafra committed Sep 18, 2024
1 parent 09d2827 commit d8c2bb5
Showing 1 changed file with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -299,7 +308,6 @@ export const ApplicationsTable: React.FC = () => {
});
}
);

const discardAssessment = async (application: DecoratedApplication) => {
if (application.assessments) {
application.assessments.forEach((assessment) => {
Expand Down Expand Up @@ -577,15 +585,13 @@ export const ApplicationsTable: React.FC = () => {
>
{t("actions.delete")}
</DropdownItem>,
...(tasksReadAccess &&
tasksWriteAccess &&
selectedRows.every((application) => isTaskCancellable(application))
...(tasksReadAccess && tasksWriteAccess && RunningAnalysis()
? [
<DropdownItem
key="applications-bulk-cancel"
isDisabled={selectedRows.length < 1}
onClick={() => {
handleCancelBulkAnalysis(selectedRows);
handleCancelBulkAnalysis();
}}
>
{t("actions.cancelAnalysis")}
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit d8c2bb5

Please sign in to comment.