ydb-embedded-ui 4.27.0 → 4.28.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/components/EmptyState/EmptyState.scss +5 -2
  3. package/dist/components/EmptyState/EmptyState.tsx +11 -3
  4. package/dist/components/Errors/403/AccessDenied.tsx +4 -3
  5. package/dist/components/ProblemFilter/ProblemFilter.tsx +1 -1
  6. package/dist/components/UptimeFIlter/UptimeFilter.tsx +1 -1
  7. package/dist/components/VirtualTable/VirtualTable.scss +1 -1
  8. package/dist/containers/Cluster/Cluster.tsx +11 -12
  9. package/dist/containers/Nodes/Nodes.tsx +4 -4
  10. package/dist/containers/Nodes/NodesWrapper.tsx +21 -0
  11. package/dist/containers/Nodes/VirtualNodes.tsx +4 -14
  12. package/dist/containers/Storage/DiskStateProgressBar/DiskStateProgressBar.scss +1 -0
  13. package/dist/containers/Storage/EmptyFilter/EmptyFilter.tsx +1 -0
  14. package/dist/containers/Storage/PDisk/PDisk.tsx +5 -7
  15. package/dist/containers/Storage/Storage.tsx +30 -67
  16. package/dist/containers/Storage/StorageControls/StorageControls.tsx +104 -0
  17. package/dist/containers/Storage/StorageGroups/StorageGroups.tsx +18 -62
  18. package/dist/containers/Storage/StorageGroups/StorageGroupsEmptyDataMessage.tsx +30 -0
  19. package/dist/containers/Storage/StorageGroups/VirtualStorageGroups.tsx +94 -0
  20. package/dist/containers/Storage/StorageGroups/getGroups.ts +21 -0
  21. package/dist/containers/Storage/StorageGroups/getStorageGroupsColumns.tsx +73 -50
  22. package/dist/containers/Storage/StorageNodes/StorageNodes.tsx +23 -138
  23. package/dist/containers/Storage/StorageNodes/StorageNodesEmptyDataMessage.tsx +44 -0
  24. package/dist/containers/Storage/StorageNodes/VirtualStorageNodes.tsx +105 -0
  25. package/dist/containers/Storage/StorageNodes/getNodes.ts +26 -0
  26. package/dist/containers/Storage/StorageNodes/getStorageNodesColumns.tsx +125 -0
  27. package/dist/containers/Storage/StorageNodes/shared.ts +9 -0
  28. package/dist/containers/Storage/StorageTypeFilter/StorageTypeFilter.tsx +1 -1
  29. package/dist/containers/Storage/StorageVisibleEntitiesFilter/StorageVisibleEntitiesFilter.tsx +1 -1
  30. package/dist/containers/Storage/StorageWrapper.tsx +23 -0
  31. package/dist/containers/Storage/UsageFilter/UsageFilter.tsx +3 -4
  32. package/dist/containers/Storage/VirtualStorage.tsx +112 -0
  33. package/dist/containers/Storage/i18n/en.json +7 -0
  34. package/dist/containers/Storage/i18n/index.ts +11 -0
  35. package/dist/containers/Storage/i18n/ru.json +7 -0
  36. package/dist/containers/Storage/shared.ts +3 -0
  37. package/dist/containers/Tenants/Tenants.tsx +2 -2
  38. package/dist/containers/UserSettings/i18n/en.json +2 -2
  39. package/dist/containers/UserSettings/i18n/ru.json +2 -2
  40. package/dist/containers/UserSettings/settings.ts +4 -4
  41. package/dist/services/settings.ts +7 -11
  42. package/dist/store/reducers/settings/settings.ts +16 -3
  43. package/dist/store/reducers/settings/types.ts +5 -2
  44. package/dist/store/reducers/storage/selectors.ts +0 -20
  45. package/package.json +6 -6
