Skip to content

Commit

Permalink
Console: SchemaForm support for more date formats
Browse files Browse the repository at this point in the history
  • Loading branch information
absorbb committed Nov 8, 2024
1 parent 453f6eb commit 3d39d85
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
11 changes: 9 additions & 2 deletions webapps/console/components/ConfigObjectEditor/Editors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,18 @@ export const StringArray: React.FC<{ options?: string[] } & CustomWidgetProps<st
);
};

export const TextEditor: React.FC<{ rows?: number } & CustomWidgetProps<string>> = props => {
export const TextEditor: React.FC<{ rows?: number; placeholder?: string } & CustomWidgetProps<string>> = props => {
if (props.rows && props.rows > 1) {
return <Input.TextArea rows={props.rows} value={props.value} onChange={e => props.onChange(e.target.value)} />;
} else {
return <Input type="text" value={props.value} onChange={e => props.onChange(e.target.value)} />;
return (
<Input
placeholder={props.placeholder}
type="text"
value={props.value}
onChange={e => props.onChange(e.target.value)}
/>
);
}
};

Expand Down
6 changes: 6 additions & 0 deletions webapps/console/components/ConfigObjectEditor/SchemaForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ export const SchemaForm: React.FC<{
case "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{6}Z$":
format = "YYYY-MM-DDTHH:mm:ss.SSSSSS[Z]";
break;
case "^\\d{4}-\\d{2}-\\d{2}[T ]\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z?$":
case "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z?$":
format = "YYYY-MM-DDTHH:mm:ss.SSSSSS[Z]";
break;
default:
return <TextEditor placeholder={f.examples?.[0]} {...editorProps} />;
}
return <DateEditor format={format} {...editorProps} />;
}
Expand Down

0 comments on commit 3d39d85

Please sign in to comment.