@@ -45,6 +45,7 @@ import * as Yup from "yup";
45
45
import type { CreateWorkspaceMode } from "./CreateWorkspacePage" ;
46
46
import { ExternalAuthButton } from "./ExternalAuthButton" ;
47
47
import type { CreateWorkspacePermissions } from "./permissions" ;
48
+ import { Combobox } from "components/Combobox/Combobox" ;
48
49
49
50
export const Language = {
50
51
duplicationWarning :
@@ -153,20 +154,21 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
153
154
) ;
154
155
155
156
const [ presetOptions , setPresetOptions ] = useState ( [
156
- { label : "None" , value : "" } ,
157
+ { displayName : "None" , value : "" , icon : "" , description : "" } ,
157
158
] ) ;
158
159
const [ selectedPresetIndex , setSelectedPresetIndex ] = useState ( 0 ) ;
159
160
// Build options and keep default label/value in sync
160
161
useEffect ( ( ) => {
161
162
const options = [
162
- { label : "None" , value : "" , icon : undefined , description : undefined } ,
163
+ { displayName : "None" , value : "" , icon : "" , description : "" } ,
163
164
...presets . map ( ( preset ) => ( {
164
- label : preset . Default ? `${ preset . Name } (Default)` : preset . Name ,
165
+ displayName : preset . Default ? `${ preset . Name } (Default)` : preset . Name ,
165
166
value : preset . ID ,
166
167
icon : preset . Icon ,
167
168
description : preset . Description ,
168
169
} ) ) ,
169
170
] ;
171
+ console . log ( options )
170
172
setPresetOptions ( options ) ;
171
173
const defaultPreset = presets . find ( ( p ) => p . Default ) ;
172
174
if ( defaultPreset ) {
@@ -382,49 +384,24 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
382
384
</ Stack >
383
385
< Stack direction = "column" spacing = { 2 } >
384
386
< Stack direction = "row" spacing = { 2 } >
385
- < MultiSelectCombobox
386
- inputProps = { { id : "preset-select" } }
387
+ < Combobox
388
+ value = { presetOptions [ selectedPresetIndex ] ?. displayName || "" } // Single selected value
387
389
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
- ) ;
390
+ placeholder = "Select a preset"
391
+ onSelect = { ( value ) => {
392
+ // value is a single string, not an array
393
+ const index = presetOptions . findIndex (
394
+ ( preset ) => preset . value === value ,
395
+ ) ;
396
+ if ( index === - 1 ) {
397
+ return ;
418
398
}
399
+ setSelectedPresetIndex ( index ) ;
400
+ form . setFieldValue (
401
+ "template_version_preset_id" ,
402
+ presetOptions [ index ] . value === "" ? undefined : presetOptions [ index ] . value ,
403
+ ) ;
419
404
} }
420
- hidePlaceholderWhenSelected
421
- 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 }
428
405
/>
429
406
</ Stack >
430
407
{ /* Only show the preset parameter visibility toggle if preset parameters are actually being modified, otherwise it has no effect. */ }
0 commit comments