@@ -0,0 +1,112 @@
1
+ import {useEffect, useState} from 'react';
2
+ import {useDispatch} from 'react-redux';
3
+
4
+ import type {AdditionalNodesProps} from '../../types/additionalProps';
5
+ import type {RenderControls, RenderErrorMessage} from '../../components/VirtualTable';
6
+ import type {StorageType, VisibleEntities} from '../../store/reducers/storage/types';
7
+ import {STORAGE_TYPES, VISIBLE_ENTITIES} from '../../store/reducers/storage/constants';
8
+ import {NodesUptimeFilterValues} from '../../utils/nodes';
9
+ import {AccessDenied} from '../../components/Errors/403/AccessDenied';
10
+ import {ResponseError} from '../../components/Errors/ResponseError/ResponseError';
11
+ import {getNodesList, selectNodesMap} from '../../store/reducers/nodesList';
12
+ import {useTypedSelector} from '../../utils/hooks';
13
+
14
+ import {StorageControls} from './StorageControls/StorageControls';
15
+ import {VirtualStorageGroups} from './StorageGroups/VirtualStorageGroups';
16
+ import {VirtualStorageNodes} from './StorageNodes/VirtualStorageNodes';
17
+
18
+ interface VirtualStorageProps {
19
+ tenant?: string;
20
+ nodeId?: string;
21
+ parentContainer?: Element | null;
22
+ additionalNodesProps?: AdditionalNodesProps;
23
+ }
24
+
25
+ export const VirtualStorage = ({
26
+ tenant,
27
+ nodeId,
28
+ parentContainer,
29
+ additionalNodesProps,
30
+ }: VirtualStorageProps) => {
31
+ const dispatch = useDispatch();
32
+
33
+ const [searchValue, setSearchValue] = useState('');
34
+ const [storageType, setStorageType] = useState<StorageType>(STORAGE_TYPES.groups);
35
+ const [visibleEntities, setVisibleEntities] = useState<VisibleEntities>(VISIBLE_ENTITIES.all);
36
+ const [nodesUptimeFilter, setNodesUptimeFilter] = useState<NodesUptimeFilterValues>(
37
+ NodesUptimeFilterValues.All,
38
+ );
39
+
40
+ const nodesMap = useTypedSelector(selectNodesMap);
41
+
42
+ useEffect(() => {
43
+ dispatch(getNodesList());
44
+ }, [dispatch]);
45
+
46
+ const handleShowAllGroups = () => {
47
+ setVisibleEntities(VISIBLE_ENTITIES.all);
48
+ };
49
+
50
+ const handleShowAllNodes = () => {
51
+ setVisibleEntities(VISIBLE_ENTITIES.all);
52
+ setNodesUptimeFilter(NodesUptimeFilterValues.All);
53
+ };
54
+
55
+ const renderControls: RenderControls = ({totalEntities, foundEntities, inited}) => {
56
+ return (
57
+ <StorageControls
58
+ searchValue={searchValue}
59
+ handleSearchValueChange={setSearchValue}
60
+ withTypeSelector={!nodeId}
61
+ storageType={storageType}
62
+ handleStorageTypeChange={setStorageType}
63
+ visibleEntities={visibleEntities}
64
+ handleVisibleEntitiesChange={setVisibleEntities}
65
+ nodesUptimeFilter={nodesUptimeFilter}
66
+ handleNodesUptimeFilterChange={setNodesUptimeFilter}
67
+ withGroupsUsageFilter={false}
68
+ entitiesCountCurrent={foundEntities}
69
+ entitiesCountTotal={totalEntities}
70
+ entitiesLoading={!inited}
71
+ />
72
+ );
73
+ };
74
+
75
+ const renderErrorMessage: RenderErrorMessage = (error) => {
76
+ if (error.status === 403) {
77
+ return <AccessDenied position="left" />;
78
+ }
79
+
80
+ return <ResponseError error={error} />;
81
+ };
82
+
83
+ if (storageType === STORAGE_TYPES.nodes) {
84
+ return (
85
+ <VirtualStorageNodes
86
+ searchValue={searchValue}
87
+ visibleEntities={visibleEntities}
88
+ nodesUptimeFilter={nodesUptimeFilter}
89
+ tenant={tenant}
90
+ additionalNodesProps={additionalNodesProps}
91
+ onShowAll={handleShowAllNodes}
92
+ parentContainer={parentContainer}
93
+ renderControls={renderControls}
94
+ renderErrorMessage={renderErrorMessage}
95
+ />
96
+ );
97
+ }
98
+
99
+ return (
100
+ <VirtualStorageGroups
101
+ searchValue={searchValue}
102
+ visibleEntities={visibleEntities}
103
+ tenant={tenant}
104
+ nodeId={nodeId}
105
+ nodesMap={nodesMap}
106
+ onShowAll={handleShowAllGroups}
107
+ parentContainer={parentContainer}
108
+ renderControls={renderControls}
109
+ renderErrorMessage={renderErrorMessage}
110
+ />
111
+ );
112
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "groups": "Groups",
3
+ "nodes": "Nodes",
4
+
5
+ "controls_groups-search-placeholder": "Group ID, Pool name",
6
+ "controls_nodes-search-placeholder": "Node ID, FQDN"
7
+ }
@@ -0,0 +1,11 @@
1
+ import {i18n, Lang} from '../../../utils/i18n';
2
+
3
+ import en from './en.json';
4
+ import ru from './ru.json';
5
+
6
+ const COMPONENT = 'ydb-storage';
7
+
8
+ i18n.registerKeyset(Lang.En, COMPONENT, en);
9
+ i18n.registerKeyset(Lang.Ru, COMPONENT, ru);
10
+
11
+ export default i18n.keyset(COMPONENT);
@@ -0,0 +1,7 @@
1
+ {
2
+ "groups": "Группы",
3
+ "nodes": "Ноды",
4
+
5
+ "controls_groups-search-placeholder": "ID группы, имя пула",
6
+ "controls_nodes-search-placeholder": "ID узла, FQDN"
7
+ }
@@ -0,0 +1,3 @@
1
+ import cn from 'bem-cn-lite';
2
+
3
+ export const b = cn('global-storage');
@@ -61,8 +61,8 @@ export const Tenants = ({additionalTenantsProps}: TenantsProps) => {
61
61
  true,
62
62
  );
