ydb-embedded-ui 4.25.0 → 4.27.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +39 -0
  3. package/dist/components/BasicNodeViewer/BasicNodeViewer.scss +3 -11
  4. package/dist/components/CircularProgressBar/CircularProgressBar.scss +4 -4
  5. package/dist/components/DateRange/DateRange.scss +3 -3
  6. package/dist/components/DiagnosticCard/DiagnosticCard.scss +4 -4
  7. package/dist/components/Divider/Divider.scss +1 -1
  8. package/dist/components/EmptyState/EmptyState.scss +8 -9
  9. package/dist/components/EntityStatus/EntityStatus.scss +19 -29
  10. package/dist/components/ExternalLinkWithIcon/ExternalLinkWithIcon.tsx +2 -2
  11. package/dist/components/FullNodeViewer/FullNodeViewer.scss +1 -4
  12. package/dist/components/Fullscreen/Fullscreen.scss +2 -9
  13. package/dist/components/Icon/Icon.tsx +1 -5
  14. package/dist/components/InfoViewer/InfoViewer.scss +6 -6
  15. package/dist/components/LabelWithPopover/LabelWithPopover.tsx +3 -2
  16. package/dist/components/NodeHostWrapper/NodeHostWrapper.tsx +2 -2
  17. package/dist/components/PoolBar/PoolBar.scss +6 -6
  18. package/dist/components/PoolUsage/PoolUsage.scss +15 -17
  19. package/dist/components/ProgressViewer/ProgressViewer.scss +17 -16
  20. package/dist/components/QueryExecutionStatus/QueryExecutionStatus.scss +3 -3
  21. package/dist/components/SpeedMultiMeter/SpeedMultiMeter.scss +5 -5
  22. package/dist/components/SpeedMultiMeter/SpeedMultiMeter.tsx +12 -13
  23. package/dist/components/SplitPane/SplitPane.scss +5 -5
  24. package/dist/components/TableSkeleton/TableSkeleton.scss +1 -1
  25. package/dist/components/Tablet/Tablet.scss +10 -10
  26. package/dist/components/TabletsStatistic/TabletsStatistic.scss +13 -13
  27. package/dist/components/Tag/Tag.scss +3 -3
  28. package/dist/components/TruncatedQuery/TruncatedQuery.scss +1 -1
  29. package/dist/components/UsageLabel/UsageLabel.scss +2 -2
  30. package/dist/components/UsageLabel/UsageLabel.tsx +1 -1
  31. package/dist/components/VirtualTable/VirtualTable.scss +3 -3
  32. package/dist/containers/App/App.scss +20 -24
  33. package/dist/containers/App/Content.js +5 -4
  34. package/dist/containers/AsideNavigation/AsideNavigation.scss +1 -4
  35. package/dist/containers/AsideNavigation/AsideNavigation.tsx +12 -27
  36. package/dist/containers/Authentication/Authentication.scss +4 -4
  37. package/dist/containers/Cluster/ClusterInfo/ClusterInfo.scss +4 -6
  38. package/dist/containers/Cluster/ClusterInfo/ClusterInfo.tsx +1 -1
  39. package/dist/containers/Cluster/ClusterInfoSkeleton/ClusterInfoSkeleton.scss +3 -3
  40. package/dist/containers/Cluster/VersionsBar/VersionsBar.tsx +1 -1
  41. package/dist/containers/Header/Header.scss +1 -1
  42. package/dist/containers/Heatmap/Heatmap.scss +3 -5
  43. package/dist/containers/Heatmap/Histogram/Histogram.scss +6 -6
  44. package/dist/containers/Node/NodeStructure/NodeStructure.scss +10 -13
  45. package/dist/containers/Node/NodeStructure/Pdisk.tsx +1 -1
  46. package/dist/containers/ReduxTooltip/ReduxTooltip.js +1 -1
  47. package/dist/containers/ReduxTooltip/ReduxTooltip.scss +1 -18
  48. package/dist/containers/Storage/DiskStateProgressBar/DiskStateProgressBar.scss +23 -23
  49. package/dist/containers/Storage/PDisk/PDisk.scss +4 -4
  50. package/dist/containers/Storage/PDiskPopup/PDiskPopup.tsx +1 -1
  51. package/dist/containers/Storage/Storage.scss +1 -1
  52. package/dist/containers/Storage/StorageGroups/StorageGroups.scss +1 -1
  53. package/dist/containers/Storage/UsageFilter/UsageFilter.scss +7 -6
  54. package/dist/containers/Storage/VDiskPopup/VDiskPopup.scss +1 -1
  55. package/dist/containers/Storage/VDiskPopup/VDiskPopup.tsx +1 -1
  56. package/dist/containers/Tablet/Tablet.scss +5 -5
  57. package/dist/containers/TabletsFilters/TabletsFilters.scss +2 -3
  58. package/dist/containers/Tenant/Acl/Acl.scss +1 -15
  59. package/dist/containers/Tenant/Diagnostics/Consumers/Consumers.scss +0 -4
  60. package/dist/containers/Tenant/Diagnostics/Consumers/TopicStats/ConsumersTopicStats.scss +5 -4
  61. package/dist/containers/Tenant/Diagnostics/DetailedOverview/DetailedOverview.scss +0 -6
  62. package/dist/containers/Tenant/Diagnostics/Diagnostics.scss +2 -2
  63. package/dist/containers/Tenant/Diagnostics/HotKeys/HotKeys.scss +2 -2
  64. package/dist/containers/Tenant/Diagnostics/Network/Network.scss +8 -10
  65. package/dist/containers/Tenant/Diagnostics/Network/NodeNetwork/NodeNetwork.scss +8 -8
  66. package/dist/containers/Tenant/Diagnostics/Partitions/Partitions.scss +1 -5
  67. package/dist/containers/Tenant/Diagnostics/Partitions/Partitions.tsx +1 -4
  68. package/dist/containers/Tenant/Diagnostics/Partitions/PartitionsControls/PartitionsControls.tsx +0 -1
  69. package/dist/containers/Tenant/Diagnostics/TenantOverview/Healthcheck/Healthcheck.scss +12 -12
  70. package/dist/containers/Tenant/Diagnostics/TenantOverview/Healthcheck/IssuesViewer/IssueTree.scss +1 -36
  71. package/dist/containers/Tenant/Diagnostics/TenantOverview/Healthcheck/IssuesViewer/IssueTreeItem/IssueTreeItem.scss +3 -3
  72. package/dist/containers/Tenant/Diagnostics/TenantOverview/MetricsCards/MetricCard/MetricCard.scss +7 -7
  73. package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantOverview.scss +2 -2
  74. package/dist/containers/Tenant/Diagnostics/TopShards/TopShards.scss +1 -1
  75. package/dist/containers/Tenant/ObjectSummary/ObjectSummary.scss +4 -8
  76. package/dist/containers/Tenant/ObjectSummary/ObjectSummary.tsx +2 -1
  77. package/dist/containers/Tenant/Query/ExecuteResult/ExecuteResult.scss +3 -6
  78. package/dist/containers/Tenant/Query/ExplainResult/ExplainResult.scss +2 -5
  79. package/dist/containers/Tenant/Query/Issues/Issues.scss +11 -14
  80. package/dist/containers/Tenant/Query/Preview/Preview.scss +3 -7
  81. package/dist/containers/Tenant/Query/QueryDuration/QueryDuration.scss +1 -1
  82. package/dist/containers/Tenant/Query/QueryEditor/QueryEditor.js +4 -8
  83. package/dist/containers/Tenant/Query/QueryEditor/QueryEditor.scss +3 -9
  84. package/dist/containers/Tenant/Query/QueryEditorControls/QueryEditorControls.scss +0 -9
  85. package/dist/containers/Tenant/Query/QueryEditorControls/QueryEditorControls.tsx +11 -13
  86. package/dist/containers/Tenant/Query/SaveQuery/SaveQuery.scss +5 -5
  87. package/dist/containers/Tenant/Query/SavedQueries/SavedQueries.tsx +3 -3
  88. package/dist/containers/Tenant/Tenant.scss +1 -2
  89. package/dist/containers/Tenant/utils/schemaControls.tsx +2 -2
  90. package/dist/containers/UserSettings/Setting.tsx +5 -1
  91. package/dist/containers/Versions/GroupedNodesTree/GroupedNodesTree.scss +2 -3
  92. package/dist/containers/Versions/NodesTreeTitle/NodesTreeTitle.scss +1 -1
  93. package/dist/containers/Versions/NodesTreeTitle/NodesTreeTitle.tsx +1 -1
  94. package/dist/index.tsx +1 -0
  95. package/dist/services/api.ts +4 -3
  96. package/dist/services/settings.ts +113 -0
  97. package/dist/store/reducers/executeQuery.ts +6 -3
  98. package/dist/store/reducers/settings/settings.ts +7 -74
  99. package/dist/store/reducers/settings/types.ts +4 -3
  100. package/dist/styles/mixins.scss +37 -35
  101. package/dist/styles/themes/dark-hc.scss +296 -0
  102. package/dist/styles/themes/dark.scss +297 -0
  103. package/dist/styles/themes/light-hc.scss +289 -0
  104. package/dist/styles/themes/light.scss +291 -0
  105. package/dist/styles/themes.scss +73 -0
  106. package/dist/types/window.d.ts +2 -2
  107. package/dist/utils/hooks/useSetting.ts +6 -7
  108. package/dist/utils/i18n/i18n.ts +2 -2
  109. package/package.json +7 -6
  110. package/dist/containers/App/TipPopup/TipPopup.js +0 -66
  111. package/dist/containers/App/TipPopup/TipPopup.scss +0 -46
  112. package/dist/utils/settings.ts +0 -13
