@@ -2,98 +2,39 @@ import cn from 'bem-cn-lite';
22
33import { Settings } from '@gravity-ui/navigation' ;
44
5- import favoriteFilledIcon from '../../assets/icons/star.svg' ;
6- import flaskIcon from '../../assets/icons/flask.svg' ;
7-
8- import {
9- ENABLE_QUERY_MODES_FOR_EXPLAIN ,
10- INVERTED_DISKS_KEY ,
11- THEME_KEY ,
12- USE_NODES_ENDPOINT_IN_DIAGNOSTICS_KEY ,
13- } from '../../utils/constants' ;
14-
15- import { Setting , SettingProps } from './Setting' ;
16- import i18n from './i18n' ;
5+ import { YDBEmbeddedUISettings , settings } from './settings' ;
6+ import { Setting } from './Setting' ;
177
188import './UserSettings.scss' ;
199
2010export const b = cn ( 'ydb-user-settings' ) ;
2111
22- enum Theme {
23- light = 'light' ,
24- dark = 'dark' ,
25- system = 'system' ,
26- }
27-
28- const themeValues = [
29- {
30- value : Theme . system ,
31- content : i18n ( 'settings.theme.option-system' ) ,
32- } ,
33- {
34- value : Theme . light ,
35- content : i18n ( 'settings.theme.option-light' ) ,
36- } ,
37- {
38- value : Theme . dark ,
39- content : i18n ( 'settings.theme.option-dark' ) ,
40- } ,
41- ] ;
42-
43- export enum SettingsSection {
44- general = 'general' ,
45- experiments = 'experiments' ,
46- }
47-
4812interface UserSettingsProps {
49- settings ?: Partial < Record < SettingsSection , SettingProps [ ] > > ;
13+ settings ?: YDBEmbeddedUISettings ;
5014}
5115
52- export const UserSettings = ( { settings} : UserSettingsProps ) => {
16+ export const UserSettings = ( { settings : userSettings = settings } : UserSettingsProps ) => {
5317 return (
5418 < Settings >
55- < Settings . Page
56- id = { SettingsSection . general }
57- title = { i18n ( 'page.general' ) }
58- icon = { { data : favoriteFilledIcon , height : 14 , width : 14 } }
59- >
60- < Settings . Section title = { i18n ( 'section.general' ) } >
61- < Setting
62- settingKey = { THEME_KEY }
63- title = { i18n ( 'settings.theme.title' ) }
64- type = "radio"
65- values = { themeValues }
66- />
67- { settings ?. [ SettingsSection . general ] ?. map ( ( setting ) => (
68- < Setting key = { setting . settingKey } { ...setting } />
69- ) ) }
70- </ Settings . Section >
71- </ Settings . Page >
72- < Settings . Page
73- id = { SettingsSection . experiments }
74- title = { i18n ( 'page.experiments' ) }
75- icon = { { data : flaskIcon } }
76- >
77- < Settings . Section title = { i18n ( 'section.experiments' ) } >
78- < Setting
79- settingKey = { INVERTED_DISKS_KEY }
80- title = { i18n ( 'settings.invertedDisks.title' ) }
81- />
82- < Setting
83- settingKey = { USE_NODES_ENDPOINT_IN_DIAGNOSTICS_KEY }
84- title = { i18n ( 'settings.useNodesEndpoint.title' ) }
85- helpPopoverContent = { i18n ( 'settings.useNodesEndpoint.popover' ) }
86- />
87- < Setting
88- settingKey = { ENABLE_QUERY_MODES_FOR_EXPLAIN }
89- title = { i18n ( 'settings.enableQueryModesForExplain.title' ) }
90- helpPopoverContent = { i18n ( 'settings.enableQueryModesForExplain.popover' ) }
91- />
92- { settings ?. [ SettingsSection . experiments ] ?. map ( ( setting ) => (
93- < Setting key = { setting . settingKey } { ...setting } />
94- ) ) }
95- </ Settings . Section >
96- </ Settings . Page >
19+ { userSettings . map ( ( page ) => {
20+ const { id, title, icon, sections = [ ] } = page ;
21+
22+ return (
23+ < Settings . Page key = { id } id = { id } title = { title } icon = { icon } >
24+ { sections . map ( ( section ) => {
25+ const { title : sectionTitle , settings : sectionSettings = [ ] } = section ;
26+
27+ return (
28+ < Settings . Section key = { id } title = { sectionTitle } >
29+ { sectionSettings . map ( ( setting ) => {
30+ return < Setting key = { setting . settingKey } { ...setting } /> ;
31+ } ) }
32+ </ Settings . Section >
33+ ) ;
34+ } ) }
35+ </ Settings . Page >
36+ ) ;
37+ } ) }
9738 </ Settings >
9839 ) ;
9940} ;
0 commit comments