mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-09 05:25:18 +00:00
fix: improve volume backup validation and refactor component props
- Added validation to ensure service name is required when service type is "compose" in the volume backup form schema. - Refactored the ShowVolumeBackups component to use a more consistent prop name for volume backup type, enhancing clarity and maintainability. - Updated related components to align with the new prop structure, ensuring seamless integration across the application.
This commit is contained in:
@@ -78,6 +78,14 @@ const formSchema = z
|
|||||||
path: ["serviceName"],
|
path: ["serviceName"],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.serviceType === "compose" && !data.serviceName) {
|
||||||
|
ctx.addIssue({
|
||||||
|
code: z.ZodIssueCode.custom,
|
||||||
|
message: "Service name is required",
|
||||||
|
path: ["serviceName"],
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|||||||
+8
-18
@@ -17,7 +17,6 @@ import {
|
|||||||
import { api } from "@/utils/api";
|
import { api } from "@/utils/api";
|
||||||
import {
|
import {
|
||||||
ClipboardList,
|
ClipboardList,
|
||||||
Clock,
|
|
||||||
DatabaseBackup,
|
DatabaseBackup,
|
||||||
Loader2,
|
Loader2,
|
||||||
Play,
|
Play,
|
||||||
@@ -29,19 +28,10 @@ import { ShowDeploymentsModal } from "../deployments/show-deployments-modal";
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
id: string;
|
id: string;
|
||||||
volumeBackupType?:
|
type?: "application" | "compose" | "postgres" | "mariadb" | "mongo" | "mysql";
|
||||||
| "application"
|
|
||||||
| "compose"
|
|
||||||
| "postgres"
|
|
||||||
| "mariadb"
|
|
||||||
| "mongo"
|
|
||||||
| "mysql";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ShowVolumeBackups = ({
|
export const ShowVolumeBackups = ({ id, type = "application" }: Props) => {
|
||||||
id,
|
|
||||||
volumeBackupType = "application",
|
|
||||||
}: Props) => {
|
|
||||||
const {
|
const {
|
||||||
data: volumeBackups,
|
data: volumeBackups,
|
||||||
isLoading: isLoadingVolumeBackups,
|
isLoading: isLoadingVolumeBackups,
|
||||||
@@ -49,7 +39,7 @@ export const ShowVolumeBackups = ({
|
|||||||
} = api.volumeBackups.list.useQuery(
|
} = api.volumeBackups.list.useQuery(
|
||||||
{
|
{
|
||||||
id: id || "",
|
id: id || "",
|
||||||
volumeBackupType,
|
volumeBackupType: type,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
enabled: !!id,
|
enabled: !!id,
|
||||||
@@ -79,7 +69,7 @@ export const ShowVolumeBackups = ({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{volumeBackups && volumeBackups.length > 0 && (
|
{volumeBackups && volumeBackups.length > 0 && (
|
||||||
<HandleVolumeBackups id={id} volumeBackupType={volumeBackupType} />
|
<HandleVolumeBackups id={id} volumeBackupType={type} />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
@@ -109,7 +99,7 @@ export const ShowVolumeBackups = ({
|
|||||||
>
|
>
|
||||||
<div className="flex items-start gap-3">
|
<div className="flex items-start gap-3">
|
||||||
<div className="flex h-9 w-9 items-center justify-center rounded-full bg-primary/5">
|
<div className="flex h-9 w-9 items-center justify-center rounded-full bg-primary/5">
|
||||||
<Clock className="size-4 text-primary/70" />
|
<DatabaseBackup className="size-4 text-primary/70" />
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-1.5">
|
<div className="space-y-1.5">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
@@ -184,7 +174,7 @@ export const ShowVolumeBackups = ({
|
|||||||
<HandleVolumeBackups
|
<HandleVolumeBackups
|
||||||
volumeBackupId={volumeBackup.volumeBackupId}
|
volumeBackupId={volumeBackup.volumeBackupId}
|
||||||
id={id}
|
id={id}
|
||||||
volumeBackupType={volumeBackupType}
|
volumeBackupType={type}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<DialogAction
|
<DialogAction
|
||||||
@@ -198,7 +188,7 @@ export const ShowVolumeBackups = ({
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
utils.volumeBackups.list.invalidate({
|
utils.volumeBackups.list.invalidate({
|
||||||
id,
|
id,
|
||||||
volumeBackupType,
|
volumeBackupType: type,
|
||||||
});
|
});
|
||||||
toast.success("Volume backup deleted successfully");
|
toast.success("Volume backup deleted successfully");
|
||||||
})
|
})
|
||||||
@@ -230,7 +220,7 @@ export const ShowVolumeBackups = ({
|
|||||||
<p className="text-sm text-muted-foreground mt-1">
|
<p className="text-sm text-muted-foreground mt-1">
|
||||||
Create your first volume backup to automate your workflows
|
Create your first volume backup to automate your workflows
|
||||||
</p>
|
</p>
|
||||||
<HandleVolumeBackups id={id} volumeBackupType={volumeBackupType} />
|
<HandleVolumeBackups id={id} volumeBackupType={type} />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</CardContent>
|
</CardContent>
|
||||||
|
|||||||
+1
-7
@@ -336,15 +336,9 @@ const Service = (
|
|||||||
<TabsContent value="volume-backups" className="w-full pt-2.5">
|
<TabsContent value="volume-backups" className="w-full pt-2.5">
|
||||||
<div className="flex flex-col gap-4 border rounded-lg">
|
<div className="flex flex-col gap-4 border rounded-lg">
|
||||||
<ShowVolumeBackups
|
<ShowVolumeBackups
|
||||||
id={applicationId}
|
|
||||||
volumeBackupType="application"
|
|
||||||
/>
|
|
||||||
{/* <ShowDeployments
|
|
||||||
id={applicationId}
|
id={applicationId}
|
||||||
type="application"
|
type="application"
|
||||||
serverId={data?.serverId || ""}
|
/>
|
||||||
refreshToken={data?.refreshToken || ""}
|
|
||||||
/> */}
|
|
||||||
</div>
|
</div>
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
<TabsContent value="preview-deployments" className="w-full">
|
<TabsContent value="preview-deployments" className="w-full">
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { ShowDeployments } from "@/components/dashboard/application/deployments/
|
|||||||
import { ShowDomains } from "@/components/dashboard/application/domains/show-domains";
|
import { ShowDomains } from "@/components/dashboard/application/domains/show-domains";
|
||||||
import { ShowEnvironment } from "@/components/dashboard/application/environment/show-enviroment";
|
import { ShowEnvironment } from "@/components/dashboard/application/environment/show-enviroment";
|
||||||
import { ShowSchedules } from "@/components/dashboard/application/schedules/show-schedules";
|
import { ShowSchedules } from "@/components/dashboard/application/schedules/show-schedules";
|
||||||
|
import { ShowVolumeBackups } from "@/components/dashboard/application/volume-backups/show-volume-backups";
|
||||||
import { AddCommandCompose } from "@/components/dashboard/compose/advanced/add-command";
|
import { AddCommandCompose } from "@/components/dashboard/compose/advanced/add-command";
|
||||||
import { DeleteService } from "@/components/dashboard/compose/delete-service";
|
import { DeleteService } from "@/components/dashboard/compose/delete-service";
|
||||||
import { ShowGeneralCompose } from "@/components/dashboard/compose/general/show";
|
import { ShowGeneralCompose } from "@/components/dashboard/compose/general/show";
|
||||||
@@ -57,7 +58,8 @@ type TabState =
|
|||||||
| "advanced"
|
| "advanced"
|
||||||
| "deployments"
|
| "deployments"
|
||||||
| "domains"
|
| "domains"
|
||||||
| "monitoring";
|
| "monitoring"
|
||||||
|
| "volumeBackups";
|
||||||
|
|
||||||
const Service = (
|
const Service = (
|
||||||
props: InferGetServerSidePropsType<typeof getServerSideProps>,
|
props: InferGetServerSidePropsType<typeof getServerSideProps>,
|
||||||
@@ -226,6 +228,9 @@ const Service = (
|
|||||||
<TabsTrigger value="deployments">Deployments</TabsTrigger>
|
<TabsTrigger value="deployments">Deployments</TabsTrigger>
|
||||||
<TabsTrigger value="backups">Backups</TabsTrigger>
|
<TabsTrigger value="backups">Backups</TabsTrigger>
|
||||||
<TabsTrigger value="schedules">Schedules</TabsTrigger>
|
<TabsTrigger value="schedules">Schedules</TabsTrigger>
|
||||||
|
<TabsTrigger value="volumeBackups">
|
||||||
|
Volume Backups
|
||||||
|
</TabsTrigger>
|
||||||
<TabsTrigger value="logs">Logs</TabsTrigger>
|
<TabsTrigger value="logs">Logs</TabsTrigger>
|
||||||
{((data?.serverId && isCloud) || !data?.server) && (
|
{((data?.serverId && isCloud) || !data?.server) && (
|
||||||
<TabsTrigger value="monitoring">Monitoring</TabsTrigger>
|
<TabsTrigger value="monitoring">Monitoring</TabsTrigger>
|
||||||
@@ -255,7 +260,11 @@ const Service = (
|
|||||||
<ShowSchedules id={composeId} scheduleType="compose" />
|
<ShowSchedules id={composeId} scheduleType="compose" />
|
||||||
</div>
|
</div>
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
|
<TabsContent value="volumeBackups">
|
||||||
|
<div className="flex flex-col gap-4 pt-2.5">
|
||||||
|
<ShowVolumeBackups id={composeId} type="compose" />
|
||||||
|
</div>
|
||||||
|
</TabsContent>
|
||||||
<TabsContent value="monitoring">
|
<TabsContent value="monitoring">
|
||||||
<div className="pt-2.5">
|
<div className="pt-2.5">
|
||||||
<div className="flex flex-col border rounded-lg ">
|
<div className="flex flex-col border rounded-lg ">
|
||||||
@@ -342,6 +351,7 @@ const Service = (
|
|||||||
<ShowDomains id={composeId} type="compose" />
|
<ShowDomains id={composeId} type="compose" />
|
||||||
</div>
|
</div>
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
|
|
||||||
<TabsContent value="advanced">
|
<TabsContent value="advanced">
|
||||||
<div className="flex flex-col gap-4 pt-2.5">
|
<div className="flex flex-col gap-4 pt-2.5">
|
||||||
<AddCommandCompose composeId={composeId} />
|
<AddCommandCompose composeId={composeId} />
|
||||||
|
|||||||
Reference in New Issue
Block a user