diff --git a/frontend/src/components/config/index.tsx b/frontend/src/components/config/index.tsx index bfe29838b..450fc6fdc 100644 --- a/frontend/src/components/config/index.tsx +++ b/frontend/src/components/config/index.tsx @@ -60,8 +60,10 @@ export const ConfigLayout = < variant="outline" onClick={onReset} disabled={disabled || (config ? !Object.keys(config).length : true)} + className="flex items-center gap-2" > + Reset {changesMade && ( - diff --git a/frontend/src/components/resources/build/config.tsx b/frontend/src/components/resources/build/config.tsx index d5cc2fc81..8e691b70d 100644 --- a/frontend/src/components/resources/build/config.tsx +++ b/frontend/src/components/resources/build/config.tsx @@ -19,8 +19,9 @@ import { } from "@ui/select"; import { Textarea } from "@ui/textarea"; import { PlusCircle } from "lucide-react"; -import { ReactNode, useEffect, useState } from "react"; +import { ReactNode, RefObject, createRef, useEffect, useState } from "react"; import { CopyGithubWebhook, LabelsConfig, ResourceSelector } from "../common"; +import { Tabs, TabsContent, TabsList, TabsTrigger } from "@ui/tabs"; export const BuildConfig = ({ id, @@ -270,24 +271,171 @@ const BuildArgs = ({ set: (input: Partial) => void; disabled: boolean; }) => { - const [args, setArgs] = useState(env_to_text(vars)); - useEffect(() => { - !!args && set({ build_args: text_to_env(args) }); - }, [args, set]); + const ref = createRef(); + const [args, setArgs] = useState(); + useEffect(() => setArgs(env_to_text(vars)), [vars]); + + const update = () => { + if (!args) return; + const parsed = text_to_env(args); + + // Diff the vars from old to new + for (const [v, i] of vars.map( + (v, i) => [v, i] as [Types.EnvironmentVar, number] + )) { + const _v = parsed[i]; + if (!_v || v.value !== _v.value || v.variable !== _v.variable) { + set({ build_args: parsed }); + return; + } + } + + // Diff the vars from new to old + for (const [v, i] of parsed.map( + (v, i) => [v, i] as [Types.EnvironmentVar, number] + )) { + const _v = vars[i]; + if (!_v || v.value !== _v.value || v.variable !== _v.variable) { + set({ build_args: parsed }); + return; + } + } + }; return ( + {!disabled && }