From 38eaff12ce1a70ab530436c9090fb10be1878dc2 Mon Sep 17 00:00:00 2001 From: hinashi Date: Tue, 10 Dec 2024 16:56:58 +0900 Subject: [PATCH 1/3] Fixed not being able to cancel a job from the Job menu --- frontend/src/components/job/JobList.tsx | 12 ++++++++++-- package-lock.json | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/job/JobList.tsx b/frontend/src/components/job/JobList.tsx index 39f69b3ec..2581415b9 100644 --- a/frontend/src/components/job/JobList.tsx +++ b/frontend/src/components/job/JobList.tsx @@ -12,6 +12,7 @@ import { Typography, } from "@mui/material"; import { styled } from "@mui/material/styles"; +import { useSnackbar } from "notistack"; import React, { FC, useState } from "react"; import { Link, useNavigate } from "react-router-dom"; @@ -108,6 +109,7 @@ interface Props { export const JobList: FC = ({ jobs }) => { const navigate = useNavigate(); + const { enqueueSnackbar } = useSnackbar(); const [encodes, setEncodes] = useState<{ [key: number]: string; @@ -119,8 +121,14 @@ export const JobList: FC = ({ jobs }) => { }; const handleCancel = async (jobId: number) => { - await aironeApiClient.cancelJob(jobId); - navigate(0); + await aironeApiClient + .cancelJob(jobId) + .then(() => { + navigate(0); + }) + .catch((resp) => { + enqueueSnackbar("キャンセルに失敗しました。", { variant: "error" }); + }); }; return ( diff --git a/package-lock.json b/package-lock.json index 2dbcecb57..b320d590a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "@syucream/pagoda-core", + "name": "@dmm-com/pagoda-core", "version": "1.0.1", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "@syucream/pagoda-core", + "name": "@dmm-com/pagoda-core", "version": "1.0.1", "license": "GPLv2", "devDependencies": { From 2091272923a6041ff1da2d7133b4ac1ee784f376 Mon Sep 17 00:00:00 2001 From: hinashi Date: Tue, 10 Dec 2024 17:10:02 +0900 Subject: [PATCH 2/3] Fixed lint error --- frontend/src/components/job/JobList.tsx | 71 ++++++++++++------------- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/frontend/src/components/job/JobList.tsx b/frontend/src/components/job/JobList.tsx index 2581415b9..667bbf7fb 100644 --- a/frontend/src/components/job/JobList.tsx +++ b/frontend/src/components/job/JobList.tsx @@ -25,7 +25,7 @@ import { AironeTableHeadCell } from "../common/AironeTableHeadCell"; import { AironeTableHeadRow } from "../common/AironeTableHeadRow"; import { Confirmable } from "../common/Confirmable"; -const StyledTableRow = styled(TableRow)(({}) => ({ +const StyledTableRow = styled(TableRow)(({ }) => ({ "&:nth-of-type(odd)": { backgroundColor: "white", }, @@ -34,7 +34,7 @@ const StyledTableRow = styled(TableRow)(({}) => ({ }, })); -const PreparingIcon = styled(Box)(({}) => ({ +const PreparingIcon = styled(Box)(({ }) => ({ width: "13px", height: "13px", margin: "0 4px", @@ -44,7 +44,7 @@ const PreparingIcon = styled(Box)(({}) => ({ borderRadius: "8px", })); -const DoneIcon = styled(Box)(({}) => ({ +const DoneIcon = styled(Box)(({ }) => ({ width: "16px", height: "16px", margin: "0 4px", @@ -52,7 +52,7 @@ const DoneIcon = styled(Box)(({}) => ({ borderRadius: "8px", })); -const ErrorIcon = styled(Box)(({}) => ({ +const ErrorIcon = styled(Box)(({ }) => ({ width: "16px", height: "16px", margin: "0 4px", @@ -60,7 +60,7 @@ const ErrorIcon = styled(Box)(({}) => ({ borderRadius: "8px", })); -const TimeoutIcon = styled(Box)(({}) => ({ +const TimeoutIcon = styled(Box)(({ }) => ({ width: "16px", height: "16px", margin: "0 4px", @@ -68,7 +68,7 @@ const TimeoutIcon = styled(Box)(({}) => ({ borderRadius: "8px", })); -const CancelledIcon = styled(Box)(({}) => ({ +const CancelledIcon = styled(Box)(({ }) => ({ width: "16px", height: "16px", margin: "0 4px", @@ -76,7 +76,7 @@ const CancelledIcon = styled(Box)(({}) => ({ borderRadius: "8px", })); -const UnknownIcon = styled(Box)(({}) => ({ +const UnknownIcon = styled(Box)(({ }) => ({ width: "16px", height: "16px", margin: "0 4px", @@ -126,7 +126,7 @@ export const JobList: FC = ({ jobs }) => { .then(() => { navigate(0); }) - .catch((resp) => { + .catch(() => { enqueueSnackbar("キャンセルに失敗しました。", { variant: "error" }); }); }; @@ -214,35 +214,35 @@ export const JobList: FC = ({ jobs }) => { JobStatuses.PROCESSING, JobStatuses.CANCELED, ].includes(job.status ?? 0) && ( - - )} + + )} {![ JobStatuses.DONE, JobStatuses.ERROR, JobStatuses.CANCELED, ].includes(job.status ?? 0) && ( - ( - - )} - dialogTitle="本当にキャンセルしますか?" - onClickYes={() => handleCancel(job.id)} - /> - )} + ( + + )} + dialogTitle="本当にキャンセルしますか?" + onClickYes={() => handleCancel(job.id)} + /> + )} @@ -260,7 +260,7 @@ export const JobList: FC = ({ jobs }) => { job.operation == JobOperations.EXPORT_SEARCH_RESULT || job.operation == JobOperations.EXPORT_ENTRY_V2 || job.operation == JobOperations.EXPORT_SEARCH_RESULT_V2) && - job.status == JobStatuses.DONE ? ( + job.status == JobStatuses.DONE ? ( - )} + + )} {![ JobStatuses.DONE, JobStatuses.ERROR, JobStatuses.CANCELED, ].includes(job.status ?? 0) && ( - ( - - )} - dialogTitle="本当にキャンセルしますか?" - onClickYes={() => handleCancel(job.id)} - /> - )} + ( + + )} + dialogTitle="本当にキャンセルしますか?" + onClickYes={() => handleCancel(job.id)} + /> + )} @@ -260,7 +260,7 @@ export const JobList: FC = ({ jobs }) => { job.operation == JobOperations.EXPORT_SEARCH_RESULT || job.operation == JobOperations.EXPORT_ENTRY_V2 || job.operation == JobOperations.EXPORT_SEARCH_RESULT_V2) && - job.status == JobStatuses.DONE ? ( + job.status == JobStatuses.DONE ? (