@@ -92,19 +92,17 @@ export const QueryEditorControls = ({
92
92
  return (
93
93
  <div className={b()}>
94
94
  <div className={b('left')}>
95
- <div className={b('run')}>
96
- <Button
97
- onClick={() => {
98
- onRunButtonClick(queryMode);
99
- }}
100
- disabled={disabled}
101
- loading={runIsLoading}
102
- view={runView}
103
- >
104
- <Icon name="startPlay" viewBox="0 0 16 16" width={16} height={16} />
105
- {'Run'}
106
- </Button>
107
- </div>
95
+ <Button
96
+ onClick={() => {
97
+ onRunButtonClick(queryMode);
98
+ }}
99
+ disabled={disabled}
100
+ loading={runIsLoading}
101
+ view={runView}
102
+ >
103
+ <Icon name="startPlay" viewBox="0 0 16 16" width={16} height={16} />
104
+ {'Run'}
105
+ </Button>
108
106
  <Button
109
107
  onClick={() => {
110
108
  onExplainButtonClick(queryMode);
@@ -4,7 +4,7 @@
4
4
  align-items: flex-start;
5
5
 
6
6
  & + & {
7
- margin-top: var(--yc-text-body-1-line-height);
7
+ margin-top: var(--g-text-body-1-line-height);
8
8
  }
9
9
  }
10
10
  &__field-title {
@@ -18,7 +18,7 @@
18
18
  &::after {
19
19
  content: '*';
20
20
 
21
- color: var(--yc-color-text-danger);
21
+ color: var(--g-color-text-danger);
22
22
  }
23
23
  }
24
24
  }
@@ -32,7 +32,7 @@
32
32
 
33
33
  height: 17px;
34
34
 
35
- color: var(--yc-color-text-danger);
35
+ color: var(--g-color-text-danger);
36
36
  }
37
37
  &__embedded-tooltip {
38
38
  display: flex;
@@ -41,11 +41,11 @@
41
41
  height: 100%;
42
42
  margin-left: -10px;
43
43
 
44
- color: var(--yc-color-text-secondary);
44
+ color: var(--g-color-text-secondary);
45
45
  &:hover {
46
46
  cursor: pointer;
47
47
 
48
- color: var(--yc-color-text-complementary);
48
+ color: var(--g-color-text-complementary);
49
49
  }
50
50
  }
51
51
 
@@ -11,7 +11,7 @@ import {setQueryTab} from '../../../../store/reducers/tenant/tenant';
11
11
  import {TENANT_QUERY_TABS_ID} from '../../../../store/reducers/tenant/constants';
12
12
 
13
13
  import {TruncatedQuery} from '../../../../components/TruncatedQuery/TruncatedQuery';
14
- import {IconWrapper} from '../../../../components/Icon';
14
+ import {Icon} from '../../../../components/Icon';
15
15
 
16
16
  import {MAX_QUERY_HEIGHT, QUERY_TABLE_SETTINGS} from '../../utils/constants';
17
17
 
@@ -110,10 +110,10 @@ export const SavedQueries = ({savedQueries, changeUserInput, onDeleteQuery}: Sav
110
110
  </div>
111
111
  <span className={b('controls')}>
112
112
  <Button view="flat-secondary">
113
- <IconWrapper name="pencil" viewBox="0 0 24 24" />
113
+ <Icon name="pencil" viewBox="0 0 24 24" />
114
114
  </Button>
115
115
  <Button view="flat-secondary" onClick={onDeleteQueryClick(query.name)}>
116
- <IconWrapper name="trash" viewBox="0 0 24 24" />
116
+ <Icon name="trash" viewBox="0 0 24 24" />
117
117
  </Button>
118
118
  </span>
119
119
  </div>
@@ -3,7 +3,6 @@
3
3
  .tenant-page {
4
4
  overflow: hidden;
5
5
 
6
- font-size: var(--yc-text-body-2-font-size);
7
- line-height: var(--yc-text-body-2-line-height);
6
+ @include body-2-typography();
8
7
  @include flex-container();
9
8
  }
@@ -6,7 +6,7 @@ import {Button} from '@gravity-ui/uikit';
6
6
  import {setShowPreview} from '../../../store/reducers/schema/schema';
7
7
  import {setQueryTab, setTenantPage} from '../../../store/reducers/tenant/tenant';
8
8
  import {TENANT_PAGES_IDS, TENANT_QUERY_TABS_ID} from '../../../store/reducers/tenant/constants';
9
- import {IconWrapper} from '../../../components/Icon';
9
+ import {Icon} from '../../../components/Icon';
10
10
 
11
11
  import i18n from '../i18n';
12
12
 
@@ -44,7 +44,7 @@ export const getControls =
44
44
  title={i18n('actions.openPreview')}
45
45
  size="s"
46
46
  >
47
- <IconWrapper name="tablePreview" />
47
+ <Icon name="tablePreview" />
48
48
  </Button>
49
49
  );
50
50
 
@@ -82,7 +82,11 @@ export const Setting = ({
82
82
  };
83
83
 
84
84
  return (
85
- <Settings.Item title={title} renderTitleComponent={renderTitleComponent}>
85
+ <Settings.Item
86
+ title={title}
87
+ highlightedTitle={title}
88
+ renderTitleComponent={renderTitleComponent}
89
+ >
86
90
  {getSettingsElement(type)}
87
91
  </Settings.Item>
88
92
  );
@@ -8,7 +8,7 @@
8
8
  margin-top: 10px;
9
9
  margin-bottom: 10px;
10
10
 
11
- border: 1px solid var(--yc-color-line-generic);
11
+ border: 1px solid var(--g-color-line-generic);
12
12
  border-radius: 10px;
13
13
  }
14
14
 
@@ -29,8 +29,7 @@
29
29
  }
30
30
 
31
31
  .ydb-tree-view {
32
- font-size: var(--yc-text-body-2-font-size);
33
- line-height: var(--yc-text-body-2-line-height);
32
+ @include body-2-typography();
34
33
 
35
34
  // Apply margin ignoring first element of the tree
36
35
  .ydb-tree-view {
@@ -24,7 +24,7 @@
24
24
  &__info-label {
25
25
  font-weight: 200;
26
26
 
27
- color: var(--yc-color-text-complementary);
27
+ color: var(--g-color-text-complementary);
28
28
 
29
29
  &_margin_left {
30
30
  margin-left: 5px;
@@ -53,7 +53,7 @@ export const NodesTreeTitle = ({
53
53
  {versionsValues ? (
54
54
  <div className={b('version-progress')}>
55
55
  <span className={b('info-label', {margin: 'right'})}>Versions</span>
56
- <Progress view="thin" value={100} stack={versionsValues} />
56
+ <Progress size="s" value={100} stack={versionsValues} />
57
57
  </div>
58
58
  ) : null}
59
59
  </div>
package/dist/index.tsx CHANGED
@@ -9,6 +9,7 @@ import configureStore from './store';
9
9
  import reportWebVitals from './reportWebVitals';
10
10
  import HistoryContext from './contexts/HistoryContext';
11
11
 
12
+ import './styles/themes.scss';
12
13
  import './styles/constants.scss';
13
14
  import './index.css';
14
15
 
@@ -34,7 +34,6 @@ import type {StorageApiRequestParams} from '../store/reducers/storage/types';
34
34
 
35
35
  import {backend as BACKEND} from '../store';
36
36
  import {prepareSortValue} from '../utils/filters';
37
- import {settingsApi} from '../utils/settings';
38
37
 
39
38
  const config = {withCredentials: !window.custom_backend};
40
39
 
@@ -378,10 +377,12 @@ export class YdbEmbeddedAPI extends AxiosWrapper {
378
377
  path_id: tenantId?.PathId,
379
378
  });
380
379
  }
381
- postSetting(name: string, value: string) {
380
+
381
+ /** @deprecated use localStorage instead */
382
+ postSetting(settingsApi: string, name: string, value: string) {
382
383
  return this.request({
383
384
  method: 'PATCH',
384
- url: settingsApi || '',
385
+ url: settingsApi,
385
386
  data: {[name]: value},
386
387
  });
387
388
  }
@@ -0,0 +1,113 @@
1
+ import {TENANT_PAGES_IDS} from '../store/reducers/tenant/constants';
2
+
3
+ import {
4
+ ASIDE_HEADER_COMPACT_KEY,
5
+ CLUSTER_INFO_HIDDEN_KEY,
6
+ INVERTED_DISKS_KEY,
7
+ LANGUAGE_KEY,
8
+ LAST_USED_QUERY_ACTION_KEY,
9
+ PARTITIONS_HIDDEN_COLUMNS_KEY,
10
+ QUERY_INITIAL_MODE_KEY,
11
+ QUERY_USE_MULTI_SCHEMA_KEY,
12
+ SAVED_QUERIES_KEY,
13
+ TENANT_INITIAL_PAGE_KEY,
14
+ THEME_KEY,
15
+ USE_BACKEND_PARAMS_FOR_TABLES_KEY,
16
+ USE_NODES_ENDPOINT_IN_DIAGNOSTICS_KEY,
17
+ } from '../utils/constants';
18
+ import {QUERY_ACTIONS, QUERY_MODES} from '../utils/query';
19
+ import {parseJson} from '../utils/utils';
20
+
21
+ export type SettingsObject = Record<string, unknown>;
22
+
23
+ const USE_LOCAL_STORAGE_FOR_SETTINGS_KEY = 'useLocalStorageForSettings';
24
+
25
+ /** User settings keys and their default values */
26
+ const DEFAULT_USER_SETTINGS: SettingsObject = {
27
+ [THEME_KEY]: 'system',
28
+ [LANGUAGE_KEY]: undefined,
29
+ [INVERTED_DISKS_KEY]: false,
30
+ [USE_NODES_ENDPOINT_IN_DIAGNOSTICS_KEY]: false,
31
+ [QUERY_USE_MULTI_SCHEMA_KEY]: false,
32
+ [SAVED_QUERIES_KEY]: [],
33
+ [TENANT_INITIAL_PAGE_KEY]: TENANT_PAGES_IDS.query,
34
+ [QUERY_INITIAL_MODE_KEY]: QUERY_MODES.script,
35
+ [LAST_USED_QUERY_ACTION_KEY]: QUERY_ACTIONS.execute,
36
+ [ASIDE_HEADER_COMPACT_KEY]: true,
37
+ [PARTITIONS_HIDDEN_COLUMNS_KEY]: [],
38
+ [CLUSTER_INFO_HIDDEN_KEY]: true,
39
+ [USE_BACKEND_PARAMS_FOR_TABLES_KEY]: false,
40
+ };
41
+
42
+ class SettingsManager {
43
+ constructor() {
44
+ // Migrate settings to LS if external API was used before
45
+ const settingsApi = window.web_version ? window.systemSettings?.settingsApi : undefined;
46
+
47
+ const useLocalStorage = this.readUserSettingsValue(USE_LOCAL_STORAGE_FOR_SETTINGS_KEY);
48
+
49
+ if (settingsApi && !useLocalStorage) {
50
+ const externalUserSettings = window.userSettings;
51
+
52
+ if (externalUserSettings) {
53
+ Object.entries(externalUserSettings).forEach(([key, value]) =>
54
+ this.setUserSettingsValue(key, value),
55
+ );
56
+ }
57
+
58
+ this.setUserSettingsValue(USE_LOCAL_STORAGE_FOR_SETTINGS_KEY, true);
59
+ }
60
+ }
61
+
62
+ /**
63
+ * User settings - settings stored in LS or external store
64
+ */
65
+ getUserSettings() {
66
+ return this.extractSettingsFromLS();
67
+ }
68
+
69
+ /**
70
+ * Returns parsed settings value.
71
+ * If value cannot be parsed, returns initially stored string.
72
+ * If there is no value, return default value
73
+ */
74
+ readUserSettingsValue(key: string, defaultValue?: unknown) {
75
+ return this.readValueFromLS(key) ?? defaultValue ?? DEFAULT_USER_SETTINGS[key];
76
+ }
77
+
78
+ /**
79
+ * Stringify value and set it to LS
80
+ */
81
+ setUserSettingsValue(key: string, value: unknown) {
82
+ return this.setValueToLS(key, value);
83
+ }
84
+
85
+ private extractSettingsFromLS = () => {
86
+ return Object.entries(DEFAULT_USER_SETTINGS).reduce<SettingsObject>((acc, [key, value]) => {
87
+ acc[key] = this.readUserSettingsValue(key, value);
88
+ return acc;
89
+ }, {});
90
+ };
91
+
92
+ private readValueFromLS = (key: string): unknown => {
93
+ try {
94
+ const value = localStorage.getItem(key);
95
+
96
+ return parseJson(value);
97
+ } catch {
98
+ return undefined;
99
+ }
100
+ };
101
+
102
+ private setValueToLS = (key: string, value: unknown): void => {
103
+ try {
104
+ if (typeof value === 'string') {
105
+ localStorage.setItem(key, value);
106
+ } else {
107
+ localStorage.setItem(key, JSON.stringify(value));
108
+ }
109
+ } catch {}
110
+ };
111
+ }
112
+
113
+ export const settingsManager = new SettingsManager();
@@ -9,10 +9,10 @@ import type {
9
9
  QueryInHistory,
10
10
  } from '../../types/store/executeQuery';
11
11
  import type {QueryRequestParams, QueryMode, QuerySyntax} from '../../types/store/query';
12
- import {getValueFromLS, parseJson} from '../../utils/utils';
13
12
  import {QUERIES_HISTORY_KEY} from '../../utils/constants';
14
13
  import {QUERY_MODES, QUERY_SYNTAX, parseQueryAPIExecuteResponse} from '../../utils/query';
15
14
  import {parseQueryError} from '../../utils/error';
15
+ import {settingsManager} from '../../services/settings';
16
16
  import '../../services/api';
17
17
 
18
18
  import {createRequestActionTypes, createApiRequest} from '../utils';
@@ -28,7 +28,10 @@ const GO_TO_NEXT_QUERY = 'query/GO_TO_NEXT_QUERY';
28
28
  const SET_MONACO_HOT_KEY = 'query/SET_MONACO_HOT_KEY';
29
29
  const SET_TENANT_PATH = 'query/SET_TENANT_PATH';
30
30
 
31
- const queriesHistoryInitial: string[] = parseJson(getValueFromLS(QUERIES_HISTORY_KEY, '[]'));
31
+ const queriesHistoryInitial = settingsManager.readUserSettingsValue(
32
+ QUERIES_HISTORY_KEY,
33
+ [],
34
+ ) as string[];
32
35
 
33
36
  const sliceLimit = queriesHistoryInitial.length - MAXIMUM_QUERIES_IN_HISTORY;
34
37
 
@@ -97,7 +100,7 @@ const executeQuery: Reducer<ExecuteQueryState, ExecuteQueryAction> = (
97
100
  const newQueries = [...state.history.queries, {queryText, syntax}].slice(
98
101
  state.history.queries.length >= MAXIMUM_QUERIES_IN_HISTORY ? 1 : 0,
99
102
  );
100
- window.localStorage.setItem(QUERIES_HISTORY_KEY, JSON.stringify(newQueries));
103
+ settingsManager.setUserSettingsValue(QUERIES_HISTORY_KEY, newQueries);
101
104
  const currentIndex = newQueries.length - 1;
102
105
 
103
106
  return {
@@ -1,32 +1,8 @@
1
1
  import type {Reducer} from 'redux';
2
2
  import type {ThunkAction} from 'redux-thunk';
3
3
 
4
- import {
5
- SAVED_QUERIES_KEY,
6
- THEME_KEY,
7
- TENANT_INITIAL_PAGE_KEY,
8
- INVERTED_DISKS_KEY,
9
- ASIDE_HEADER_COMPACT_KEY,
10
- USE_NODES_ENDPOINT_IN_DIAGNOSTICS_KEY,
11
- PARTITIONS_HIDDEN_COLUMNS_KEY,
12
- QUERY_INITIAL_MODE_KEY,
13
- CLUSTER_INFO_HIDDEN_KEY,
14
- LAST_USED_QUERY_ACTION_KEY,
15
- USE_BACKEND_PARAMS_FOR_TABLES_KEY,
16
- LANGUAGE_KEY,
17
- QUERY_USE_MULTI_SCHEMA_KEY,
18
- } from '../../../utils/constants';
19
4
  import '../../../services/api';
20
- import {parseJson} from '../../../utils/utils';
21
- import {QUERY_ACTIONS, QUERY_MODES} from '../../../utils/query';
22
- import {
23
- readSavedSettingsValue,
24
- settingsApi,
25
- systemSettings,
26
- userSettings,
27
- } from '../../../utils/settings';
28
-
29
- import {TENANT_PAGES_IDS} from '../tenant/constants';
5
+ import {settingsManager} from '../../../services/settings';
30
6
 
31
7
  import type {RootState} from '..';
32
8
  import type {
@@ -45,39 +21,12 @@ export const ProblemFilterValues = {
45
21
  PROBLEMS: 'With problems',
46
22
  } as const;
47
23
 
24
+ const userSettings = settingsManager.getUserSettings();
25
+ const systemSettings = window.systemSettings || {};
26
+
48
27
  export const initialState = {
49
28
  problemFilter: ProblemFilterValues.ALL,
50
- userSettings: {
51
- ...userSettings,
52
- [THEME_KEY]: readSavedSettingsValue(THEME_KEY, 'system'),
53
- [LANGUAGE_KEY]: readSavedSettingsValue(LANGUAGE_KEY),
54
- [INVERTED_DISKS_KEY]: readSavedSettingsValue(INVERTED_DISKS_KEY, 'false'),
55
- [USE_NODES_ENDPOINT_IN_DIAGNOSTICS_KEY]: readSavedSettingsValue(
56
- USE_NODES_ENDPOINT_IN_DIAGNOSTICS_KEY,
57
- 'false',
58
- ),
59
- [QUERY_USE_MULTI_SCHEMA_KEY]: readSavedSettingsValue(QUERY_USE_MULTI_SCHEMA_KEY, 'false'),
60
- [SAVED_QUERIES_KEY]: readSavedSettingsValue(SAVED_QUERIES_KEY, '[]'),
61
- [TENANT_INITIAL_PAGE_KEY]: readSavedSettingsValue(
62
- TENANT_INITIAL_PAGE_KEY,
63
- TENANT_PAGES_IDS.query,
64
- ),
65
- [QUERY_INITIAL_MODE_KEY]: readSavedSettingsValue(
66
- QUERY_INITIAL_MODE_KEY,
67
- QUERY_MODES.script,
68
- ),
69
- [LAST_USED_QUERY_ACTION_KEY]: readSavedSettingsValue(
70
- LAST_USED_QUERY_ACTION_KEY,
71
- QUERY_ACTIONS.execute,
72
- ),
73
- [ASIDE_HEADER_COMPACT_KEY]: readSavedSettingsValue(ASIDE_HEADER_COMPACT_KEY, 'true'),
74
- [PARTITIONS_HIDDEN_COLUMNS_KEY]: readSavedSettingsValue(PARTITIONS_HIDDEN_COLUMNS_KEY),
75
- [CLUSTER_INFO_HIDDEN_KEY]: readSavedSettingsValue(CLUSTER_INFO_HIDDEN_KEY, 'true'),
76
- [USE_BACKEND_PARAMS_FOR_TABLES_KEY]: readSavedSettingsValue(
77
- USE_BACKEND_PARAMS_FOR_TABLES_KEY,
78
- 'false',
79
- ),
80
- },
29
+ userSettings,
81
30
  systemSettings,
82
31
  };
83
32
 
@@ -108,19 +57,12 @@ const settings: Reducer<SettingsState, SettingsAction> = (state = initialState,
108
57
 
109
58
  export const setSettingValue = (
110
59
  name: string,
111
- value: string,
60
+ value: unknown,
112
61
  ): ThunkAction<void, RootState, unknown, SetSettingValueAction> => {
113
62
  return (dispatch) => {
114
63
  dispatch({type: SET_SETTING_VALUE, data: {name, value}});
115
64
 
116
- // If there is no settingsApi, use localStorage
117
- if (settingsApi) {
118
- window.api.postSetting(name, value);
119
- } else {
120
- try {
121
- localStorage.setItem(name, value);
122
- } catch {}
123
- }
65
+ settingsManager.setUserSettingsValue(name, value);
124
66
  };
125
67
  };
126
68
 
@@ -128,15 +70,6 @@ export const getSettingValue = (state: SettingsRootStateSlice, name: string) =>
128
70
  return state.settings.userSettings[name];
129
71
  };
130
72
 
131
- /**
132
- * Returns parsed settings value.
133
- * If value cannot be parsed, returns initially stored string
134
- */
135
- export const getParsedSettingValue = (state: SettingsRootStateSlice, name: string) => {
136
- const value = state.settings.userSettings[name];
137
- return parseJson(value);
138
- };
139
-
140
73
  export const changeFilter = (filter: ProblemFilterValue) => {
141
74
  return {
142
75
  type: CHANGE_PROBLEM_FILTER,
@@ -1,17 +1,18 @@
1
1
  import type {ValueOf} from '../../../types/common';
2
+ import type {SettingsObject} from '../../../services/settings';
2
3
  import {changeFilter, ProblemFilterValues, SET_SETTING_VALUE} from './settings';
3
4
 
4
5
  export type ProblemFilterValue = ValueOf<typeof ProblemFilterValues>;
5
6
 
6
7
  export interface SettingsState {
7
8
  problemFilter: ProblemFilterValue;
8
- userSettings: Record<string, string | undefined>;
9
- systemSettings: Record<string, string | undefined>;
9
+ userSettings: SettingsObject;
10
+ systemSettings: SettingsObject;
10
11
  }
11
12
 
12
13
  export type SetSettingValueAction = {
13
14
  type: typeof SET_SETTING_VALUE;
14
- data: {name: string; value: string};
15
+ data: {name: string; value: unknown};
15
16
  };
16
17
 
17
18
  export type SettingsAction = ReturnType<typeof changeFilter> | SetSettingValueAction;
@@ -15,26 +15,29 @@
15
15
  flex-direction: column;
16
16
  }
17
17
 
18
- @mixin body-typography() {
19
- font-size: var(--yc-text-body-1-font-size);
20
- line-height: var(--yc-text-body-1-line-height);
18
+ @mixin body-1-typography() {
19
+ font-size: var(--g-text-body-1-font-size);
20
+ line-height: var(--g-text-body-1-line-height);
21
21
  }
22
- @mixin body2-typography() {
23
- font-size: var(--yc-text-body-2-font-size);
24
- line-height: var(--yc-text-body-2-line-height);
22
+ @mixin body-2-typography() {
23
+ font-size: var(--g-text-body-2-font-size);
24
+ line-height: var(--g-text-body-2-line-height);
25
25
  }
26
- @mixin body3-typography() {
27
- font-size: var(--yc-text-body-3-font-size);
28
- line-height: var(--yc-text-body-3-line-height);
26
+ @mixin body-3-typography() {
27
+ font-size: var(--g-text-body-3-font-size);
28
+ line-height: var(--g-text-body-3-line-height);
29
29
  }
30
30
  @mixin lead-typography() {
31
- font-size: var(--yc-text-subheader-3-font-size);
32
- line-height: var(--yc-text-subheader-3-line-height);
31
+ font-size: var(--g-text-subheader-3-font-size);
32
+ line-height: var(--g-text-subheader-3-line-height);
33
33
  }
34
-
35
- @mixin title-typography() {
36
- font-size: var(--yc-text-header-2-font-size);
37
- line-height: var(--yc-text-header-2-line-height);
34
+ @mixin header-1-typography() {
35
+ font-size: var(--g-text-header-1-font-size);
36
+ line-height: var(--g-text-header-1-line-height);
37
+ }
38
+ @mixin header-2-typography() {
39
+ font-size: var(--g-text-header-2-font-size);
40
+ line-height: var(--g-text-header-2-line-height);
38
41
  }
39
42
 
40
43
  @mixin sticky-top {
@@ -42,7 +45,7 @@
42
45
  top: 0;
43
46
  left: 0;
44
47
 
45
- background-color: var(--yc-color-base-background);
48
+ background-color: var(--g-color-base-background);
46
49
  }
47
50
 
48
51
  @mixin loader() {
@@ -82,9 +85,8 @@
82
85
  @mixin info-viewer-title {
83
86
  margin: 15px 0 10px;
84
87
 
85
- font-size: var(--yc-text-body-2-font-size);
86
88
  font-weight: 600;
87
- line-height: var(--yc-text-body-2-line-height);
89
+ @include body-2-typography();
88
90
  }
89
91
 
90
92
  @mixin query-data-table() {
@@ -113,7 +115,7 @@
113
115
  }
114
116
 
115
117
  &__th {
116
- box-shadow: inset 0 -1px 0 0 var(--yc-tabs-color-divider);
118
+ box-shadow: inset 0 -1px 0 0 var(--g-tabs-color-divider);
117
119
  }
118
120
  }
119
121
  }
@@ -121,14 +123,14 @@
121
123
  .link {
122
124
  text-decoration: none;
123
125
 
124
- color: var(--yc-color-text-link);
126
+ color: var(--g-color-text-link);
125
127
 
126
128
  &_external {
127
129
  margin-right: 10px;
128
130
  }
129
131
 
130
132
  &:hover {
131
- color: var(--yc-color-text-link-hover);
133
+ color: var(--g-color-text-link-hover);
132
134
  }
133
135
  }
134
136
 
@@ -143,8 +145,8 @@
143
145
  z-index: 2000;
144
146
  left: $left;
145
147
 
146
- border-right: $border-width solid var(--yc-color-line-generic);
147
- background-color: var(--yc-color-base-background);
148
+ border-right: $border-width solid var(--g-color-line-generic);
149
+ background-color: var(--g-color-base-background);
148
150
  }
149
151
  .data-table__row:hover .data-table__td:nth-child(#{$nth}) {
150
152
  background-color: var(--ydb-data-table-color-hover) !important;
@@ -199,9 +201,9 @@
199
201
 
200
202
  @mixin json-tree-styles {
201
203
  // stylelint-disable
202
- font-family: var(--yc-font-family-monospace) !important;
203
- font-size: var(--yc-text-code-1-font-size) !important;
204
- line-height: var(--yc-text-code-1-line-height) !important;
204
+ font-family: var(--g-font-family-monospace) !important;
205
+ font-size: var(--g-text-code-1-font-size) !important;
206
+ line-height: var(--g-text-code-1-line-height) !important;
205
207
  // stylelint-enable
206
208
 
207
209
  .json-inspector__leaf_composite:before {
@@ -210,7 +212,7 @@
210
212
 
211
213
  font-size: 9px;
212
214
 
213
- color: var(--yc-color-text-secondary);
215
+ color: var(--g-color-text-secondary);
214
216
  }
215
217
  .json-inspector__leaf_composite.json-inspector__leaf_root:before {
216
218
  left: 0;
@@ -224,7 +226,7 @@
224
226
 
225
227
  & .json-inspector {
226
228
  &__key {
227
- color: var(--yc-color-text-misc);
229
+ color: var(--g-color-text-misc);
228
230
  }
229
231
  &__leaf {
230
232
  position: relative;
@@ -241,7 +243,7 @@
241
243
  width: 300px;
242
244
  margin-bottom: 10px;
243
245
 
244
- border: 1px solid var(--yc-color-line-generic);
246
+ border: 1px solid var(--g-color-line-generic);
245
247
  border-radius: 4px;
246
248
  }
247
249
  &__search {
@@ -251,11 +253,11 @@
251
253
  margin: 0;
252
254
  padding: 0;
253
255
 
254
- font-family: var(--yc-text-body-font-family);
256
+ font-family: var(--g-text-body-font-family);
255
257
  font-size: 13px;
256
258
  vertical-align: top;
257
259
 
258
- color: var(--yc-color-text-primary);
260
+ color: var(--g-color-text-primary);
259
261
  border: 0 solid transparent;
260
262
  border-width: 0 8px;
261
263
  border-right-width: 22px;
@@ -264,18 +266,18 @@
264
266
  }
265
267
  &__value {
266
268
  &_helper {
267
- color: var(--yc-color-text-secondary);
269
+ color: var(--g-color-text-secondary);
268
270
  }
269
271
  }
270
272
  &__line:hover:after {
271
- background: var(--yc-color-base-simple-hover);
273
+ background: var(--g-color-base-simple-hover);
272
274
  }
273
275
  &__show-original:before {
274
- color: var(--yc-color-text-secondary);
276
+ color: var(--g-color-text-secondary);
275
277
  }
276
278
  &__show-original:hover:after,
277
279
  &__show-original:hover:before {
278
- color: var(--yc-color-text-primary);
280
+ color: var(--g-color-text-primary);
279
281
  }
280
282
  }
281
283
  }