ydb-ui-components 1.1.3 → 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 +7 -0
- package/build/components/NavigationTree/NavigationTree.d.ts +1 -1
- package/build/components/NavigationTree/NavigationTree.js +4 -2
- package/build/components/NavigationTree/NavigationTreeDirectory.d.ts +2 -1
- package/build/components/NavigationTree/NavigationTreeDirectory.js +26 -22
- package/build/components/NavigationTree/state.js +2 -1
- package/build/components/NavigationTree/types.d.ts +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
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
|
+
|
|
3
10
|
### [1.1.3](https://github.com/ydb-platform/ydb-ui-components/compare/v1.1.2...v1.1.3) (2022-05-23)
|
|
4
11
|
|
|
5
12
|
|
|
@@ -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, {
|
|
@@ -49,6 +50,7 @@ function NavigationTree(_ref) {
|
|
|
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 (
|
|
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.
|
|
48
|
+
type: _state.NavigationTreeActionType.FinishLoading,
|
|
38
49
|
payload: {
|
|
39
|
-
path
|
|
50
|
+
path,
|
|
51
|
+
data
|
|
40
52
|
}
|
|
41
53
|
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
|