ydb-ui-components 1.1.1 → 1.2.0

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,29 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.2.0](https://github.com/ydb-platform/ydb-ui-components/compare/v1.1.3...v1.2.0) (2022-05-23)
4
+
5
+
6
+ ### Features
7
+
8
+ * a param to always refetch nodes data ([6cee325](https://github.com/ydb-platform/ydb-ui-components/commit/6cee32581d0a16ecc8bb742eb8f2c27d2d9a1cad))
9
+
10
+ ### [1.1.3](https://github.com/ydb-platform/ydb-ui-components/compare/v1.1.2...v1.1.3) (2022-05-23)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * add @yandex-cloud/uikit to peer deps ([61d5628](https://github.com/ydb-platform/ydb-ui-components/commit/61d5628088528e5c532c096bacebb2eca3f68206))
16
+
17
+ ### [1.1.2](https://github.com/ydb-platform/ydb-ui-components/compare/v1.1.1...v1.1.2) (2022-05-19)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * move react-treeview to prod deps ([#5](https://github.com/ydb-platform/ydb-ui-components/issues/5)) ([04d307b](https://github.com/ydb-platform/ydb-ui-components/commit/04d307b226b8b0d7bdaf58542df8d214fb49acce))
23
+ * @yandex-cloud/browserslist-config as peer dependency ([c3b48a7](https://github.com/ydb-platform/ydb-ui-components/commit/c3b48a7ea0370c854fb68b1e1fc12541e8a6494e))
24
+ * use provided root path ([203abd1](https://github.com/ydb-platform/ydb-ui-components/commit/203abd1892ad1e8c8c4555b06b99aa41ff01ab01))
25
+ * include i18n files ([8363de6](https://github.com/ydb-platform/ydb-ui-components/commit/8363de686cbad9e10753b47a62e7917610dcc84d))
26
+
3
27
  ### [1.1.1](https://www.github.com/ydb-platform/ydb-ui-components/compare/v1.1.0...v1.1.1) (2022-05-13)
4
28
 
5
29
 
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { NavigationTreeProps } from './types';
3
3
  export type { NavigationTreeProps };
4
- export declare function NavigationTree({ rootState: partialRootState, fetchPath, getActions, activePath, onActivePathUpdate, }: NavigationTreeProps): JSX.Element;
4
+ export declare function NavigationTree({ rootState: partialRootState, fetchPath, getActions, activePath, onActivePathUpdate, cache, }: NavigationTreeProps): JSX.Element;
@@ -27,7 +27,8 @@ function NavigationTree(_ref) {
27
27
  fetchPath,
28
28
  getActions,
29
29
  activePath,
30
- onActivePathUpdate
30
+ onActivePathUpdate,
31
+ cache
31
32
  } = _ref;
32
33
 
33
34
  const [state, dispatch] = _react.default.useReducer(_state.reducer, {
@@ -45,10 +46,11 @@ function NavigationTree(_ref) {
45
46
  }, /*#__PURE__*/_react.default.createElement(_NavigationTreeDirectory.NavigationTreeDirectory, {
46
47
  state: state,
47
48
  dispatch: dispatch,
48
- path: "",
49
+ path: rootState.path,
49
50
  fetchPath: fetchPath,
50
51
  activePath: activePath,
51
52
  onItemActivate: onActivePathUpdate,
52
- getActions: getActions
53
+ getActions: getActions,
54
+ cache: cache
53
55
  }));
54
56
  }
@@ -9,5 +9,6 @@ export interface NavigationTreeDirectoryProps {
9
9
  activePath?: string;
10
10
  onItemActivate?: (itemPath: string) => void;
11
11
  getActions?: NavigationTreeProps['getActions'];
12
+ cache?: boolean;
12
13
  }
13
- export declare function NavigationTreeDirectory({ state, dispatch, path, fetchPath, activePath, onItemActivate, getActions, }: NavigationTreeDirectoryProps): JSX.Element;
14
+ export declare function NavigationTreeDirectory({ state, dispatch, path, fetchPath, activePath, onItemActivate, getActions, cache, }: NavigationTreeDirectoryProps): JSX.Element;
@@ -27,36 +27,39 @@ function NavigationTreeDirectory(_ref) {
27
27
  fetchPath,
28
28
  activePath,
29
29
  onItemActivate,
30
- getActions
30
+ getActions,
31
+ cache = true
31
32
  } = _ref;
32
33
  const nodeState = state[path];
33
34
 
34
35
  _react.default.useEffect(() => {
35
- if (!nodeState.loaded && !nodeState.loading) {
36
+ if (nodeState.loaded && cache || nodeState.loading) {
37
+ return;
38
+ }
39
+
40
+ dispatch({
41
+ type: _state.NavigationTreeActionType.StartLoading,
42
+ payload: {
43
+ path
44
+ }
45
+ });
46
+ fetchPath(path).then(data => {
36
47
  dispatch({
37
- type: _state.NavigationTreeActionType.StartLoading,
48
+ type: _state.NavigationTreeActionType.FinishLoading,
38
49
  payload: {
39
- path
50
+ path,
51
+ data
40
52
  }
41
53
  });
42
- fetchPath(path).then(data => {
43
- dispatch({
44
- type: _state.NavigationTreeActionType.FinishLoading,
45
- payload: {
46
- path,
47
- data
48
- }
49
- });
50
- }).catch(error => {
51
- dispatch({
52
- type: _state.NavigationTreeActionType.FinishLoading,
53
- payload: {
54
- path,
55
- error
56
- }
57
- });
54
+ }).catch(error => {
55
+ dispatch({
56
+ type: _state.NavigationTreeActionType.FinishLoading,
57
+ payload: {
58
+ path,
59
+ error
60
+ }
58
61
  });
59
- }
62
+ });
60
63
  }, []);
61
64
 
62
65
  if (nodeState.loading) {
@@ -80,7 +83,8 @@ function NavigationTreeDirectory(_ref) {
80
83
  fetchPath: fetchPath,
81
84
  activePath: activePath,
82
85
  onItemActivate: onItemActivate,
83
- getActions: getActions
86
+ getActions: getActions,
87
+ cache: cache
84
88
  });
85
89
  }
86
90
 
@@ -0,0 +1,4 @@
1
+ {
2
+ "label_error": "Error",
3
+ "label_empty": "No data"
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "label_error": "Ошибка",
3
+ "label_empty": "Нет данных"
4
+ }
@@ -49,7 +49,8 @@ function reducer() {
49
49
  [action.payload.path]: _objectSpread(_objectSpread({}, state[action.payload.path]), {}, {
50
50
  loading: true,
51
51
  loaded: false,
52
- error: false
52
+ error: false,
53
+ children: []
53
54
  })
54
55
  });
55
56
 
@@ -23,4 +23,5 @@ export interface NavigationTreeProps<D = any> {
23
23
  getActions?: (path: string, type: NavigationTreeNodeType) => DropdownMenuItemMixed<D>[];
24
24
  activePath?: string;
25
25
  onActivePathUpdate?: (activePath: string) => void;
26
+ cache?: boolean;
26
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ydb-ui-components",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "main": "build/index.js",
@@ -23,7 +23,8 @@
23
23
  "prepublishOnly": "npm run build"
24
24
  },
25
25
  "dependencies": {
26
- "bem-cn-lite": "^4.1.0"
26
+ "bem-cn-lite": "^4.1.0",
27
+ "react-treeview": "^0.4.7"
27
28
  },
28
29
  "devDependencies": {
29
30
  "@babel/core": "^7.17.8",
@@ -56,7 +57,6 @@
56
57
  "react": "^16.14.0",
57
58
  "react-docgen-typescript": "^2.2.2",
58
59
  "react-dom": "^16.14.0",
59
- "react-treeview": "^0.4.7",
60
60
  "rimraf": "^3.0.2",
61
61
  "sass": "^1.49.9",
62
62
  "sass-loader": "^10.2.1",
@@ -65,7 +65,9 @@
65
65
  "typescript": "^4.6.2"
66
66
  },
67
67
  "peerDependencies": {
68
+ "@yandex-cloud/browserslist-config": "^1.0.1",
68
69
  "@yandex-cloud/i18n": "^0.4.0",
70
+ "@yandex-cloud/uikit": "^1.8.0",
69
71
  "react": "^16.0.0",
70
72
  "react-dom": "^16.0.0"
71
73
  },