Skip to content

Commit

Permalink
👻 Add check for scheduled when checking if analysis button enabled
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Bolton <[email protected]>
  • Loading branch information
ibolton336 committed Jun 20, 2024
1 parent cf87201 commit c9209ef
Showing 1 changed file with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,7 @@ export const ApplicationsTable: React.FC = () => {

const isTaskCancellable = (application: Application) => {
const task = getTask(application);
if (task?.state && task.state.match(/(Created|Running|Ready|Pending)/))
return true;
return false;
return task?.state && !["Succeeded", "Failed"].includes(task.state);
};

const cancelAnalysis = (row: Application) => {
Expand Down Expand Up @@ -610,18 +608,23 @@ export const ApplicationsTable: React.FC = () => {

const dropdownItems = [...importDropdownItems, ...applicationDropdownItems];

const isAnalyzingAllowed = () => {
const candidateTasks = selectedRows.filter(
(app) =>
!tasks.some(
(task) =>
task.application?.id === app.id &&
task.state?.match(/(Created|Running|Ready|Pending)/)
)
);

if (candidateTasks.length === selectedRows.length) return true;
return false;
const isAnalyzingDisabled = () => {
if (tasks.length === 0) {
return false;
}

const allowedStates = ["Succeeded", "Failed", null, ""];

const candidateTasks = selectedRows.filter((app) => {
const hasAllowedState = tasks.some(
(task) =>
task.application?.id === app.id &&
allowedStates.includes(task.state || "")
);
return !hasAllowedState;
});

return candidateTasks.length > 0;
};

const hasExistingAnalysis = selectedRows.some((app) =>
Expand Down Expand Up @@ -783,7 +786,7 @@ export const ApplicationsTable: React.FC = () => {
setAnalyzeModalOpen(true);
}}
isDisabled={
selectedRows.length < 1 || !isAnalyzingAllowed()
selectedRows.length < 1 || isAnalyzingDisabled()
}
>
{t("actions.analyze")}
Expand Down

0 comments on commit c9209ef

Please sign in to comment.