@@ -515,16 +515,63 @@ const Settings = () => {
515515
516516function SettingsPanel ( { childrenSettings, name, visible, id } ) {
517517 const [ shown , setShown ] = useState ( visible )
518+ const [ childShown , setChildShown ] = useState ( { } )
519+ const order = [ ]
520+ childrenSettings . forEach ( ( setting ) => {
521+ let template = DefaultSettings [ id ] [ setting ]
522+ if ( template . group ) {
523+ let g = order . find ( ( group ) => group . name === template . group ) || {
524+ type : 'group' ,
525+ name : template . group ,
526+ settings : [ ] ,
527+ translatableName : template . groupName ,
528+ }
529+ if ( ! order . includes ( g ) ) order . push ( g )
530+ g . settings . push ( setting )
531+ } else {
532+ order . push ( {
533+ type : 'setting' ,
534+ name : setting ,
535+ } )
536+ }
537+ } )
518538 return (
519539 < DropDown visible = { shown } onClick = { ( ) => setShown ( ! shown ) } name = { name } >
520540 < ul style = { { marginLeft : '2em' } } >
521- { childrenSettings . map ( ( child ) => (
522- < li key = { child } >
523- < SettingInput
524- namespace = { id }
525- name = { child }
526- template = { DefaultSettings [ id ] [ child ] }
527- > </ SettingInput >
541+ { order . map ( ( child ) => (
542+ < li key = { child . name } >
543+ { child . type === 'group' ? (
544+ < DropDown
545+ visible = { childShown [ child . name ] }
546+ name = { child . translatableName }
547+ onClick = { ( ) => {
548+ setChildShown ( {
549+ ...childShown ,
550+ [ child . name ] : ! childShown [ child . name ] ,
551+ } )
552+ } }
553+ >
554+ < ul style = { { marginLeft : '2em' } } >
555+ { child . settings . map ( ( setting ) => (
556+ < li key = { setting } >
557+ < SettingInput
558+ namespace = { id }
559+ name = { setting }
560+ template = {
561+ DefaultSettings [ id ] [ setting ]
562+ }
563+ > </ SettingInput >
564+ </ li >
565+ ) ) }
566+ </ ul >
567+ </ DropDown >
568+ ) : (
569+ < SettingInput
570+ namespace = { id }
571+ name = { child . name }
572+ template = { DefaultSettings [ id ] [ child . name ] }
573+ > </ SettingInput >
574+ ) }
528575 </ li >
529576 ) ) }
530577 </ ul >
0 commit comments