diff --git a/app/pages/projects/[projectId].tsx b/app/pages/projects/[projectId].tsx index 75bcfd3..96e66c1 100644 --- a/app/pages/projects/[projectId].tsx +++ b/app/pages/projects/[projectId].tsx @@ -77,7 +77,7 @@ const UpdatedInfo = ({ stub, project }) => { return ( <> {project.updatedBy} - {project.updatedAt.toLocaleString()} + {project.updatedAt.toLocaleString()} ) } @@ -85,14 +85,14 @@ const UpdatedInfo = ({ stub, project }) => { return ( <> {stub.stubs[0].updatedBy} - {stub.stubs[0].updatedAt.toLocaleString()} + {stub.stubs[0].updatedAt.toLocaleString()} ) } else { return ( <> {project.updatedBy} - {project.updatedAt.toLocaleString()} + {project.updatedAt.toLocaleString()} ) } @@ -181,7 +181,8 @@ export const Project = () => { createdBy createdAt updatedBy - updatedAt + updatedAt + memo @@ -190,6 +191,15 @@ export const Project = () => { {project.createdBy} {project.createdAt.toLocaleString()} + + {project.memo} + diff --git a/app/pages/stubs/[stubId].tsx b/app/pages/stubs/[stubId].tsx index d75999e..38d9ac6 100644 --- a/app/pages/stubs/[stubId].tsx +++ b/app/pages/stubs/[stubId].tsx @@ -135,15 +135,28 @@ export const Stub = () => { statusCode - - sleep - - - ntimesError - - - ntimesErrorStatusCode - + {stub.sleep !== 0 && ( + <> + + sleep + + + )} + {stub.ntimesError !== 0 && ( + <> + + ntimesError + + + ntimesErrorStatusCode + + + )} + {stub.memo !== "" && ( + + memo + + )} response @@ -173,16 +186,44 @@ export const Stub = () => { {stub.statusCode} - - {stub.sleep} s - - - {stub.ntimesError} times - - - {stub.ntimesErrorStatusCode} - - + {stub.sleep !== 0 && ( + <> + + {stub.sleep} s + + + )} + {stub.ntimesError !== 0 && ( + <> + + {stub.ntimesError} times + + + {stub.ntimesErrorStatusCode} + + + )} + {stub.memo !== "" && ( + + {stub.memo} + + )} +
                       {(() => {
                         try {
diff --git a/app/projects/components/ProjectForm.tsx b/app/projects/components/ProjectForm.tsx
index be1519c..1803058 100644
--- a/app/projects/components/ProjectForm.tsx
+++ b/app/projects/components/ProjectForm.tsx
@@ -1,5 +1,6 @@
 import { Form, FormProps } from "app/core/components/Form"
 import { LabeledTextField } from "app/core/components/LabeledTextField"
+import { LabeledTextAreaField } from "app/core/components/LabeledTextAreaField"
 import { z } from "zod"
 export { FORM_ERROR } from "app/core/components/Form"
 
@@ -8,6 +9,7 @@ export function ProjectForm>(props: FormProps)
      {...props}>
       
       
+      
     
   )
 }
diff --git a/app/projects/mutations/createProject.ts b/app/projects/mutations/createProject.ts
index 3660b9a..149aef3 100644
--- a/app/projects/mutations/createProject.ts
+++ b/app/projects/mutations/createProject.ts
@@ -9,6 +9,7 @@ const CreateProject = z.object({
   basePath: z
     .string()
     .regex(/^\/[^\/]+$/, { message: "The only slash allowed is at the beginning of a basePath" }),
+  memo: z.string().default(""),
 })
 
 export default resolver.pipe(resolver.zod(CreateProject), resolver.authorize(), async (input) => {
diff --git a/app/projects/mutations/updateProject.ts b/app/projects/mutations/updateProject.ts
index 76c7a53..efc3b84 100644
--- a/app/projects/mutations/updateProject.ts
+++ b/app/projects/mutations/updateProject.ts
@@ -9,6 +9,7 @@ const UpdateProject = z.object({
   basePath: z
     .string()
     .regex(/^\/[^\/]+$/, { message: "The only slash allowed is at the beginning of a basePath" }),
+  memo: z.string(),
 })
 
 export default resolver.pipe(
diff --git a/app/stubs/components/StubForm.tsx b/app/stubs/components/StubForm.tsx
index f126db6..db27e7e 100644
--- a/app/stubs/components/StubForm.tsx
+++ b/app/stubs/components/StubForm.tsx
@@ -46,6 +46,7 @@ export function StubForm>(props: FormProps) {
       />
       
       
+      
       
          {
diff --git a/app/stubs/mutations/updateStub.ts b/app/stubs/mutations/updateStub.ts
index d3f4a40..3921541 100644
--- a/app/stubs/mutations/updateStub.ts
+++ b/app/stubs/mutations/updateStub.ts
@@ -29,6 +29,7 @@ const UpdateStub = z.object({
   ntimesErrorStatusCode: z
     .string()
     .regex(/^\d{3}$/, { message: "The ntimes error status code must be a three-digit number." }),
+  memo: z.string(),
 })
 
 export default resolver.pipe(
diff --git a/db/migrations/20220227143200_/migration.sql b/db/migrations/20220227143200_/migration.sql
new file mode 100644
index 0000000..2f29232
--- /dev/null
+++ b/db/migrations/20220227143200_/migration.sql
@@ -0,0 +1,42 @@
+-- RedefineTables
+PRAGMA foreign_keys=OFF;
+CREATE TABLE "new_Project" (
+    "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
+    "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+    "updatedAt" DATETIME NOT NULL,
+    "name" TEXT NOT NULL,
+    "basePath" TEXT NOT NULL,
+    "createdBy" TEXT NOT NULL,
+    "updatedBy" TEXT NOT NULL,
+    "memo" TEXT NOT NULL DEFAULT ''
+);
+INSERT INTO "new_Project" ("basePath", "createdAt", "createdBy", "id", "name", "updatedAt", "updatedBy") SELECT "basePath", "createdAt", "createdBy", "id", "name", "updatedAt", "updatedBy" FROM "Project";
+DROP TABLE "Project";
+ALTER TABLE "new_Project" RENAME TO "Project";
+CREATE UNIQUE INDEX "Project_name_key" ON "Project"("name");
+CREATE UNIQUE INDEX "Project_basePath_key" ON "Project"("basePath");
+CREATE TABLE "new_Stub" (
+    "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
+    "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+    "updatedAt" DATETIME NOT NULL,
+    "createdBy" TEXT NOT NULL,
+    "updatedBy" TEXT NOT NULL,
+    "path" TEXT NOT NULL,
+    "method" TEXT NOT NULL,
+    "contentType" TEXT NOT NULL,
+    "statusCode" TEXT NOT NULL,
+    "response" TEXT NOT NULL,
+    "sleep" INTEGER NOT NULL DEFAULT 0,
+    "logs" TEXT NOT NULL,
+    "ntimesError" INTEGER NOT NULL DEFAULT 0,
+    "ntimesErrorStatusCode" TEXT NOT NULL DEFAULT '500',
+    "ntimesErrorCounter" INTEGER NOT NULL DEFAULT 0,
+    "memo" TEXT NOT NULL DEFAULT '',
+    "projectId" INTEGER NOT NULL,
+    CONSTRAINT "Stub_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "Project" ("id") ON DELETE CASCADE ON UPDATE CASCADE
+);
+INSERT INTO "new_Stub" ("contentType", "createdAt", "createdBy", "id", "logs", "method", "ntimesError", "ntimesErrorCounter", "ntimesErrorStatusCode", "path", "projectId", "response", "sleep", "statusCode", "updatedAt", "updatedBy") SELECT "contentType", "createdAt", "createdBy", "id", "logs", "method", "ntimesError", "ntimesErrorCounter", "ntimesErrorStatusCode", "path", "projectId", "response", "sleep", "statusCode", "updatedAt", "updatedBy" FROM "Stub";
+DROP TABLE "Stub";
+ALTER TABLE "new_Stub" RENAME TO "Stub";
+PRAGMA foreign_key_check;
+PRAGMA foreign_keys=ON;
diff --git a/db/schema.prisma b/db/schema.prisma
index 0ad8c43..f51817e 100644
--- a/db/schema.prisma
+++ b/db/schema.prisma
@@ -72,6 +72,7 @@ model Project {
   basePath  String   @unique
   createdBy String
   updatedBy String
+  memo      String   @default("")
   Stub      Stub[]
 }
 
@@ -91,6 +92,7 @@ model Stub {
   ntimesError           Int      @default(0)
   ntimesErrorStatusCode String   @default("500")
   ntimesErrorCounter    Int      @default(0)
+  memo                  String   @default("")
   project               Project  @relation(fields: [projectId], references: [id], onDelete: Cascade)
   projectId             Int
 }