ydb-embedded-ui 2.4.0 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.4.1](https://github.com/ydb-platform/ydb-embedded-ui/compare/v2.4.0...v2.4.1) (2022-11-01)
4
+
5
+
6
+ ### Performance Improvements
7
+
8
+ * **SchemaTree:** batch preloaded data dispatch ([c9ac514](https://github.com/ydb-platform/ydb-embedded-ui/commit/c9ac514aabf5e9674aae95956604f47ba8a2d257))
9
+
3
10
  ## [2.4.0](https://github.com/ydb-platform/ydb-embedded-ui/compare/v2.3.0...v2.4.0) (2022-10-27)
4
11
 
5
12
 
@@ -3,10 +3,10 @@ import {useDispatch} from 'react-redux';
3
3
 
4
4
  import {NavigationTree} from 'ydb-ui-components';
5
5
 
6
- import {setCurrentSchemaPath, getSchema, preloadSchema} from '../../../../store/reducers/schema';
6
+ import {setCurrentSchemaPath, getSchema, preloadSchemas} from '../../../../store/reducers/schema';
7
7
  import {getDescribe} from '../../../../store/reducers/describe';
8
8
  import {getSchemaAcl} from '../../../../store/reducers/schemaAcl';
9
- import type {EPathType} from '../../../../types/api/schema';
9
+ import type {EPathType, TEvDescribeSchemeResult} from '../../../../types/api/schema';
10
10
 
11
11
  import {mapPathTypeToNavigationTreeType} from '../../utils/schema';
12
12
  import {getActions} from '../../utils/schemaActions';
@@ -29,15 +29,15 @@ export function SchemaTree(props: SchemaTreeProps) {
29
29
  .then((data) => {
30
30
  const {PathDescription: {Children = []} = {}} = data;
31
31
 
32
- dispatch(preloadSchema(path, data));
32
+ const preloadedData: Record<string, TEvDescribeSchemeResult> = {
33
+ [path]: data
34
+ };
33
35
 
34
- return Children.map((childData) => {
36
+ const childItems = Children.map((childData) => {
35
37
  const {Name = '', PathType, PathSubType} = childData;
36
38
 
37
39
  // not full data, but it contains PathType, which ensures seamless switch between nodes
38
- dispatch(
39
- preloadSchema(`${path}/${Name}`, {PathDescription: {Self: childData}}),
40
- );
40
+ preloadedData[`${path}/${Name}`] = {PathDescription: {Self: childData}};
41
41
 
42
42
  return {
43
43
  name: Name,
@@ -47,6 +47,10 @@ export function SchemaTree(props: SchemaTreeProps) {
47
47
  expandable: true,
48
48
  };
49
49
  });
50
+
51
+ dispatch(preloadSchemas(preloadedData));
52
+
53
+ return childItems;
50
54
  });
51
55
 
52
56
  const handleActivePathUpdate = (activePath: string) => {
@@ -2,7 +2,7 @@ import {createRequestActionTypes, createApiRequest} from '../utils';
2
2
  import '../../services/api';
3
3
 
4
4
  const FETCH_SCHEMA = createRequestActionTypes('schema', 'FETCH_SCHEMA');
5
- const PRELOAD_SCHEMA = 'schema/PRELOAD_SCHEMA';
5
+ const PRELOAD_SCHEMAS = 'schema/PRELOAD_SCHEMAS';
6
6
  const SET_SCHEMA = 'schema/SET_SCHEMA';
7
7
  const SET_SHOW_PREVIEW = 'schema/SET_SHOW_PREVIEW';
8
8
  const ENABLE_AUTOREFRESH = 'schema/ENABLE_AUTOREFRESH';
@@ -54,16 +54,13 @@ const schema = (state = initialState, action) => {
54
54
  loading: false,
55
55
  };
56
56
  }
57
- case PRELOAD_SCHEMA: {
58
- if (state.data[action.path]) {
59
- return state;
60
- }
61
-
57
+ case PRELOAD_SCHEMAS: {
62
58
  return {
63
59
  ...state,
64
60
  data: {
61
+ // we don't want to overwrite existing paths
62
+ ...action.data,
65
63
  ...state.data,
66
- [action.path]: action.data,
67
64
  },
68
65
  };
69
66
  }
@@ -133,11 +130,11 @@ export function setShowPreview(value) {
133
130
  };
134
131
  }
135
132
 
136
- // only stores the passed data if the path doesn't exist yet
137
- export function preloadSchema(path, data) {
133
+ // only stores data for paths that are not in the store yet
134
+ // existing paths are ignored
135
+ export function preloadSchemas(data) {
138
136
  return {
139
- type: PRELOAD_SCHEMA,
140
- path,
137
+ type: PRELOAD_SCHEMAS,
141
138
  data,
142
139
  };
143
140
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ydb-embedded-ui",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
4
  "files": [
5
5
  "dist"
6
6
  ],