mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
feat: discord decoration switch
This commit is contained in:
@@ -64,6 +64,7 @@ export const notificationSchema = z.discriminatedUnion("type", [
|
|||||||
.object({
|
.object({
|
||||||
type: z.literal("discord"),
|
type: z.literal("discord"),
|
||||||
webhookUrl: z.string().min(1, { message: "Webhook URL is required" }),
|
webhookUrl: z.string().min(1, { message: "Webhook URL is required" }),
|
||||||
|
decoration: z.boolean().default(true),
|
||||||
})
|
})
|
||||||
.merge(notificationBaseSchema),
|
.merge(notificationBaseSchema),
|
||||||
z
|
z
|
||||||
@@ -195,6 +196,7 @@ export const AddNotification = () => {
|
|||||||
dokployRestart: dokployRestart,
|
dokployRestart: dokployRestart,
|
||||||
databaseBackup: databaseBackup,
|
databaseBackup: databaseBackup,
|
||||||
webhookUrl: data.webhookUrl,
|
webhookUrl: data.webhookUrl,
|
||||||
|
decoration: data.decoration,
|
||||||
name: data.name,
|
name: data.name,
|
||||||
dockerCleanup: dockerCleanup,
|
dockerCleanup: dockerCleanup,
|
||||||
});
|
});
|
||||||
@@ -397,6 +399,7 @@ export const AddNotification = () => {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{type === "discord" && (
|
{type === "discord" && (
|
||||||
|
<>
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="webhookUrl"
|
name="webhookUrl"
|
||||||
@@ -414,6 +417,29 @@ export const AddNotification = () => {
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="decoration"
|
||||||
|
defaultValue={true}
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem className="flex items-center justify-between rounded-lg border p-3 shadow-sm">
|
||||||
|
<div className="space-y-0.5">
|
||||||
|
<FormLabel>Decoration</FormLabel>
|
||||||
|
<FormDescription>
|
||||||
|
Decorate the notification with emojis.
|
||||||
|
</FormDescription>
|
||||||
|
</div>
|
||||||
|
<FormControl>
|
||||||
|
<Switch
|
||||||
|
checked={field.value}
|
||||||
|
onCheckedChange={field.onChange}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{type === "email" && (
|
{type === "email" && (
|
||||||
|
|||||||
@@ -72,7 +72,9 @@ export const ShowNotifications = () => {
|
|||||||
{notification.name}
|
{notification.name}
|
||||||
</span>
|
</span>
|
||||||
<span className="text-xs font-medium text-muted-foreground">
|
<span className="text-xs font-medium text-muted-foreground">
|
||||||
{notification.notificationType?.[0]?.toUpperCase() + notification.notificationType?.slice(1)} notification
|
{notification.notificationType?.[0]?.toUpperCase() +
|
||||||
|
notification.notificationType?.slice(1)}{" "}
|
||||||
|
notification
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import { api } from "@/utils/api";
|
|||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { Mail, Pen } from "lucide-react";
|
import { Mail, Pen } from "lucide-react";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { FieldErrors, useFieldArray, useForm } from "react-hook-form";
|
import { useFieldArray, useForm } from "react-hook-form";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import {
|
import {
|
||||||
type NotificationSchema,
|
type NotificationSchema,
|
||||||
@@ -113,6 +113,7 @@ export const UpdateNotification = ({ notificationId }: Props) => {
|
|||||||
databaseBackup: data.databaseBackup,
|
databaseBackup: data.databaseBackup,
|
||||||
type: data.notificationType,
|
type: data.notificationType,
|
||||||
webhookUrl: data.discord?.webhookUrl,
|
webhookUrl: data.discord?.webhookUrl,
|
||||||
|
decoration: data.discord?.decoration || undefined,
|
||||||
name: data.name,
|
name: data.name,
|
||||||
dockerCleanup: data.dockerCleanup,
|
dockerCleanup: data.dockerCleanup,
|
||||||
});
|
});
|
||||||
@@ -218,9 +219,7 @@ export const UpdateNotification = ({ notificationId }: Props) => {
|
|||||||
return (
|
return (
|
||||||
<Dialog open={isOpen} onOpenChange={setIsOpen}>
|
<Dialog open={isOpen} onOpenChange={setIsOpen}>
|
||||||
<DialogTrigger className="" asChild>
|
<DialogTrigger className="" asChild>
|
||||||
<Button variant="ghost"
|
<Button variant="ghost" size="icon" className="h-9 w-9">
|
||||||
size="icon"
|
|
||||||
className="h-9 w-9">
|
|
||||||
<Pen className="size-4 text-muted-foreground" />
|
<Pen className="size-4 text-muted-foreground" />
|
||||||
</Button>
|
</Button>
|
||||||
</DialogTrigger>
|
</DialogTrigger>
|
||||||
@@ -358,6 +357,7 @@ export const UpdateNotification = ({ notificationId }: Props) => {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{type === "discord" && (
|
{type === "discord" && (
|
||||||
|
<>
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="webhookUrl"
|
name="webhookUrl"
|
||||||
@@ -375,6 +375,29 @@ export const UpdateNotification = ({ notificationId }: Props) => {
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="decoration"
|
||||||
|
defaultValue={true}
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem className="flex items-center justify-between rounded-lg border p-3 shadow-sm">
|
||||||
|
<div className="space-y-0.5">
|
||||||
|
<FormLabel>Decoration</FormLabel>
|
||||||
|
<FormDescription>
|
||||||
|
Decorate the notification with emojis.
|
||||||
|
</FormDescription>
|
||||||
|
</div>
|
||||||
|
<FormControl>
|
||||||
|
<Switch
|
||||||
|
checked={field.value}
|
||||||
|
onCheckedChange={field.onChange}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
{type === "email" && (
|
{type === "email" && (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -172,6 +172,7 @@ export const apiCreateDiscord = notificationsSchema
|
|||||||
})
|
})
|
||||||
.extend({
|
.extend({
|
||||||
webhookUrl: z.string().min(1),
|
webhookUrl: z.string().min(1),
|
||||||
|
decoration: z.boolean(),
|
||||||
})
|
})
|
||||||
.required();
|
.required();
|
||||||
|
|
||||||
@@ -183,6 +184,7 @@ export const apiUpdateDiscord = apiCreateDiscord.partial().extend({
|
|||||||
|
|
||||||
export const apiTestDiscordConnection = apiCreateDiscord.pick({
|
export const apiTestDiscordConnection = apiCreateDiscord.pick({
|
||||||
webhookUrl: true,
|
webhookUrl: true,
|
||||||
|
decoration: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const apiCreateEmail = notificationsSchema
|
export const apiCreateEmail = notificationsSchema
|
||||||
|
|||||||
@@ -204,6 +204,7 @@ export const createDiscordNotification = async (
|
|||||||
.insert(discord)
|
.insert(discord)
|
||||||
.values({
|
.values({
|
||||||
webhookUrl: input.webhookUrl,
|
webhookUrl: input.webhookUrl,
|
||||||
|
decoration: input.decoration,
|
||||||
})
|
})
|
||||||
.returning()
|
.returning()
|
||||||
.then((value) => value[0]);
|
.then((value) => value[0]);
|
||||||
@@ -272,6 +273,7 @@ export const updateDiscordNotification = async (
|
|||||||
.update(discord)
|
.update(discord)
|
||||||
.set({
|
.set({
|
||||||
webhookUrl: input.webhookUrl,
|
webhookUrl: input.webhookUrl,
|
||||||
|
decoration: input.decoration,
|
||||||
})
|
})
|
||||||
.where(eq(discord.discordId, input.discordId))
|
.where(eq(discord.discordId, input.discordId))
|
||||||
.returning()
|
.returning()
|
||||||
|
|||||||
Reference in New Issue
Block a user