@@ -6,14 +6,14 @@ import { Alert } from "components/Alert/Alert";
6
6
import { ErrorAlert } from "components/Alert/ErrorAlert" ;
7
7
import { Avatar } from "components/Avatar/Avatar" ;
8
8
import { Button } from "components/Button/Button" ;
9
+ import { SelectFilter } from "components/Filter/SelectFilter" ;
9
10
import {
10
11
FormFields ,
11
12
FormFooter ,
12
13
FormSection ,
13
14
HorizontalForm ,
14
15
} from "components/Form/Form" ;
15
16
import { Margins } from "components/Margins/Margins" ;
16
- import { MultiSelectCombobox } from "components/MultiSelectCombobox/MultiSelectCombobox" ;
17
17
import {
18
18
PageHeader ,
19
19
PageHeaderSubtitle ,
@@ -159,12 +159,10 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
159
159
// Build options and keep default label/value in sync
160
160
useEffect ( ( ) => {
161
161
const options = [
162
- { label : "None" , value : "" , icon : undefined , description : undefined } ,
163
- ...presets . map ( ( preset ) => ( {
164
- label : preset . Default ? `${ preset . Name } (Default)` : preset . Name ,
165
- value : preset . ID ,
166
- icon : preset . Icon ,
167
- description : preset . Description ,
162
+ { label : "None" , value : "" } ,
163
+ ...presets . map ( ( p ) => ( {
164
+ label : p . Default ? `${ p . Name } (Default)` : p . Name ,
165
+ value : p . ID ,
168
166
} ) ) ,
169
167
] ;
170
168
setPresetOptions ( options ) ;
@@ -382,49 +380,25 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
382
380
</ Stack >
383
381
< Stack direction = "column" spacing = { 2 } >
384
382
< Stack direction = "row" spacing = { 2 } >
385
- < MultiSelectCombobox
386
- inputProps = { { id : "preset-select" } }
383
+ < SelectFilter
384
+ label = "Preset"
387
385
options = { presetOptions }
388
- defaultOptions = { presetOptions }
389
- value = {
390
- presetOptions [ selectedPresetIndex ]
391
- ? [ presetOptions [ selectedPresetIndex ] ]
392
- : [ ]
393
- }
394
- onChange = { ( option ) => {
395
- // Handle single selection replacement
396
- if ( option . length > 0 ) {
397
- // Take the most recently selected option
398
- const selectedOption = option [ option . length - 1 ] ;
399
- const index = presetOptions . findIndex (
400
- ( preset ) => preset . value === selectedOption . value ,
401
- ) ;
402
- if ( index !== - 1 ) {
403
- setSelectedPresetIndex ( index ) ;
404
- form . setFieldValue (
405
- "template_version_preset_id" ,
406
- selectedOption . value === ""
407
- ? undefined
408
- : selectedOption . value ,
409
- ) ;
410
- }
411
- } else {
412
- // None preset selected
413
- setSelectedPresetIndex ( 0 ) ;
414
- form . setFieldValue (
415
- "template_version_preset_id" ,
416
- undefined ,
417
- ) ;
386
+ onSelect = { ( option ) => {
387
+ const index = presetOptions . findIndex (
388
+ ( preset ) => preset . value === option ?. value ,
389
+ ) ;
390
+ if ( index === - 1 ) {
391
+ return ;
418
392
}
393
+ setSelectedPresetIndex ( index ) ;
394
+ form . setFieldValue (
395
+ "template_version_preset_id" ,
396
+ // Empty string is equivalent to using None
397
+ option ?. value === "" ? undefined : option ?. value ,
398
+ ) ;
419
399
} }
420
- hidePlaceholderWhenSelected
421
400
placeholder = "Select a preset"
422
- emptyIndicator = {
423
- < p className = "text-center text-md text-content-primary" >
424
- No presets found
425
- </ p >
426
- }
427
- disabled = { false }
401
+ selectedOption = { presetOptions [ selectedPresetIndex ] }
428
402
/>
429
403
</ Stack >
430
404
{ /* Only show the preset parameter visibility toggle if preset parameters are actually being modified, otherwise it has no effect. */ }
0 commit comments