@@ -8,7 +8,7 @@ import { Group as UiGroup } from '@ui/components/editor/settings/Group/Group'
88import { Section as UiSection } from '@ui/components/editor/settings/Section'
99import { SortableList } from '@ui/components/editor/settings/SortableList'
1010import { IconButton } from '@ui/components/editor/common/IconButton'
11- import { Dropdown as UiDropdown } from '@ui/components/editor/common/Dropdown '
11+ import { DefaultConfigurationSelector } from '@ui/components/editor/settings/DefaultConfigurationSelector '
1212import { Textarea as UiTextarea } from '@ui/components/editor/common/Textarea'
1313import { Toggler as UiToggler } from '@ui/components/editor/common/Toggler'
1414import { Button as UiButton } from '@ui/components/editor/common/Button'
@@ -159,6 +159,7 @@ type Props = {
159159 tool_name : ToolType ,
160160 configuration_id : string | null
161161 ) => void
162+ on_select_default_config : ( tool_name : ToolType ) => void
162163 on_open_external_url : ( url : string ) => void
163164 scroll_to_section_on_load ?: NavItem
164165}
@@ -298,14 +299,6 @@ export const Home: React.FC<Props> = (props) => {
298299 handle_scroll_to_section ( item_id )
299300 }
300301
301- const config_options = [
302- { value : '' , label : t ( 'action.none' ) } ,
303- ...props . configurations . map ( ( c ) => ( {
304- value : c . id ,
305- label : `${ c . model } (${ c . description } )`
306- } ) )
307- ]
308-
309302 return (
310303 < div style = { { height : '100vh' } } >
311304 < UiLayout
@@ -563,16 +556,20 @@ export const Home: React.FC<Props> = (props) => {
563556 < UiGroup >
564557 < UiItem
565558 title = { t ( 'action.default-configuration' ) }
566- slot_right = {
567- < UiDropdown
568- options = { config_options }
569- value = { props . defaults [ 'intelligent-update' ] || '' }
570- onChange = { ( val ) =>
571- props . on_set_default_config (
572- 'intelligent-update' ,
573- val || null
574- )
559+ slot_below = {
560+ < DefaultConfigurationSelector
561+ value = { props . defaults [ 'intelligent-update' ] || null }
562+ configurations = { props . configurations }
563+ on_unset = { ( ) =>
564+ props . on_set_default_config ( 'intelligent-update' , null )
565+ }
566+ on_select = { ( ) =>
567+ props . on_select_default_config ( 'intelligent-update' )
575568 }
569+ translations = { {
570+ select_default : t ( 'action.select-default-configuration' ) ,
571+ unset : t ( 'action.unset-default' )
572+ } }
576573 />
577574 }
578575 />
@@ -636,13 +633,20 @@ export const Home: React.FC<Props> = (props) => {
636633 < UiGroup >
637634 < UiItem
638635 title = { t ( 'action.default-configuration' ) }
639- slot_right = {
640- < UiDropdown
641- options = { config_options }
642- value = { props . defaults [ 'code-at-cursor' ] || '' }
643- onChange = { ( val ) =>
644- props . on_set_default_config ( 'code-at-cursor' , val || null )
636+ slot_below = {
637+ < DefaultConfigurationSelector
638+ value = { props . defaults [ 'code-at-cursor' ] || null }
639+ configurations = { props . configurations }
640+ on_unset = { ( ) =>
641+ props . on_set_default_config ( 'code-at-cursor' , null )
642+ }
643+ on_select = { ( ) =>
644+ props . on_select_default_config ( 'code-at-cursor' )
645645 }
646+ translations = { {
647+ select_default : t ( 'action.select-default-configuration' ) ,
648+ unset : t ( 'action.unset-default' )
649+ } }
646650 />
647651 }
648652 />
@@ -673,16 +677,20 @@ export const Home: React.FC<Props> = (props) => {
673677 < UiGroup >
674678 < UiItem
675679 title = { t ( 'action.default-configuration' ) }
676- slot_right = {
677- < UiDropdown
678- options = { config_options }
679- value = { props . defaults [ 'find-relevant-files' ] || '' }
680- onChange = { ( val ) =>
681- props . on_set_default_config (
682- 'find-relevant-files' ,
683- val || null
684- )
680+ slot_below = {
681+ < DefaultConfigurationSelector
682+ value = { props . defaults [ 'find-relevant-files' ] || null }
683+ configurations = { props . configurations }
684+ on_unset = { ( ) =>
685+ props . on_set_default_config ( 'find-relevant-files' , null )
686+ }
687+ on_select = { ( ) =>
688+ props . on_select_default_config ( 'find-relevant-files' )
685689 }
690+ translations = { {
691+ select_default : t ( 'action.select-default-configuration' ) ,
692+ unset : t ( 'action.unset-default' )
693+ } }
686694 />
687695 }
688696 />
@@ -700,13 +708,20 @@ export const Home: React.FC<Props> = (props) => {
700708 < UiGroup >
701709 < UiItem
702710 title = { t ( 'action.default-configuration' ) }
703- slot_right = {
704- < UiDropdown
705- options = { config_options }
706- value = { props . defaults [ 'commit-messages' ] || '' }
707- onChange = { ( val ) =>
708- props . on_set_default_config ( 'commit-messages' , val || null )
711+ slot_below = {
712+ < DefaultConfigurationSelector
713+ value = { props . defaults [ 'commit-messages' ] || null }
714+ configurations = { props . configurations }
715+ on_unset = { ( ) =>
716+ props . on_set_default_config ( 'commit-messages' , null )
717+ }
718+ on_select = { ( ) =>
719+ props . on_select_default_config ( 'commit-messages' )
709720 }
721+ translations = { {
722+ select_default : t ( 'action.select-default-configuration' ) ,
723+ unset : t ( 'action.unset-default' )
724+ } }
710725 />
711726 }
712727 />
@@ -775,13 +790,20 @@ export const Home: React.FC<Props> = (props) => {
775790 < UiGroup >
776791 < UiItem
777792 title = { t ( 'action.default-configuration' ) }
778- slot_right = {
779- < UiDropdown
780- options = { config_options }
781- value = { props . defaults [ 'voice-input' ] || '' }
782- onChange = { ( val ) =>
783- props . on_set_default_config ( 'voice-input' , val || null )
793+ slot_below = {
794+ < DefaultConfigurationSelector
795+ value = { props . defaults [ 'voice-input' ] || null }
796+ configurations = { props . configurations }
797+ on_unset = { ( ) =>
798+ props . on_set_default_config ( 'voice-input' , null )
784799 }
800+ on_select = { ( ) =>
801+ props . on_select_default_config ( 'voice-input' )
802+ }
803+ translations = { {
804+ select_default : t ( 'action.select-default-configuration' ) ,
805+ unset : t ( 'action.unset-default' )
806+ } }
785807 />
786808 }
787809 />
0 commit comments