From 429c1e4cd8e292df3b0ebd6579b0c4ff140d83e5 Mon Sep 17 00:00:00 2001 From: PiquelChips <63727792+PiquelChips@users.noreply.github.com> Date: Mon, 11 Aug 2025 14:03:30 +0200 Subject: [PATCH] feat: better UI for submitting labels --- .../show-preview-settings.tsx | 111 +- .../dokploy/drizzle/0104_yummy_silver_fox.sql | 1 - apps/dokploy/drizzle/0106_purple_maggott.sql | 1 + apps/dokploy/drizzle/meta/0106_snapshot.json | 6424 +++++++++++++++++ apps/dokploy/drizzle/meta/_journal.json | 7 + apps/dokploy/pages/api/deploy/github.ts | 5 +- packages/server/src/db/schema/application.ts | 2 +- 7 files changed, 6526 insertions(+), 25 deletions(-) delete mode 100644 apps/dokploy/drizzle/0104_yummy_silver_fox.sql create mode 100644 apps/dokploy/drizzle/0106_purple_maggott.sql create mode 100644 apps/dokploy/drizzle/meta/0106_snapshot.json diff --git a/apps/dokploy/components/dashboard/application/preview-deployments/show-preview-settings.tsx b/apps/dokploy/components/dashboard/application/preview-deployments/show-preview-settings.tsx index 7e59482d4..0aa676057 100644 --- a/apps/dokploy/components/dashboard/application/preview-deployments/show-preview-settings.tsx +++ b/apps/dokploy/components/dashboard/application/preview-deployments/show-preview-settings.tsx @@ -1,4 +1,5 @@ import { Button } from "@/components/ui/button"; +import { Badge } from "@/components/ui/badge"; import { Dialog, DialogContent, @@ -27,9 +28,15 @@ import { SelectValue, } from "@/components/ui/select"; import { Switch } from "@/components/ui/switch"; +import { + Tooltip, + TooltipContent, + TooltipProvider, + TooltipTrigger, +} from "@/components/ui/tooltip"; import { api } from "@/utils/api"; import { zodResolver } from "@hookform/resolvers/zod"; -import { Settings2 } from "lucide-react"; +import { HelpCircle, Plus, Settings2, X } from "lucide-react"; import { useEffect, useState } from "react"; import { useForm } from "react-hook-form"; import { toast } from "sonner"; @@ -42,7 +49,7 @@ const schema = z wildcardDomain: z.string(), port: z.number(), previewLimit: z.number(), - previewLabels: z.string(), + previewLabels: z.array(z.string()).optional(), previewHttps: z.boolean(), previewPath: z.string(), previewCertificateType: z.enum(["letsencrypt", "none", "custom"]), @@ -82,7 +89,7 @@ export const ShowPreviewSettings = ({ applicationId }: Props) => { wildcardDomain: "*.traefik.me", port: 3000, previewLimit: 3, - previewLabels: "", + previewLabels: [], previewHttps: false, previewPath: "/", previewCertificateType: "none", @@ -104,7 +111,7 @@ export const ShowPreviewSettings = ({ applicationId }: Props) => { buildArgs: data.previewBuildArgs || "", wildcardDomain: data.previewWildcard || "*.traefik.me", port: data.previewPort || 3000, - previewLabels: data.previewLabels || "", + previewLabels: data.previewLabels || [], previewLimit: data.previewLimit || 3, previewHttps: data.previewHttps || false, previewPath: data.previewPath || "/", @@ -204,22 +211,86 @@ export const ShowPreviewSettings = ({ applicationId }: Props) => { )} /> - ( - - Labels - - - - - - )} - /> + ( + +
+ Preview Labels + + + + + + +

+ Add a labels that will trigger a preview deployment + for a pull request. If no labels are specified, all + pull requests will trigger a preview deployment. +

+
+
+
+
+
+ {field.value?.map((label, index) => ( + + {label} + { + const newLabels = [...(field.value || [])]; + newLabels.splice(index, 1); + field.onChange(newLabels); + }} + /> + + ))} +
+
+ + { + if (e.key === "Enter") { + e.preventDefault(); + const input = e.currentTarget; + const label = input.value.trim(); + if (label) { + field.onChange([...(field.value || []), label]); + input.value = ""; + } + } + }} + /> + + +
+ +
+ )} + /> 0) { let hasLabel: boolean = false; const labels = githubBody?.pull_request?.labels; for (const label of labels) { - if (previewLabels.contains(label.name)) { + if (app?.previewLabels.contains(label.name)) { hasLabel = true; break; } diff --git a/packages/server/src/db/schema/application.ts b/packages/server/src/db/schema/application.ts index 7263b895f..21ee9fbda 100644 --- a/packages/server/src/db/schema/application.ts +++ b/packages/server/src/db/schema/application.ts @@ -79,7 +79,7 @@ export const applications = pgTable("application", { previewEnv: text("previewEnv"), watchPaths: text("watchPaths").array(), previewBuildArgs: text("previewBuildArgs"), - previewLabels: text("previewLabels"), + previewLabels: text("previewLabels").array(), previewWildcard: text("previewWildcard"), previewPort: integer("previewPort").default(3000), previewHttps: boolean("previewHttps").notNull().default(false),