-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: abort task route, improvements on UI and more
- Loading branch information
Ivo
committed
Apr 26, 2023
1 parent
a9cda03
commit 1165112
Showing
15 changed files
with
194 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
apps/client/src/components/DynamicRunningAbortButton/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { Slash } from "lucide-react"; | ||
import { useRouter } from "next/router"; | ||
import { useTranslation } from "next-i18next"; | ||
|
||
import { Button } from "@app/components/Button"; | ||
import { api } from "@app/lib/api"; | ||
|
||
interface DynamicRunningAbortButtonProps { | ||
celeryId: string; | ||
disableAbortButton?: boolean; | ||
folder: string; | ||
refetch: () => void; | ||
} | ||
|
||
export function DynamicRunningAbortButton({ | ||
celeryId, | ||
disableAbortButton, | ||
folder, | ||
refetch | ||
}: DynamicRunningAbortButtonProps) { | ||
const { t } = useTranslation(["common"]); | ||
const router = useRouter(); | ||
|
||
async function abortTask() { | ||
const formData = new FormData(); | ||
|
||
formData.append("taskId", celeryId); | ||
formData.append("folder", folder); | ||
api | ||
.post("/run/abort", formData, { | ||
headers: { | ||
"Content-Type": "multipart/form-data" | ||
} | ||
}) | ||
.then(() => { | ||
if (refetch) { | ||
refetch(); | ||
} else { | ||
router.push("/my-dynamics"); | ||
} | ||
}); | ||
} | ||
|
||
return ( | ||
<Button | ||
className="w-fit bg-red-700 enabled:hover:bg-red-800" | ||
LeftIcon={Slash} | ||
disabled={disableAbortButton} | ||
onClick={abortTask} | ||
> | ||
{t("common:abort")} | ||
</Button> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.