From b0c2168463ca7cc31226f3f329b8eefd5ad09b41 Mon Sep 17 00:00:00 2001 From: Takeshi Kimata <117462761+kimatata@users.noreply.github.com> Date: Sun, 7 Apr 2024 19:03:43 +0900 Subject: [PATCH] create runs list page --- .../projects/[projectId]/runs/RunDialog.tsx | 140 ++++++++++++++++ .../projects/[projectId]/runs/RunsPage.tsx | 112 +++++++++++++ .../projects/[projectId]/runs/RunsTable.tsx | 158 ++++++++++++++++++ .../app/projects/[projectId]/runs/page.tsx | 10 +- .../projects/[projectId]/runs/runsControl.ts | 105 ++++++++++++ frontend/types/run.ts | 10 ++ 6 files changed, 533 insertions(+), 2 deletions(-) create mode 100644 frontend/app/projects/[projectId]/runs/RunDialog.tsx create mode 100644 frontend/app/projects/[projectId]/runs/RunsPage.tsx create mode 100644 frontend/app/projects/[projectId]/runs/RunsTable.tsx create mode 100644 frontend/app/projects/[projectId]/runs/runsControl.ts create mode 100644 frontend/types/run.ts diff --git a/frontend/app/projects/[projectId]/runs/RunDialog.tsx b/frontend/app/projects/[projectId]/runs/RunDialog.tsx new file mode 100644 index 0000000..ff48d58 --- /dev/null +++ b/frontend/app/projects/[projectId]/runs/RunDialog.tsx @@ -0,0 +1,140 @@ +"use client"; +import React from "react"; +import { useState, useEffect } from "react"; +import { + Button, + Input, + Textarea, + Modal, + ModalContent, + ModalHeader, + ModalBody, + ModalFooter, +} from "@nextui-org/react"; +import { RunType } from "@/types/run"; + +type Props = { + isOpen: boolean; + editingRun: RunType; + onCancel: () => void; + onSubmit: (name: string, detail: string) => void; +}; + +export default function RunDialog({ + isOpen, + editingRun, + onCancel, + onSubmit, +}: Props) { + const [runName, setRunName] = useState({ + text: editingRun ? editingRun.name : "", + isValid: false, + errorMessage: "", + }); + + const [runDetail, setRunDetail] = useState({ + text: editingRun ? editingRun.detail : "", + isValid: false, + errorMessage: "", + }); + + useEffect(() => { + if (editingRun) { + setRunName({ + ...runName, + text: editingRun.name, + }); + + setRunDetail({ + ...runDetail, + text: editingRun.detail ? editingRun.detail : "", + }); + } else { + setRunName({ + ...runName, + text: "", + }); + + setRunDetail({ + ...runDetail, + text: "", + }); + } + }, [editingRun]); + + const clear = () => { + setRunName({ + isValid: false, + text: "", + errorMessage: "", + }); + setRunDetail({ + isValid: false, + text: "", + errorMessage: "", + }); + }; + + const validate = () => { + if (!runName.text) { + setRunName({ + text: "", + isValid: false, + errorMessage: "Please enter run name", + }); + + return; + } + + onSubmit(runName.text, runDetail.text); + clear(); + }; + + return ( + { + onCancel(); + }} + > + + Run + + { + setRunName({ + ...runName, + text: e.target.value, + }); + }} + /> +