- Notifications
You must be signed in to change notification settings - Fork1k
chore(site): add preset combobox to dynamic parameters page#19100
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -5,16 +5,10 @@ import { ErrorAlert } from "components/Alert/ErrorAlert"; | ||
import { Avatar } from "components/Avatar/Avatar"; | ||
import { Badge } from "components/Badge/Badge"; | ||
import { Button } from "components/Button/Button"; | ||
import { Combobox } from "components/Combobox/Combobox"; | ||
import { Input } from "components/Input/Input"; | ||
import { Label } from "components/Label/Label"; | ||
import { Link } from "components/Link/Link"; | ||
import { Spinner } from "components/Spinner/Spinner"; | ||
import { Switch } from "components/Switch/Switch"; | ||
import { | ||
@@ -186,30 +180,31 @@ export const CreateWorkspacePageViewExperimental: FC< | ||
}, [form.submitCount, form.errors]); | ||
const [presetOptions, setPresetOptions] = useState([ | ||
{displayName: "None", value: "undefined", icon: "", description: "" }, | ||
]); | ||
const [selectedPresetIndex, setSelectedPresetIndex] = useState(0); | ||
// Build options and keep default label/value in sync | ||
useEffect(() => { | ||
const options =[ | ||
{displayName: "None", value: "undefined", icon: "", description: "" }, | ||
...presets.map((preset) => ({ | ||
displayName: preset.Default ? `${preset.Name} (Default)` : preset.Name, | ||
value: preset.ID, | ||
icon: preset.Icon, | ||
description: preset.Description, | ||
})), | ||
]; | ||
setPresetOptions(options); | ||
const defaultPreset = presets.find((p) => p.Default); | ||
if (defaultPreset) { | ||
const idx = presets.indexOf(defaultPreset) + 1; // +1 for "None" | ||
setSelectedPresetIndex(idx); | ||
form.setFieldValue("template_version_preset_id", defaultPreset.ID); | ||
} else { | ||
setSelectedPresetIndex(0); // Explicitly set to "None" | ||
form.setFieldValue("template_version_preset_id", undefined); | ||
} | ||
}, [presets, form.setFieldValue]); | ||
const [presetParameterNames, setPresetParameterNames] = useState<string[]>( | ||
[], | ||
@@ -572,33 +567,30 @@ export const CreateWorkspacePageViewExperimental: FC< | ||
</div> | ||
<div className="flex flex-col gap-4"> | ||
<div className="max-w-lg"> | ||
<Combobox | ||
value={ | ||
presetOptions[selectedPresetIndex]?.displayName || "" | ||
} | ||
options={presetOptions} | ||
placeholder="Select a preset" | ||
onSelect={(value) => { | ||
const index = presetOptions.findIndex( | ||
(preset) => preset.value ===value, | ||
); | ||
if (index === -1) { | ||
return; | ||
} | ||
setSelectedPresetIndex(index); | ||
form.setFieldValue( | ||
"template_version_preset_id", | ||
// "undefined" string is equivalent to using None option | ||
// Combobox requires a value in order to correctly highlight the None option | ||
presetOptions[index].value === "undefined" | ||
? undefined | ||
: presetOptions[index].value, | ||
Comment on lines +586 to +590 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. sorry to keep bringing up merged pull requests, but couldn't 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. @aslilac Ideally, yes, it should be an empty string. However, this appears to be an issue with the @jaaydenh helped me investigate this and came up with the workaround, so he may have more context. I've included a recording below showing the difference:
Screen.Recording.2025-08-04.at.16.09.20.mov
Screen.Recording.2025-08-04.at.16.10.17.mov | ||
); | ||
}} | ||
/> | ||
</div> | ||
{/* Only show the preset parameter visibility toggle if preset parameters are actually being modified, otherwise it is ineffectual */} | ||
{presetParameterNames.length > 0 && ( | ||
Uh oh!
There was an error while loading.Please reload this page.