-
Notifications
You must be signed in to change notification settings - Fork 894
feat: setup url autofill for dynamic parameters #17739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4209d7d
feat: setup autofill for dynamic parameters
jaaydenh 1d798ea
chore: cleanup
jaaydenh 9d10195
feat: set initial param values from autofill
jaaydenh ec35a7f
fix: setup ParameterLabel to use htmlfor
jaaydenh 04c7f83
chore: change autofill to boolean
jaaydenh 03dde8a
chore: updates for PR review comments
jaaydenh afdab85
chore: move logic for sending initial parameters to websocket
jaaydenh a76159f
fix: improvements to dynamic parameter handling
jaaydenh 6711e28
fix: updates for PR review
jaaydenh 7dc96bb
fix: update logic for onMessage
jaaydenh eb413fb
fix: format
jaaydenh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: setup ParameterLabel to use htmlfor
- Loading branch information
commit ec35a7f4bd47383b88cea03000c90c7ec1c62d4f
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,7 @@ export const DynamicParameter: FC<DynamicParameterProps> = ({ | |
data-testid={`parameter-field-${parameter.name}`} | ||
> | ||
<ParameterLabel | ||
id={id} | ||
parameter={parameter} | ||
isPreset={isPreset} | ||
autofill={autofill} | ||
|
@@ -86,12 +87,14 @@ interface ParameterLabelProps { | |
parameter: PreviewParameter; | ||
isPreset?: boolean; | ||
autofill?: AutofillBuildParameter; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this is only being used for a truthy check to influence the conditional rendering, can we replace this with an |
||
id: string; | ||
} | ||
|
||
const ParameterLabel: FC<ParameterLabelProps> = ({ | ||
parameter, | ||
isPreset, | ||
autofill, | ||
id, | ||
}) => { | ||
const hasDescription = parameter.description && parameter.description !== ""; | ||
jaaydenh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const displayName = parameter.display_name | ||
|
@@ -109,7 +112,10 @@ const ParameterLabel: FC<ParameterLabelProps> = ({ | |
)} | ||
|
||
<div className="flex flex-col w-full gap-1"> | ||
<Label className="flex gap-2 flex-wrap text-sm font-medium"> | ||
<Label | ||
htmlFor={id} | ||
className="flex gap-2 flex-wrap text-sm font-medium" | ||
> | ||
<span className="flex"> | ||
{displayName} | ||
{parameter.required && ( | ||
|
@@ -197,15 +203,12 @@ const ParameterField: FC<ParameterFieldProps> = ({ | |
disabled, | ||
id, | ||
}) => { | ||
const initialValue = | ||
value !== undefined ? value : validValue(parameter.value); | ||
const [localValue, setLocalValue] = useState(initialValue); | ||
|
||
useEffect(() => { | ||
if (value !== undefined) { | ||
setLocalValue(value); | ||
} | ||
}, [value]); | ||
const [localValue, setLocalValue] = useState( | ||
value !== undefined ? value : validValue(parameter.value) | ||
); | ||
if (value !== undefined && value !== localValue) { | ||
setLocalValue(value); | ||
} | ||
|
||
switch (parameter.form_type) { | ||
case "dropdown": | ||
|
@@ -216,7 +219,7 @@ const ParameterField: FC<ParameterFieldProps> = ({ | |
disabled={disabled} | ||
required={parameter.required} | ||
> | ||
<SelectTrigger> | ||
<SelectTrigger id={id}> | ||
<SelectValue | ||
placeholder={parameter.styling?.placeholder || "Select option"} | ||
/> | ||
|
@@ -256,7 +259,7 @@ const ParameterField: FC<ParameterFieldProps> = ({ | |
return ( | ||
<MultiSelectCombobox | ||
inputProps={{ | ||
id: `${id}-${parameter.name}`, | ||
id: id, | ||
}} | ||
options={options} | ||
defaultOptions={selectedOptions} | ||
|
@@ -281,7 +284,7 @@ const ParameterField: FC<ParameterFieldProps> = ({ | |
|
||
return ( | ||
<TagInput | ||
id={parameter.name} | ||
id={id} | ||
label={parameter.display_name || parameter.name} | ||
values={values} | ||
onChange={(values) => { | ||
|
@@ -294,6 +297,7 @@ const ParameterField: FC<ParameterFieldProps> = ({ | |
case "switch": | ||
return ( | ||
<Switch | ||
id={id} | ||
checked={value === "true"} | ||
onCheckedChange={(checked) => { | ||
onChange(checked ? "true" : "false"); | ||
|
@@ -329,23 +333,24 @@ const ParameterField: FC<ParameterFieldProps> = ({ | |
return ( | ||
<div className="flex items-center space-x-2"> | ||
<Checkbox | ||
id={parameter.name} | ||
id={id} | ||
checked={value === "true"} | ||
onCheckedChange={(checked) => { | ||
onChange(checked ? "true" : "false"); | ||
}} | ||
disabled={disabled} | ||
/> | ||
<Label htmlFor={parameter.name}>{parameter.styling?.label}</Label> | ||
<Label htmlFor={id}>{parameter.styling?.label}</Label> | ||
</div> | ||
); | ||
|
||
case "slider": | ||
return ( | ||
<div className="flex flex-row items-baseline gap-3"> | ||
<Slider | ||
id={id} | ||
className="mt-2" | ||
value={[Number(localValue ?? 0)]} | ||
value={[Number(localValue)]} | ||
onValueChange={([value]) => { | ||
setLocalValue(value.toString()); | ||
onChange(value.toString()); | ||
|
@@ -361,6 +366,7 @@ const ParameterField: FC<ParameterFieldProps> = ({ | |
case "textarea": | ||
return ( | ||
<Textarea | ||
id={id} | ||
className="max-w-2xl" | ||
value={localValue} | ||
onChange={(e) => { | ||
|
@@ -397,6 +403,7 @@ const ParameterField: FC<ParameterFieldProps> = ({ | |
|
||
return ( | ||
<Input | ||
id={id} | ||
type={inputType} | ||
value={localValue} | ||
onChange={(e) => { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.