mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-03 18:52:17 +00:00
Merge pull request #3257 from Dokploy/fix/add-remove-build-registry
fix(build-server): enforce selection rules for Build Server and Build…
This commit is contained in:
@@ -38,10 +38,31 @@ interface Props {
|
|||||||
applicationId: string;
|
applicationId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const schema = z.object({
|
const schema = z
|
||||||
buildServerId: z.string().min(1, "Build server is required"),
|
.object({
|
||||||
buildRegistryId: z.string().min(1, "Build registry is required"),
|
buildServerId: z.string().optional(),
|
||||||
});
|
buildRegistryId: z.string().optional(),
|
||||||
|
})
|
||||||
|
.refine(
|
||||||
|
(data) => {
|
||||||
|
// Both empty/none is valid
|
||||||
|
const buildServerIsNone =
|
||||||
|
!data.buildServerId || data.buildServerId === "none";
|
||||||
|
const buildRegistryIsNone =
|
||||||
|
!data.buildRegistryId || data.buildRegistryId === "none";
|
||||||
|
|
||||||
|
// Both should be either filled or empty
|
||||||
|
if (buildServerIsNone && buildRegistryIsNone) return true;
|
||||||
|
if (!buildServerIsNone && !buildRegistryIsNone) return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
{
|
||||||
|
message:
|
||||||
|
"Both Build Server and Build Registry must be selected together, or both set to None",
|
||||||
|
path: ["buildServerId"], // Show error on buildServerId field
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
type Schema = z.infer<typeof schema>;
|
type Schema = z.infer<typeof schema>;
|
||||||
|
|
||||||
@@ -121,6 +142,11 @@ export const ShowBuildServer = ({ applicationId }: Props) => {
|
|||||||
container starts running.
|
container starts running.
|
||||||
</AlertBlock>
|
</AlertBlock>
|
||||||
|
|
||||||
|
<AlertBlock type="info">
|
||||||
|
<strong>Note:</strong> Build Server and Build Registry must be
|
||||||
|
configured together. You can either select both or set both to None.
|
||||||
|
</AlertBlock>
|
||||||
|
|
||||||
{!registries || registries.length === 0 ? (
|
{!registries || registries.length === 0 ? (
|
||||||
<AlertBlock type="warning">
|
<AlertBlock type="warning">
|
||||||
You need to add at least one registry to use build servers. Please
|
You need to add at least one registry to use build servers. Please
|
||||||
@@ -147,7 +173,13 @@ export const ShowBuildServer = ({ applicationId }: Props) => {
|
|||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Build Server</FormLabel>
|
<FormLabel>Build Server</FormLabel>
|
||||||
<Select
|
<Select
|
||||||
onValueChange={field.onChange}
|
onValueChange={(value) => {
|
||||||
|
field.onChange(value);
|
||||||
|
// If setting to "none", also reset build registry to "none"
|
||||||
|
if (value === "none") {
|
||||||
|
form.setValue("buildRegistryId", "none");
|
||||||
|
}
|
||||||
|
}}
|
||||||
value={field.value || "none"}
|
value={field.value || "none"}
|
||||||
>
|
>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
@@ -197,7 +229,13 @@ export const ShowBuildServer = ({ applicationId }: Props) => {
|
|||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Build Registry</FormLabel>
|
<FormLabel>Build Registry</FormLabel>
|
||||||
<Select
|
<Select
|
||||||
onValueChange={field.onChange}
|
onValueChange={(value) => {
|
||||||
|
field.onChange(value);
|
||||||
|
// If setting to "none", also reset build server to "none"
|
||||||
|
if (value === "none") {
|
||||||
|
form.setValue("buildServerId", "none");
|
||||||
|
}
|
||||||
|
}}
|
||||||
value={field.value || "none"}
|
value={field.value || "none"}
|
||||||
>
|
>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
|
|||||||
@@ -286,13 +286,17 @@ export const ShowProjects = () => {
|
|||||||
)
|
)
|
||||||
.some(Boolean);
|
.some(Boolean);
|
||||||
|
|
||||||
|
const productionEnvironment = project?.environments.find(
|
||||||
|
(env) => env.isDefault,
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={project.projectId}
|
key={project.projectId}
|
||||||
className="w-full lg:max-w-md"
|
className="w-full lg:max-w-md"
|
||||||
>
|
>
|
||||||
<Link
|
<Link
|
||||||
href={`/dashboard/project/${project.projectId}/environment/${project?.environments?.[0]?.environmentId}`}
|
href={`/dashboard/project/${project.projectId}/environment/${productionEnvironment?.environmentId}`}
|
||||||
>
|
>
|
||||||
<Card className="group relative w-full h-full bg-transparent transition-colors hover:bg-border">
|
<Card className="group relative w-full h-full bg-transparent transition-colors hover:bg-border">
|
||||||
{haveServicesWithDomains ? (
|
{haveServicesWithDomains ? (
|
||||||
|
|||||||
Reference in New Issue
Block a user