63
63
 
64
- const handleProblemFilterChange = (value: string) => {
65
- dispatch(changeFilter(value as ProblemFilterValue));
64
+ const handleProblemFilterChange = (value: ProblemFilterValue) => {
65
+ dispatch(changeFilter(value));
66
66
  };
67
67
 
68
68
  const handleSearchChange = (value: string) => {
@@ -19,8 +19,8 @@
19
19
  "settings.useNodesEndpoint.title": "Break the Nodes tab in Diagnostics",
20
20
  "settings.useNodesEndpoint.popover": "Use /viewer/json/nodes endpoint for Nodes Tab in diagnostics. It could return incorrect data on some versions",
21
21
 
22
- "settings.useBackendParamsForTables.title": "Use virtual table for cluster Nodes tab",
23
- "settings.useBackendParamsForTables.popover": "Use table with data load on scroll. It will increase performance, but could work unstable",
22
+ "settings.useVirtualTables.title": "Use table with data load on scroll for Nodes and Storage cluster tabs",
23
+ "settings.useVirtualTables.popover": "It will increase performance, but could work unstable",
24
24
 
25
25
  "settings.queryUseMultiSchema.title": "Allow queries with multiple result sets",
26
26
  "settings.queryUseMultiSchema.popover": "Use 'multi' schema for queries that enables queries with multiple result sets. Returns nothing on versions 23-3 and older"
@@ -19,8 +19,8 @@
19
19
  "settings.useNodesEndpoint.title": "Сломать вкладку Nodes в диагностике",
20
20
  "settings.useNodesEndpoint.popover": "Использовать эндпоинт /viewer/json/nodes для вкладки Nodes в диагностике. Может возвращать некорректные данные на некоторых версиях",
21
21
 
22
- "settings.useBackendParamsForTables.title": "Использовать виртуализированную таблицу для вкладки Nodes кластера",
23
- "settings.useBackendParamsForTables.popover": "Использовать таблицу с загрузкой данных по скроллу. Это улучшит производительность, но может работать нестабильно",
22
+ "settings.useVirtualTables.title": "Использовать таблицу с загрузкой данных по скроллу для вкладок Nodes и Storage кластера",
23
+ "settings.useVirtualTables.popover": "Это улучшит производительность, но может работать нестабильно",
24
24
 
25
25
  "settings.queryUseMultiSchema.title": "Разрешить запросы с несколькими результатами",
26
26
  "settings.queryUseMultiSchema.popover": "Использовать для запросов схему 'multi', которая позволяет выполнять запросы с несколькими результатами. На версиях 23-3 и старше результат не возвращается вообще"
@@ -84,10 +84,10 @@ export const useNodesEndpointSetting: SettingProps = {
84
84
  title: i18n('settings.useNodesEndpoint.title'),
85
85
  helpPopoverContent: i18n('settings.useNodesEndpoint.popover'),
86
86
  };
87
- export const useBackendParamsForTables: SettingProps = {
87
+ export const useVirtualTables: SettingProps = {
88
88
  settingKey: USE_BACKEND_PARAMS_FOR_TABLES_KEY,
89
- title: i18n('settings.useBackendParamsForTables.title'),
90
- helpPopoverContent: i18n('settings.useBackendParamsForTables.popover'),
89
+ title: i18n('settings.useVirtualTables.title'),
90
+ helpPopoverContent: i18n('settings.useVirtualTables.popover'),
91
91
  };
92
92
  export const queryUseMultiSchemaSetting: SettingProps = {
93
93
  settingKey: QUERY_USE_MULTI_SCHEMA_KEY,
@@ -103,7 +103,7 @@ export const appearanceSection: SettingsSection = {
103
103
  export const experimentsSection: SettingsSection = {
104
104
  id: 'experimentsSection',
105
105
  title: i18n('section.experiments'),
106
- settings: [useNodesEndpointSetting, useBackendParamsForTables, queryUseMultiSchemaSetting],
106
+ settings: [useNodesEndpointSetting, useVirtualTables, queryUseMultiSchemaSetting],
107
107
  };
108
108
 
109
109
  export const generalPage: SettingsPage = {
@@ -23,7 +23,7 @@ export type SettingsObject = Record<string, unknown>;
23
23
  const USE_LOCAL_STORAGE_FOR_SETTINGS_KEY = 'useLocalStorageForSettings';
24
24
 
25
25
  /** User settings keys and their default values */
26
- const DEFAULT_USER_SETTINGS: SettingsObject = {
26
+ export const DEFAULT_USER_SETTINGS: SettingsObject = {
27
27
  [THEME_KEY]: 'system',
28
28
  [LANGUAGE_KEY]: undefined,
29
29
  [INVERTED_DISKS_KEY]: false,
@@ -59,20 +59,13 @@ class SettingsManager {
59
59
  }
60
60
  }
61
61
 
62
- /**
63
- * User settings - settings stored in LS or external store
64
- */
65
- getUserSettings() {
66
- return this.extractSettingsFromLS();
67
- }
68
-
69
62
  /**
70
63
  * Returns parsed settings value.
71
64
  * If value cannot be parsed, returns initially stored string.
72
65
  * If there is no value, return default value
73
66
  */
74
67
  readUserSettingsValue(key: string, defaultValue?: unknown) {
75
- return this.readValueFromLS(key) ?? defaultValue ?? DEFAULT_USER_SETTINGS[key];
68
+ return this.readValueFromLS(key) ?? defaultValue;
76
69
  }
77
70
 
78
71
  /**
@@ -82,8 +75,11 @@ class SettingsManager {
82
75
  return this.setValueToLS(key, value);
83
76
  }
84
77
 
85
- private extractSettingsFromLS = () => {
86
- return Object.entries(DEFAULT_USER_SETTINGS).reduce<SettingsObject>((acc, [key, value]) => {
78
+ /**
79
+ * Extract values by provided settings object
80
+ */
81
+ extractSettingsFromLS = (settings: SettingsObject) => {
82
+ return Object.entries(settings).reduce<SettingsObject>((acc, [key, value]) => {
87
83
  acc[key] = this.readUserSettingsValue(key, value);
88
84
  return acc;
89
85
  }, {});
@@ -2,7 +2,7 @@ import type {Reducer} from 'redux';
2
2
  import type {ThunkAction} from 'redux-thunk';
3
3
 
4
4
  import '../../../services/api';
5
- import {settingsManager} from '../../../services/settings';
5
+ import {DEFAULT_USER_SETTINGS, SettingsObject, settingsManager} from '../../../services/settings';
6
6
 
7
7
  import type {RootState} from '..';
8
8
  import type {
@@ -15,13 +15,14 @@ import type {
15
15
 
16
16
  const CHANGE_PROBLEM_FILTER = 'settings/CHANGE_PROBLEM_FILTER';
17
17
  export const SET_SETTING_VALUE = 'settings/SET_VALUE';
18
+ export const SET_USER_SETTINGS = 'settings/SET_USER_SETTINGS';
18
19
 
19
20
  export const ProblemFilterValues = {
20
21
  ALL: 'All',
21
22
  PROBLEMS: 'With problems',
22
23
  } as const;
23
24
 
24
- const userSettings = settingsManager.getUserSettings();
25
+ const userSettings = settingsManager.extractSettingsFromLS(DEFAULT_USER_SETTINGS);
25
26
  const systemSettings = window.systemSettings || {};
26
27
 
27
28
  export const initialState = {
@@ -49,7 +50,15 @@ const settings: Reducer<SettingsState, SettingsAction> = (state = initialState,
49
50
  userSettings: newSettings,
50
51
  };
51
52
  }
52
-
53
+ case SET_USER_SETTINGS: {
54
+ return {
55
+ ...state,
56
+ userSettings: {
57
+ ...state.userSettings,
58
+ ...action.data,
59
+ },
60
+ };
61
+ }
53
62
  default:
54
63
  return state;
55
64
  }
@@ -66,6 +75,10 @@ export const setSettingValue = (
66
75
  };
67
76
  };
68
77
 
78
+ export const setUserSettings = (data: SettingsObject) => {
79
+ return {type: SET_USER_SETTINGS, data} as const;
80
+ };
81
+
69
82
  export const getSettingValue = (state: SettingsRootStateSlice, name: string) => {
70
83
  return state.settings.userSettings[name];
71
84
  };
@@ -1,6 +1,6 @@
1
1
  import type {ValueOf} from '../../../types/common';
2
2
  import type {SettingsObject} from '../../../services/settings';
3
- import {changeFilter, ProblemFilterValues, SET_SETTING_VALUE} from './settings';
3
+ import {changeFilter, setUserSettings, ProblemFilterValues, SET_SETTING_VALUE} from './settings';
4
4
 
5
5
  export type ProblemFilterValue = ValueOf<typeof ProblemFilterValues>;
6
6
 
@@ -15,7 +15,10 @@ export type SetSettingValueAction = {
15
15
  data: {name: string; value: unknown};
16
16
  };
17
17
 
18
- export type SettingsAction = ReturnType<typeof changeFilter> | SetSettingValueAction;
18
+ export type SettingsAction =
19
+ | ReturnType<typeof changeFilter>
20
+ | ReturnType<typeof setUserSettings>
21
+ | SetSettingValueAction;
19
22
 
20
23
  export interface SettingsRootStateSlice {
21
24
  settings: SettingsState;
@@ -3,7 +3,6 @@ import {Selector, createSelector} from 'reselect';
3
3
  import type {OrderType} from '@gravity-ui/react-data-table';
4
4
  import {ASCENDING, DESCENDING} from '@gravity-ui/react-data-table/build/esm/lib/constants';
5
5
 
6
- import type {TVDiskStateInfo} from '../../../types/api/vdisk';
7
6
  import {NODES_SORT_VALUES, type NodesSortValue} from '../../../utils/nodes';
8
7
  import {STORAGE_SORT_VALUES, type StorageSortValue, getUsage} from '../../../utils/storage';
9
8
 
@@ -111,25 +110,6 @@ export const selectGroupsSortParams = (state: StorageStateSlice) => {
111
110
  };
112
111
  // ==== Complex selectors ====
113
112
 
114
- export const selectVDisksForPDisk: Selector<
115
- StorageStateSlice,
116
- TVDiskStateInfo[] | undefined,
117
- [number | undefined, number | undefined]
118
- > = createSelector(
119
- [
120
- selectStorageNodes,
121
- (_state, nodeId: number | undefined) => nodeId,
122
- (_state, _nodeId, pdiskId: number | undefined) => pdiskId,
123
- ],
124
- (storageNodes, nodeId, pdiskId) => {
125
- const targetNode = storageNodes?.find((node) => node.NodeId === nodeId);
126
- return targetNode?.VDisks?.filter((vdisk) => vdisk.PDiskId === pdiskId).map((data) => ({
127
- ...data,
128
- NodeId: nodeId,
129
- }));
130
- },
131
- );
132
-
133
113
  export const selectUsageFilterOptions: Selector<StorageStateSlice, UsageFilter[]> = createSelector(
134
114
  selectStorageGroups,
135
115
  (groups) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ydb-embedded-ui",
3
- "version": "4.27.0",
3
+ "version": "4.28.0",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -16,6 +16,8 @@
16
16
  "@gravity-ui/navigation": "^1.8.0",
17
17
  "@gravity-ui/paranoid": "^1.4.0",
18
18
  "@gravity-ui/react-data-table": "^1.0.3",
19
+ "@types/numeral": "^2.0.2",
20
+ "@types/qs": "^6.9.7",
19
21
  "@types/react": "^17.0.58",
20
22
  "axios": "0.19.2",
21
23
  "bem-cn-lite": "4.0.0",
@@ -27,6 +29,7 @@
27
29
  "monaco-editor": "0.24.0",
28
30
  "numeral": "2.0.6",
29
31
  "path-to-regexp": "3.0.0",
32
+ "qs": "^6.11.0",
30
33
  "react-json-inspector": "7.1.1",
31
34
  "react-list": "0.8.11",
32
35
  "react-monaco-editor": "0.30.1",
@@ -40,6 +43,7 @@
40
43
  "redux-thunk": "2.3.0",
41
44
  "reselect": "4.1.6",
42
45
  "sass": "1.32.8",
46
+ "url": "^0.11.0",
43
47
  "web-vitals": "1.1.2",
44
48
  "ydb-ui-components": "^3.5.0"
45
49
  },
@@ -118,8 +122,6 @@
118
122
  "@testing-library/react": "^11.2.7",
119
123
  "@testing-library/user-event": "^12.8.3",
120
124
  "@types/lodash": "^4.14.178",
121
- "@types/numeral": "^2.0.2",
122
- "@types/qs": "^6.9.7",
123
125
  "@types/react-dom": "^17.0.11",
124
126
  "@types/react-router": "^5.1.17",
125
127
  "@types/react-router-dom": "^5.3.2",
@@ -130,14 +132,12 @@
130
132
  "lint-staged": "^12.3.7",
131
133
  "postcss": "^8.4.6",
132
134
  "prettier": "^2.5.1",
133
- "qs": "^6.11.0",
134
135
  "react": "^17.0.2",
135
136
  "react-app-rewired": "^2.1.11",
136
137
  "react-dom": "^17.0.2",
137
138
  "stylelint": "^14.3.0",
138
139
  "ts-jest": "^28.0.7",
139
- "typescript": "^4.5.5",
140
- "url": "^0.11.0"
140
+ "typescript": "^4.5.5"
141
141
  },
142
142
  "peerDependencies": {
143
143
  "@gravity-ui/uikit": "^5.24.0"