Skip to content

Commit cf52193

Browse files
feat: expose GitLab webhook config in UI, provider-aware permission label
- edit-gitlab-provider.tsx: add Webhook Configuration section with read-only webhook URL and secret token fields (each with copy button) - show-preview-settings.tsx: previewRequireCollaboratorPermissions label switches to 'Require Member Access' with GitLab roles (Owner/Maintainer/ Developer) when sourceType is 'gitlab' Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 4956958 commit cf52193

2 files changed

Lines changed: 109 additions & 13 deletions

File tree

apps/dokploy/components/dashboard/application/preview-deployments/show-preview-settings.tsx

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -433,18 +433,37 @@ export const ShowPreviewSettings = ({ applicationId }: Props) => {
433433
render={({ field }) => (
434434
<FormItem className="flex flex-row items-center justify-between p-3 mt-4 border rounded-lg shadow-sm col-span-2">
435435
<div className="space-y-0.5">
436-
<FormLabel>
437-
Require Collaborator Permissions
438-
</FormLabel>
439-
<FormDescription>
440-
Require collaborator permissions to preview
441-
deployments, valid roles are:
442-
<ul>
443-
<li>Admin</li>
444-
<li>Maintain</li>
445-
<li>Write</li>
446-
</ul>
447-
</FormDescription>
436+
{data?.sourceType === "gitlab" ? (
437+
<>
438+
<FormLabel>
439+
Require Member Access
440+
</FormLabel>
441+
<FormDescription>
442+
Require a minimum GitLab access level to
443+
trigger preview deployments. Valid roles are:
444+
<ul>
445+
<li>Owner</li>
446+
<li>Maintainer</li>
447+
<li>Developer</li>
448+
</ul>
449+
</FormDescription>
450+
</>
451+
) : (
452+
<>
453+
<FormLabel>
454+
Require Collaborator Permissions
455+
</FormLabel>
456+
<FormDescription>
457+
Require collaborator permissions to preview
458+
deployments, valid roles are:
459+
<ul>
460+
<li>Admin</li>
461+
<li>Maintain</li>
462+
<li>Write</li>
463+
</ul>
464+
</FormDescription>
465+
</>
466+
)}
448467
</div>
449468
<FormControl>
450469
<Switch

apps/dokploy/components/dashboard/settings/git/gitlab/edit-gitlab-provider.tsx

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { standardSchemaResolver as zodResolver } from "@hookform/resolvers/standard-schema";
2-
import { PenBoxIcon } from "lucide-react";
2+
import { Check, Copy, PenBoxIcon } from "lucide-react";
33
import { useEffect, useState } from "react";
44
import { useForm } from "react-hook-form";
55
import { toast } from "sonner";
@@ -58,6 +58,23 @@ export const EditGitlabProvider = ({ gitlabId }: Props) => {
5858
);
5959
const utils = api.useUtils();
6060
const [isOpen, setIsOpen] = useState(false);
61+
const [copiedWebhookUrl, setCopiedWebhookUrl] = useState(false);
62+
const [copiedSecret, setCopiedSecret] = useState(false);
63+
64+
const webhookUrl =
65+
typeof window !== "undefined"
66+
? `${window.location.origin}/api/deploy/gitlab`
67+
: "/api/deploy/gitlab";
68+
69+
const copyToClipboard = (
70+
text: string,
71+
setter: (v: boolean) => void,
72+
) => {
73+
navigator.clipboard.writeText(text);
74+
setter(true);
75+
toast.success("Copied to clipboard");
76+
setTimeout(() => setter(false), 2000);
77+
};
6178
const { mutateAsync, error, isError } = api.gitlab.update.useMutation();
6279
const { mutateAsync: testConnection, isPending } =
6380
api.gitlab.testConnection.useMutation();
@@ -201,6 +218,66 @@ export const EditGitlabProvider = ({ gitlabId }: Props) => {
201218
)}
202219
/>
203220

221+
<div className="flex flex-col gap-2">
222+
<p className="text-sm font-medium">
223+
Webhook Configuration
224+
</p>
225+
<p className="text-sm text-muted-foreground">
226+
Configure these values in your GitLab project under{" "}
227+
<strong>Settings → Webhooks</strong>. Enable the{" "}
228+
<em>Merge requests events</em> and{" "}
229+
<em>Push events</em> triggers.
230+
</p>
231+
<div className="flex items-center gap-2">
232+
<Input
233+
readOnly
234+
value={webhookUrl}
235+
className="font-mono text-xs"
236+
/>
237+
<Button
238+
type="button"
239+
variant="outline"
240+
size="icon"
241+
onClick={() =>
242+
copyToClipboard(webhookUrl, setCopiedWebhookUrl)
243+
}
244+
>
245+
{copiedWebhookUrl ? (
246+
<Check className="size-4 text-green-500" />
247+
) : (
248+
<Copy className="size-4" />
249+
)}
250+
</Button>
251+
</div>
252+
{gitlab?.webhookSecret && (
253+
<div className="flex items-center gap-2">
254+
<Input
255+
readOnly
256+
type="password"
257+
value={gitlab.webhookSecret}
258+
className="font-mono text-xs"
259+
/>
260+
<Button
261+
type="button"
262+
variant="outline"
263+
size="icon"
264+
onClick={() =>
265+
copyToClipboard(
266+
gitlab.webhookSecret!,
267+
setCopiedSecret,
268+
)
269+
}
270+
>
271+
{copiedSecret ? (
272+
<Check className="size-4 text-green-500" />
273+
) : (
274+
<Copy className="size-4" />
275+
)}
276+
</Button>
277+
</div>
278+
)}
279+
</div>
280+
204281
<div className="flex w-full justify-between gap-4 mt-4">
205282
<Button
206283
type="button"

0 commit comments

Comments
 (0)