diff --git a/backend/index.js b/backend/index.js index 2e05077..9c15d3e 100644 --- a/backend/index.js +++ b/backend/index.js @@ -79,8 +79,10 @@ app.use("/attachments", attachmentsDownloadRoute); // "/runs" const runsIndexRoute = require("./routes/runs/index")(sequelize); +const runsShowRoute = require("./routes/cases/show")(sequelize); const runsNewRoute = require("./routes/runs/new")(sequelize); app.use("/runs", runsIndexRoute); +app.use("/runs", runsShowRoute); app.use("/runs", runsNewRoute); const PORT = process.env.PORT || 3001; diff --git a/backend/routes/runs/show.js b/backend/routes/runs/show.js new file mode 100644 index 0000000..f23cfda --- /dev/null +++ b/backend/routes/runs/show.js @@ -0,0 +1,29 @@ +const express = require("express"); +const router = express.Router(); +const defineRun = require("../../models/runs"); +const { DataTypes } = require("sequelize"); + +module.exports = function (sequelize) { + const Run = defineRun(sequelize, DataTypes); + + router.get("/:runId", async (req, res) => { + const runId = req.params.runId; + + if (!runId) { + return res.status(400).json({ error: "runId is required" }); + } + + try { + const project = await Run.findByPk(runId); + if (!project) { + return res.status(404).send("Run not found"); + } + res.json(project); + } catch (error) { + console.error(error); + res.status(500).send("Internal Server Error"); + } + }); + + return router; +}; diff --git a/frontend/app/projects/[projectId]/folders/[folderId]/cases/[caseId]/caseControl.ts b/frontend/app/projects/[projectId]/folders/[folderId]/cases/[caseId]/caseControl.ts index 2be6553..378492f 100644 --- a/frontend/app/projects/[projectId]/folders/[folderId]/cases/[caseId]/caseControl.ts +++ b/frontend/app/projects/[projectId]/folders/[folderId]/cases/[caseId]/caseControl.ts @@ -1,5 +1,6 @@ import Config from "@/config/config"; const apiServer = Config.apiServer; +import { CaseType } from "@/types/case"; /** * fetch case @@ -76,7 +77,7 @@ async function fetchDeleteStep(stepId: number, parentCaseId: number) { } /** - * Update folder + * Update case */ async function updateCase(updateCaseData: CaseType) { const fetchOptions = { diff --git a/frontend/app/projects/[projectId]/runs/RunDialog.tsx b/frontend/app/projects/[projectId]/runs/RunDialog.tsx deleted file mode 100644 index 8a89173..0000000 --- a/frontend/app/projects/[projectId]/runs/RunDialog.tsx +++ /dev/null @@ -1,182 +0,0 @@ -"use client"; -import React from "react"; -import { useState, useEffect } from "react"; -import { - Button, - Input, - Textarea, - Select, - SelectItem, - Modal, - ModalContent, - ModalHeader, - ModalBody, - ModalFooter, -} from "@nextui-org/react"; -import { testRunStatus } from "@/config/selection"; -import { RunType } from "@/types/run"; - -const defaultTestRun = { - id: 0, - name: "", - configurations: 0, - description: "", - state: 0, - projectId: 0, -}; - -type Props = { - isOpen: boolean; - editingRun: RunType; - onCancel: () => void; - onSubmit: (testRun: RunType) => void; -}; - -export default function RunDialog({ - isOpen, - editingRun, - onCancel, - onSubmit, -}: Props) { - const [testRun, setTestRun] = useState( - editingRun ? editingRun : defaultTestRun - ); - const [isNameInvalid, setIsNameInvalid] = useState(false); - - // 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 = () => { - // do validation - - onSubmit(testRun); - // clear(); - }; - - return ( - { - onCancel(); - }} - > - - Run - -
-
-
- { - setTestRun({ ...testRun, name: e.target.value }); - }} - className="mt-3" - /> - -