mirror of
https://github.com/moghtech/komodo.git
synced 2026-03-11 17:44:19 -05:00
give placeholders
This commit is contained in:
@@ -71,6 +71,8 @@ export const ConfigLayout = <
|
||||
);
|
||||
};
|
||||
|
||||
type PrimitiveConfigArgs = { placeholder: string };
|
||||
|
||||
export const Config = <T,>({
|
||||
config,
|
||||
update,
|
||||
@@ -95,6 +97,7 @@ export const Config = <T,>({
|
||||
{
|
||||
[K in keyof Partial<T>]:
|
||||
| boolean
|
||||
| PrimitiveConfigArgs
|
||||
| ((value: T[K], set: (value: Partial<T>) => 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<T>) => void) => ReactNode);
|
||||
}>;
|
||||
set: (value: Partial<T>) => 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 (
|
||||
<Fragment key={key.toString()}>{component?.(value, set)}</Fragment>
|
||||
);
|
||||
} 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<T>)}
|
||||
disabled={disabled}
|
||||
placeholder={args?.placeholder}
|
||||
/>
|
||||
);
|
||||
case "number":
|
||||
@@ -216,6 +226,7 @@ export const ConfigAgain = <
|
||||
set({ [key]: Number(value) } as Partial<T>)
|
||||
}
|
||||
disabled={disabled}
|
||||
placeholder={args?.placeholder}
|
||||
/>
|
||||
);
|
||||
case "boolean":
|
||||
@@ -234,9 +245,7 @@ export const ConfigAgain = <
|
||||
} else if (component === false) {
|
||||
return <Fragment key={key.toString()} />;
|
||||
}
|
||||
return (
|
||||
<Fragment key={key.toString()}>{component?.(value, set)}</Fragment>
|
||||
);
|
||||
|
||||
})}
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -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) => (
|
||||
<AccountSelector
|
||||
id={update.builder_id ?? config.builder_id ?? undefined}
|
||||
|
||||
@@ -40,9 +40,9 @@ export const RepoConfig = ({ id }: { id: string }) => {
|
||||
),
|
||||
},
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user