From 1ab7bf9c1b619a9294c83e7da46ae626094c3c01 Mon Sep 17 00:00:00 2001 From: Takeshi Kimata <117462761+kimatata@users.noreply.github.com> Date: Sat, 7 Sep 2024 18:19:47 +0900 Subject: [PATCH] chore: show toast message when update test run/case (#25) --- frontend/messages/en.json | 2 ++ frontend/messages/ja.json | 2 ++ .../[folderId]/cases/[caseId]/CaseEditor.tsx | 24 ++++++++++------- .../[folderId]/cases/[caseId]/page.tsx | 1 + .../[projectId]/runs/[runId]/RunEditor.tsx | 26 +++++++++++-------- .../[projectId]/runs/[runId]/page.tsx | 1 + frontend/types/case.ts | 1 + frontend/types/run.ts | 1 + frontend/types/toast.ts | 2 +- frontend/utils/ToastProvider.tsx | 6 ++--- 10 files changed, 41 insertions(+), 25 deletions(-) diff --git a/frontend/messages/en.json b/frontend/messages/en.json index 2fdf064..835b9ab 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -189,6 +189,7 @@ "back_to_cases": "Back to test cases", "updating": "Updating...", "update": "Update", + "updated_test_case": "Updated test case", "basic": "Basic", "title": "Title", "please_enter_title": "Please enter title", @@ -241,6 +242,7 @@ "back_to_runs": "Back to test runs", "updating": "Updating...", "update": "Update", + "updated_test_run": "Updated test run", "progress": "Progress", "refresh": "Refresh", "id": "ID", diff --git a/frontend/messages/ja.json b/frontend/messages/ja.json index bb35092..1d5a300 100644 --- a/frontend/messages/ja.json +++ b/frontend/messages/ja.json @@ -190,6 +190,7 @@ "back_to_cases": "テストケース一覧に戻る", "updating": "更新中...", "update": "更新", + "updated_test_case": "テストケースを更新しました", "basic": "基本データ", "title": "タイトル", "please_enter_title": "タイトルを入力してください", @@ -242,6 +243,7 @@ "back_to_runs": "テストラン一覧に戻る", "updating": "更新中...", "update": "更新", + "updated_test_run": "テストランを更新しました", "progress": "進捗", "refresh": "再読み込み", "id": "ID", diff --git a/frontend/src/app/[locale]/projects/[projectId]/folders/[folderId]/cases/[caseId]/CaseEditor.tsx b/frontend/src/app/[locale]/projects/[projectId]/folders/[folderId]/cases/[caseId]/CaseEditor.tsx index 174a0bf..0d92cc5 100644 --- a/frontend/src/app/[locale]/projects/[projectId]/folders/[folderId]/cases/[caseId]/CaseEditor.tsx +++ b/frontend/src/app/[locale]/projects/[projectId]/folders/[folderId]/cases/[caseId]/CaseEditor.tsx @@ -10,6 +10,7 @@ import { fetchCase, updateCase } from '@/utils/caseControl'; import { updateSteps } from './stepControl'; import { fetchCreateAttachments, fetchDownloadAttachment, fetchDeleteAttachment } from './attachmentControl'; import { TokenContext } from '@/utils/TokenProvider'; +import { ToastContext } from '@/utils/ToastProvider'; import { useFormGuard } from '@/utils/formGuard'; import { CaseType, AttachmentType, CaseMessages, StepType } from '@/types/case'; import { PriorityMessages } from '@/types/priority'; @@ -52,7 +53,8 @@ export default function CaseEditor({ priorityMessages, locale, }: Props) { - const context = useContext(TokenContext); + const toakenContext = useContext(TokenContext); + const toastContext = useContext(ToastContext); const [testCase, setTestCase] = useState(defaultTestCase); const [isTitleInvalid, setIsTitleInvalid] = useState(false); const [isUpdating, setIsUpdating] = useState(false); @@ -192,11 +194,11 @@ export default function CaseEditor({ useEffect(() => { async function fetchDataEffect() { - if (!context.isSignedIn()) { + if (!toakenContext.isSignedIn()) { return; } try { - const data = await fetchCase(context.token.access_token, Number(caseId)); + const data = await fetchCase(toakenContext.token.access_token, Number(caseId)); data.Steps.forEach((step: StepType) => { step.editState = 'notChanged'; }); @@ -207,7 +209,7 @@ export default function CaseEditor({ } fetchDataEffect(); - }, [context]); + }, [toakenContext]); return ( <> @@ -230,15 +232,17 @@ export default function CaseEditor({