@@ -2,9 +2,11 @@ import styles from './Configurations.module.scss'
22import { DEFAULT_TEMPERATURE } from '@shared/constants/api-tools'
33import cn from 'classnames'
44import { dictionary } from '@shared/constants/dictionary'
5+ import { ReactSortable } from 'react-sortablejs'
56
67export namespace Configurations {
78 export type Configuration = {
9+ id : string
810 model : string
911 provider : string
1012 temperature ?: number
@@ -16,6 +18,7 @@ export namespace Configurations {
1618 api_mode : 'edit-context' | 'code-completions'
1719 configurations : Configuration [ ]
1820 on_configuration_click : ( i : number ) => void
21+ on_reorder ?: ( configurations : Configuration [ ] ) => void
1922 selected_configuration_index ?: number
2023 }
2124}
@@ -30,42 +33,69 @@ export const Configurations: React.FC<Configurations.Props> = (props) => {
3033 </ div >
3134
3235 < div className = { styles . configurations } >
33- { props . configurations . map ( ( configuration , i ) => {
34- const description_parts = [ configuration . provider ]
35- if ( configuration . reasoning_effort ) {
36- description_parts . push ( `${ configuration . reasoning_effort } ` )
37- }
38- if (
39- configuration . temperature &&
40- configuration . temperature != DEFAULT_TEMPERATURE [ props . api_mode ]
41- ) {
42- description_parts . push ( `${ configuration . temperature } ` )
43- }
44- if ( configuration . cache_enabled ) {
45- description_parts . push ( 'cache-enabled' )
46- }
36+ < ReactSortable
37+ list = { props . configurations }
38+ setList = { ( new_state ) => {
39+ if ( props . on_reorder ) {
40+ props . on_reorder ( new_state )
41+ }
42+ } }
43+ animation = { 150 }
44+ handle = { `.${ styles . configurations__item__left__drag_handle } ` }
45+ disabled = { ! props . on_reorder }
46+ >
47+ { props . configurations . map ( ( configuration , i ) => {
48+ const description_parts = [ configuration . provider ]
49+ if ( configuration . reasoning_effort ) {
50+ description_parts . push ( `${ configuration . reasoning_effort } ` )
51+ }
52+ if (
53+ configuration . temperature &&
54+ configuration . temperature != DEFAULT_TEMPERATURE [ props . api_mode ]
55+ ) {
56+ description_parts . push ( `${ configuration . temperature } ` )
57+ }
58+ if ( configuration . cache_enabled ) {
59+ description_parts . push ( 'cache-enabled' )
60+ }
4761
48- const description = description_parts . join ( ' · ' )
62+ const description = description_parts . join ( ' · ' )
4963
50- return (
51- < div
52- key = { i }
53- className = { cn ( styles . configurations__item , {
54- [ styles [ 'configurations__item--highlighted' ] ] :
55- props . selected_configuration_index == i
56- } ) }
57- onClick = { ( ) => {
58- props . on_configuration_click ( i )
59- } }
60- role = "button"
61- >
62- < div className = { styles . configurations__item__left } >
63- < span > { configuration . model } </ span >
64- < span > { description } </ span >
64+ return (
65+ < div
66+ key = { configuration . id }
67+ className = { cn ( styles . configurations__item , {
68+ [ styles [ 'configurations__item--highlighted' ] ] :
69+ props . selected_configuration_index == i
70+ } ) }
71+ onClick = { ( ) => {
72+ props . on_configuration_click ( i )
73+ } }
74+ role = "button"
75+ >
76+ < div className = { styles . configurations__item__left } >
77+ < div
78+ className = { cn (
79+ styles . configurations__item__left__drag_handle ,
80+ {
81+ [ styles [
82+ 'configurations__item__left__drag_handle--disabled'
83+ ] ] : ! props . on_reorder
84+ }
85+ ) }
86+ onClick = { ( e ) => e . stopPropagation ( ) }
87+ >
88+ < span className = "codicon codicon-gripper" />
89+ </ div >
90+ < div className = { styles . configurations__item__left__text } >
91+ < span > { configuration . model } </ span >
92+ < span > { description } </ span >
93+ </ div >
94+ </ div >
6595 </ div >
66- </ div >
67- )
68- } ) }
96+ )
97+ } ) }
98+ </ ReactSortable >
6999 </ div >
70100 </ div >
71101 )
0 commit comments