diff --git a/frontend/src/components/config/index.tsx b/frontend/src/components/config/index.tsx index 329daed45..985286dd4 100644 --- a/frontend/src/components/config/index.tsx +++ b/frontend/src/components/config/index.tsx @@ -71,6 +71,8 @@ export const ConfigLayout = < ); }; +type PrimitiveConfigArgs = { placeholder: string }; + export const Config = ({ config, update, @@ -95,6 +97,7 @@ export const Config = ({ { [K in keyof Partial]: | boolean + | PrimitiveConfigArgs | ((value: T[K], set: (value: Partial) => void) => ReactNode); } > @@ -185,6 +188,7 @@ export const ConfigAgain = < components: Partial<{ [K in keyof T extends string ? keyof T : never]: | boolean + | PrimitiveConfigArgs | ((value: T[K], set: (value: Partial) => void) => ReactNode); }>; set: (value: Partial) => void; @@ -194,7 +198,12 @@ export const ConfigAgain = < {keys(components).map((key) => { const component = components[key]; const value = update[key] ?? config[key]; - if (component === true) { + if (typeof component === "function") { + return ( + {component?.(value, set)} + ); + } else if (typeof component === "object" || component === true) { + const args = (typeof component === "object") ? component as PrimitiveConfigArgs : undefined; switch (typeof value) { case "string": return ( @@ -204,6 +213,7 @@ export const ConfigAgain = < value={value} onChange={(value) => set({ [key]: value } as Partial)} disabled={disabled} + placeholder={args?.placeholder} /> ); case "number": @@ -216,6 +226,7 @@ export const ConfigAgain = < set({ [key]: Number(value) } as Partial) } disabled={disabled} + placeholder={args?.placeholder} /> ); case "boolean": @@ -234,9 +245,7 @@ export const ConfigAgain = < } else if (component === false) { return ; } - return ( - {component?.(value, set)} - ); + })} ); diff --git a/frontend/src/components/resources/build/config.tsx b/frontend/src/components/resources/build/config.tsx index ffca1c465..a317cba3a 100644 --- a/frontend/src/components/resources/build/config.tsx +++ b/frontend/src/components/resources/build/config.tsx @@ -98,9 +98,9 @@ export const BuildConfig = ({ id }: { id: string }) => { ), }, git: { - repo: true, - branch: true, - commit: true, + repo: { placeholder: "Enter repo" }, + branch: { placeholder: "Enter branch" }, + commit: { placeholder: "Enter specific commit hash. Optional." }, github_account: (account, set) => ( { ), }, general: { - repo: true, - branch: true, - commit: true, + repo: { placeholder: "Enter repo" }, + branch: { placeholder: "Enter branch" }, + commit: { placeholder: "Enter specific commit hash. Optional." }, github_account: (value, set) => { const server_id = update.server_id || config.server_id; if (server_id) {