Skip to content

Commit

Permalink
fix: compute logic (#438)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sinrefvol authored Feb 4, 2025
1 parent f606818 commit 7932750
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,11 @@ export const CaseButtons = ({
const duplicateTooltip = () => {
if (!isOwnerOrAdmin)
return 'Can not duplicate because you are not owner or admin.';
return 'Can not duplicate unsaved case.';
};

return (
<Styled.ButtonDiv>
{id.length < 3 || !isOwnerOrAdmin ? (
{!isOwnerOrAdmin ? (
<Tooltip title={deleteTooltip()}>
<Button disabled variant="ghost_icon" aria-label="remove">
<Icon data={DELETE} size={24}></Icon>
Expand All @@ -83,7 +82,9 @@ export const CaseButtons = ({
) : (
<Button
variant="ghost_icon"
onClick={() => setDeleteConfirm(true)}
onClick={() =>
id.length < 3 ? handleConfirmDelete() : setDeleteConfirm(true)
}
aria-label="remove"
>
<Icon data={DELETE} size={24}></Icon>
Expand Down Expand Up @@ -148,6 +149,7 @@ export const CaseButtons = ({
>
<Button
color={
caseStatus === 'Created' ||
caseStatus === 'Failed' ||
caseStatus === 'Waiting' ||
caseStatus === 'Running'
Expand Down Expand Up @@ -203,7 +205,14 @@ export const CaseButtons = ({
</Styled.Button>
) : (
<Styled.Button
color={caseStatus === 'Failed' ? 'danger' : undefined}
color={
caseStatus === 'Created' ||
caseStatus === 'Failed' ||
caseStatus === 'Waiting' ||
caseStatus === 'Running'
? 'danger'
: undefined
}
variant="outlined"
onClick={runCase}
disabled={
Expand All @@ -225,7 +234,12 @@ export const CaseButtons = ({
)}
</Tooltip>
<Button
disabled={!isOwnerOrAdmin}
disabled={
!isOwnerOrAdmin ||
caseStatus === 'Created' ||
caseStatus === 'Waiting' ||
caseStatus === 'Running'
}
variant="outlined"
onClick={id.length > 3 ? () => setSaveConfirm(true) : saveCase}
>
Expand Down
15 changes: 10 additions & 5 deletions src/features/Compute/Components/CaseGroup/CaseGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,16 @@ export const CaseGroup = ({

const deleteCase = async (computeCaseId: string) => {
if (modelId) {
const res = await deleteApiCase.mutateAsync({
id: modelId,
computeCaseId: computeCaseId,
});
return res;
const localCase = caseList.find((c) => c.computeCaseId === computeCaseId);
if (!localCase) {
removeLocalCase(computeCaseId);
} else {
const res = await deleteApiCase.mutateAsync({
id: modelId,
computeCaseId: computeCaseId,
});
return res;
}
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ export const CaseRow = ({
};

const runRowCase = () => {
if (id && rowCase.jobStatus === ComputeJobStatus.RUNNING)
if (
(id && rowCase.jobStatus === ComputeJobStatus.RUNNING) ||
rowCase.jobStatus === ComputeJobStatus.WAITING
)
return runCancelJob(id);
if (id) return runCase(id);
};
Expand Down

0 comments on commit 7932750

Please sign in to comment.