@dhis2-ui/organisation-unit-tree 10.16.3-alpha.1 → 10.16.4
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/build/cjs/__e2e__/children_as_child_nodes.js +8 -11
- package/build/cjs/__e2e__/common.js +19 -26
- package/build/cjs/__e2e__/controlled_expanded.js +7 -10
- package/build/cjs/__e2e__/displaying_loading_error.js +1 -4
- package/build/cjs/__e2e__/expanded.js +25 -34
- package/build/cjs/__e2e__/force_reload.js +15 -22
- package/build/cjs/__e2e__/get-organisation-unit-data.js +25 -29
- package/build/cjs/__e2e__/highlight.js +7 -10
- package/build/cjs/__e2e__/loading_state.js +7 -13
- package/build/cjs/__e2e__/multi_selection.js +8 -11
- package/build/cjs/__e2e__/no_selection.js +15 -21
- package/build/cjs/__e2e__/path_based_filtering.js +16 -22
- package/build/cjs/__e2e__/single_selection.js +10 -16
- package/build/cjs/__e2e__/sub_unit_as_root.js +5 -7
- package/build/cjs/__e2e__/tree_api.js +15 -21
- package/build/cjs/__stories__/custom-expanded-imperative-open.js +7 -10
- package/build/cjs/__stories__/custom-node-label.js +4 -5
- package/build/cjs/__stories__/development-stories.js +6 -8
- package/build/cjs/__stories__/force-reload-all.js +1 -2
- package/build/cjs/__stories__/loading-error-grandchild.js +1 -4
- package/build/cjs/__stories__/loading.js +1 -4
- package/build/cjs/__stories__/multiple-roots.js +9 -12
- package/build/cjs/__stories__/root-error.js +1 -4
- package/build/cjs/__stories__/root-loading.js +1 -4
- package/build/cjs/__stories__/shared.js +46 -79
- package/build/cjs/features/controlled_expanded/index.js +3 -6
- package/build/cjs/locales/index.js +49 -27
- package/build/cjs/organisation-unit-node/error-message.js +10 -13
- package/build/cjs/organisation-unit-node/label/disabled-selection-label.js +9 -12
- package/build/cjs/organisation-unit-node/label/icon-empty.js +19 -22
- package/build/cjs/organisation-unit-node/label/icon-folder-closed.js +25 -28
- package/build/cjs/organisation-unit-node/label/icon-folder-open.js +34 -37
- package/build/cjs/organisation-unit-node/label/icon-single.js +28 -31
- package/build/cjs/organisation-unit-node/label/icon.js +6 -7
- package/build/cjs/organisation-unit-node/label/iconized-checkbox.js +12 -13
- package/build/cjs/organisation-unit-node/label/label-container.js +13 -16
- package/build/cjs/organisation-unit-node/label/label.js +27 -30
- package/build/cjs/organisation-unit-node/label/single-selection-label.js +18 -21
- package/build/cjs/organisation-unit-node/organisation-unit-node-children.js +27 -29
- package/build/cjs/organisation-unit-node/organisation-unit-node.js +22 -23
- package/build/cjs/organisation-unit-node/use-open-state.js +8 -9
- package/build/cjs/organisation-unit-node/use-org-children.js +14 -21
- package/build/cjs/organisation-unit-node/use-org-children.test.js +40 -59
- package/build/cjs/organisation-unit-node/use-org-data/use-org-data.js +13 -20
- package/build/cjs/organisation-unit-node/use-org-data/use-org-data.test.js +17 -27
- package/build/cjs/organisation-unit-tree/default-render-node-label/default-render-node-label.js +3 -6
- package/build/cjs/organisation-unit-tree/organisation-unit-tree-root-error.js +9 -12
- package/build/cjs/organisation-unit-tree/organisation-unit-tree-root-loading.js +10 -13
- package/build/cjs/organisation-unit-tree/organisation-unit-tree.js +24 -26
- package/build/cjs/organisation-unit-tree/use-expanded/create-expand-handlers.js +14 -17
- package/build/cjs/organisation-unit-tree/use-expanded/use-expanded.js +8 -9
- package/build/cjs/organisation-unit-tree/use-root-org-data/patch-missing-display-name.js +1 -2
- package/build/cjs/organisation-unit-tree/use-root-org-data/use-root-org-data.js +10 -14
- package/build/cjs/organisation-unit-tree/use-root-org-data/use-root-org-unit.test.js +32 -46
- package/build/es/__e2e__/children_as_child_nodes.js +8 -11
- package/build/es/__e2e__/common.js +18 -24
- package/build/es/__e2e__/controlled_expanded.js +6 -8
- package/build/es/__e2e__/displaying_loading_error.js +1 -4
- package/build/es/__e2e__/expanded.js +25 -34
- package/build/es/__e2e__/force_reload.js +14 -20
- package/build/es/__e2e__/get-organisation-unit-data.js +25 -29
- package/build/es/__e2e__/highlight.js +7 -10
- package/build/es/__e2e__/loading_state.js +7 -13
- package/build/es/__e2e__/multi_selection.js +8 -11
- package/build/es/__e2e__/no_selection.js +15 -21
- package/build/es/__e2e__/path_based_filtering.js +16 -22
- package/build/es/__e2e__/single_selection.js +10 -16
- package/build/es/__e2e__/sub_unit_as_root.js +4 -5
- package/build/es/__e2e__/tree_api.js +15 -21
- package/build/es/__stories__/custom-expanded-imperative-open.js +6 -8
- package/build/es/__stories__/custom-node-label.js +4 -5
- package/build/es/__stories__/development-stories.js +5 -6
- package/build/es/__stories__/loading-error-grandchild.js +1 -4
- package/build/es/__stories__/loading.js +1 -4
- package/build/es/__stories__/multiple-roots.js +9 -12
- package/build/es/__stories__/root-error.js +1 -4
- package/build/es/__stories__/root-loading.js +1 -4
- package/build/es/__stories__/shared.js +45 -77
- package/build/es/features/controlled_expanded/index.js +3 -6
- package/build/es/locales/index.js +40 -18
- package/build/es/organisation-unit-node/error-message.js +10 -13
- package/build/es/organisation-unit-node/label/disabled-selection-label.js +9 -12
- package/build/es/organisation-unit-node/label/icon-empty.js +19 -22
- package/build/es/organisation-unit-node/label/icon-folder-closed.js +25 -28
- package/build/es/organisation-unit-node/label/icon-folder-open.js +34 -37
- package/build/es/organisation-unit-node/label/icon-single.js +28 -31
- package/build/es/organisation-unit-node/label/icon.js +6 -7
- package/build/es/organisation-unit-node/label/iconized-checkbox.js +12 -13
- package/build/es/organisation-unit-node/label/label-container.js +13 -16
- package/build/es/organisation-unit-node/label/label.js +27 -30
- package/build/es/organisation-unit-node/label/single-selection-label.js +18 -21
- package/build/es/organisation-unit-node/organisation-unit-node-children.js +27 -29
- package/build/es/organisation-unit-node/organisation-unit-node.js +22 -23
- package/build/es/organisation-unit-node/use-open-state.js +8 -9
- package/build/es/organisation-unit-node/use-org-children.js +14 -21
- package/build/es/organisation-unit-node/use-org-children.test.js +40 -59
- package/build/es/organisation-unit-node/use-org-data/use-org-data.js +13 -20
- package/build/es/organisation-unit-node/use-org-data/use-org-data.test.js +17 -27
- package/build/es/organisation-unit-tree/default-render-node-label/default-render-node-label.js +3 -6
- package/build/es/organisation-unit-tree/organisation-unit-tree-root-error.js +9 -12
- package/build/es/organisation-unit-tree/organisation-unit-tree-root-loading.js +10 -13
- package/build/es/organisation-unit-tree/organisation-unit-tree.js +23 -24
- package/build/es/organisation-unit-tree/use-expanded/create-expand-handlers.js +14 -17
- package/build/es/organisation-unit-tree/use-expanded/use-expanded.js +8 -9
- package/build/es/organisation-unit-tree/use-root-org-data/patch-missing-display-name.js +1 -2
- package/build/es/organisation-unit-tree/use-root-org-data/use-root-org-data.js +10 -14
- package/build/es/organisation-unit-tree/use-root-org-data/use-root-org-unit.test.js +32 -46
- package/package.json +6 -6
- package/src/locales/index.js +57 -18
- package/src/organisation-unit-tree/use-root-org-data/use-root-org-unit.test.js +14 -14
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import i18n from '../locales/index.js';
|
|
4
|
-
export const OrganisationUnitTreeRootError =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
nsSeparator: '>'
|
|
14
|
-
}));
|
|
15
|
-
};
|
|
4
|
+
export const OrganisationUnitTreeRootError = ({
|
|
5
|
+
dataTest = 'dhis2-uiwidgets-orgunittree-error',
|
|
6
|
+
error
|
|
7
|
+
}) => /*#__PURE__*/React.createElement("div", {
|
|
8
|
+
"data-test": dataTest
|
|
9
|
+
}, i18n.t('Error: {{ ERRORMESSAGE }}', {
|
|
10
|
+
ERRORMESSAGE: error,
|
|
11
|
+
nsSeparator: '>'
|
|
12
|
+
}));
|
|
16
13
|
OrganisationUnitTreeRootError.propTypes = {
|
|
17
14
|
error: PropTypes.string.isRequired,
|
|
18
15
|
dataTest: PropTypes.string
|
|
@@ -2,19 +2,16 @@ import _JSXStyle from "styled-jsx/style";
|
|
|
2
2
|
import { CircularLoader } from '@dhis2-ui/loader';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import React from 'react';
|
|
5
|
-
export const OrganisationUnitTreeRootLoading =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
id: "814846266"
|
|
16
|
-
}, ["div.jsx-814846266{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;}"]));
|
|
17
|
-
};
|
|
5
|
+
export const OrganisationUnitTreeRootLoading = ({
|
|
6
|
+
dataTest = 'dhis2-uiwidgets-orgunittree-loading'
|
|
7
|
+
}) => /*#__PURE__*/React.createElement("div", {
|
|
8
|
+
"data-test": dataTest,
|
|
9
|
+
className: "jsx-814846266"
|
|
10
|
+
}, /*#__PURE__*/React.createElement(CircularLoader, {
|
|
11
|
+
small: true
|
|
12
|
+
}), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
13
|
+
id: "814846266"
|
|
14
|
+
}, ["div.jsx-814846266{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;}"]));
|
|
18
15
|
OrganisationUnitTreeRootLoading.propTypes = {
|
|
19
16
|
dataTest: PropTypes.string
|
|
20
17
|
};
|
|
@@ -13,30 +13,29 @@ import { useRootOrgData } from './use-root-org-data/index.js';
|
|
|
13
13
|
|
|
14
14
|
// A stable object to reference
|
|
15
15
|
const staticArray = [];
|
|
16
|
-
const OrganisationUnitTree =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
} = _ref;
|
|
16
|
+
const OrganisationUnitTree = ({
|
|
17
|
+
onChange,
|
|
18
|
+
roots,
|
|
19
|
+
autoExpandLoadingError,
|
|
20
|
+
dataTest = 'dhis2-uiwidgets-orgunittree',
|
|
21
|
+
disableSelection,
|
|
22
|
+
displayProperty = 'displayName',
|
|
23
|
+
forceReload,
|
|
24
|
+
highlighted = staticArray,
|
|
25
|
+
isUserDataViewFallback,
|
|
26
|
+
initiallyExpanded = staticArray,
|
|
27
|
+
filter = staticArray,
|
|
28
|
+
renderNodeLabel = defaultRenderNodeLabel,
|
|
29
|
+
selected = staticArray,
|
|
30
|
+
singleSelection,
|
|
31
|
+
suppressAlphabeticalSorting,
|
|
32
|
+
expanded: expandedControlled,
|
|
33
|
+
handleExpand: handleExpandControlled,
|
|
34
|
+
handleCollapse: handleCollapseControlled,
|
|
35
|
+
onExpand,
|
|
36
|
+
onCollapse,
|
|
37
|
+
onChildrenLoaded
|
|
38
|
+
}) => {
|
|
40
39
|
const rootIds = filterRootIds(filter, Array.isArray(roots) ? roots : [roots]);
|
|
41
40
|
const reloadId = useForceReload(forceReload);
|
|
42
41
|
const [prevReloadId, setPrevReloadId] = useState(reloadId);
|
|
@@ -6,18 +6,16 @@
|
|
|
6
6
|
* @param {Function} [args.onCollapse]
|
|
7
7
|
* @returns {{ handleExpand: Function, handleCollapse: Function }}
|
|
8
8
|
*/
|
|
9
|
-
export const createExpandHandlers =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
...rest
|
|
20
|
-
} = _ref2;
|
|
9
|
+
export const createExpandHandlers = ({
|
|
10
|
+
expanded,
|
|
11
|
+
setExpanded,
|
|
12
|
+
onExpand,
|
|
13
|
+
onCollapse
|
|
14
|
+
}) => {
|
|
15
|
+
const handleExpand = ({
|
|
16
|
+
path,
|
|
17
|
+
...rest
|
|
18
|
+
}) => {
|
|
21
19
|
if (!expanded.includes(path)) {
|
|
22
20
|
setExpanded([...expanded, path]);
|
|
23
21
|
if (onExpand) {
|
|
@@ -28,11 +26,10 @@ export const createExpandHandlers = _ref => {
|
|
|
28
26
|
}
|
|
29
27
|
}
|
|
30
28
|
};
|
|
31
|
-
const handleCollapse =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
} = _ref3;
|
|
29
|
+
const handleCollapse = ({
|
|
30
|
+
path,
|
|
31
|
+
...rest
|
|
32
|
+
}) => {
|
|
36
33
|
const pathIndex = expanded.indexOf(path);
|
|
37
34
|
if (pathIndex !== -1) {
|
|
38
35
|
const updatedExpanded = pathIndex === 0 ? expanded.slice(1) : [...expanded.slice(0, pathIndex), ...expanded.slice(pathIndex + 1)];
|
|
@@ -8,15 +8,14 @@ import { createExpandHandlers } from './create-expand-handlers.js';
|
|
|
8
8
|
* @param {Function} [onCollapse]
|
|
9
9
|
* @returns {{ expanded: string[], handleExpand: Function, handleCollapse: Function }}
|
|
10
10
|
*/
|
|
11
|
-
export const useExpanded =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} = _ref;
|
|
11
|
+
export const useExpanded = ({
|
|
12
|
+
initiallyExpanded,
|
|
13
|
+
onExpand,
|
|
14
|
+
onCollapse,
|
|
15
|
+
expandedControlled,
|
|
16
|
+
handleExpandControlled,
|
|
17
|
+
handleCollapseControlled
|
|
18
|
+
}) => {
|
|
20
19
|
const isControlled = !!expandedControlled;
|
|
21
20
|
const allInitiallyExpandedPaths = isControlled ? [] : getAllExpandedPaths(initiallyExpanded);
|
|
22
21
|
const [expanded, setExpanded] = useState(allInitiallyExpandedPaths);
|
|
@@ -11,8 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
export const patchMissingDisplayName = nodes => {
|
|
13
13
|
const nodeEntries = Object.entries(nodes);
|
|
14
|
-
const nodesWithDisplayName = nodeEntries.map(
|
|
15
|
-
let [id, node] = _ref;
|
|
14
|
+
const nodesWithDisplayName = nodeEntries.map(([id, node]) => {
|
|
16
15
|
const displayName = node.displayName || '';
|
|
17
16
|
return [id, {
|
|
18
17
|
...node,
|
|
@@ -6,15 +6,12 @@ export const createRootQuery = (ids, displayProperty) => ids.reduce((query, id)
|
|
|
6
6
|
[id]: {
|
|
7
7
|
id,
|
|
8
8
|
resource: `organisationUnits`,
|
|
9
|
-
params:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
fields: [displayProperty === 'displayName' ? 'displayName' : `${displayProperty}~rename(displayName)`, 'path', 'id']
|
|
16
|
-
};
|
|
17
|
-
}
|
|
9
|
+
params: ({
|
|
10
|
+
isUserDataViewFallback
|
|
11
|
+
}) => ({
|
|
12
|
+
isUserDataViewFallback,
|
|
13
|
+
fields: [displayProperty === 'displayName' ? 'displayName' : `${displayProperty}~rename(displayName)`, 'path', 'id']
|
|
14
|
+
})
|
|
18
15
|
}
|
|
19
16
|
}), {});
|
|
20
17
|
|
|
@@ -26,11 +23,10 @@ export const createRootQuery = (ids, displayProperty) => ids.reduce((query, id)
|
|
|
26
23
|
* @param {'displayName'|'displayShortName'} [options.displayProperty]
|
|
27
24
|
* @returns {Object}
|
|
28
25
|
*/
|
|
29
|
-
export const useRootOrgData =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
26
|
+
export const useRootOrgData = (ids, {
|
|
27
|
+
isUserDataViewFallback,
|
|
28
|
+
displayProperty = 'displayName'
|
|
29
|
+
} = {}) => {
|
|
34
30
|
const query = useMemo(() => createRootQuery(ids, displayProperty), [ids, displayProperty]);
|
|
35
31
|
const variables = {
|
|
36
32
|
isUserDataViewFallback
|
|
@@ -5,10 +5,7 @@ import { useRootOrgData } from './use-root-org-data.js';
|
|
|
5
5
|
describe('OrganisationUnitTree - useRootOrgData', () => {
|
|
6
6
|
// @TODO: Figure out why this is necessary at all...
|
|
7
7
|
const origError = console.error;
|
|
8
|
-
jest.spyOn(console, 'error').mockImplementation(
|
|
9
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
10
|
-
args[_key] = arguments[_key];
|
|
11
|
-
}
|
|
8
|
+
jest.spyOn(console, 'error').mockImplementation((...args) => {
|
|
12
9
|
const [err] = args;
|
|
13
10
|
if (!err.toString().match(/^Warning: An update to/)) {
|
|
14
11
|
origError(...args);
|
|
@@ -18,10 +15,7 @@ describe('OrganisationUnitTree - useRootOrgData', () => {
|
|
|
18
15
|
// @TODO: This is kind of necessary; no idea if we can get rid of this
|
|
19
16
|
const origWarn = console.warn;
|
|
20
17
|
const dynamicQueryWarningMsg = "The query should be static, don't create it within the render loop!";
|
|
21
|
-
jest.spyOn(console, 'warn').mockImplementation(
|
|
22
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
23
|
-
args[_key2] = arguments[_key2];
|
|
24
|
-
}
|
|
18
|
+
jest.spyOn(console, 'warn').mockImplementation((...args) => {
|
|
25
19
|
const [err] = args;
|
|
26
20
|
if (!err.toString().match(dynamicQueryWarningMsg)) {
|
|
27
21
|
origWarn(...args);
|
|
@@ -40,14 +34,11 @@ describe('OrganisationUnitTree - useRootOrgData', () => {
|
|
|
40
34
|
};
|
|
41
35
|
})
|
|
42
36
|
};
|
|
43
|
-
const wrapper =
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
data: dataProviderData
|
|
49
|
-
}, children);
|
|
50
|
-
};
|
|
37
|
+
const wrapper = ({
|
|
38
|
+
children
|
|
39
|
+
}) => /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
40
|
+
data: dataProviderData
|
|
41
|
+
}, children);
|
|
51
42
|
it('should respond with `loading: false`, `error: null` and `data: null` initially', () => {
|
|
52
43
|
const {
|
|
53
44
|
result
|
|
@@ -67,32 +58,30 @@ describe('OrganisationUnitTree - useRootOrgData', () => {
|
|
|
67
58
|
} = renderHook(() => useRootOrgData(['A0000000000']), {
|
|
68
59
|
wrapper
|
|
69
60
|
});
|
|
70
|
-
await waitFor(() => {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
61
|
+
await waitFor(() => {
|
|
62
|
+
expect(result.current).toEqual(expect.objectContaining({
|
|
63
|
+
loading: false,
|
|
64
|
+
error: null,
|
|
65
|
+
data: {
|
|
66
|
+
A0000000000: {
|
|
67
|
+
id: 'A0000000000',
|
|
68
|
+
path: '/A0000000000',
|
|
69
|
+
displayName: 'Org Unit 1'
|
|
70
|
+
}
|
|
79
71
|
}
|
|
80
|
-
}
|
|
81
|
-
})
|
|
72
|
+
}));
|
|
73
|
+
});
|
|
82
74
|
});
|
|
83
75
|
it('should provide the error', async () => {
|
|
84
|
-
const errorWrapper =
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
organisationUnits: async () => {
|
|
91
|
-
throw new Error('Error message');
|
|
92
|
-
}
|
|
76
|
+
const errorWrapper = ({
|
|
77
|
+
children
|
|
78
|
+
}) => /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
79
|
+
data: {
|
|
80
|
+
organisationUnits: async () => {
|
|
81
|
+
throw new Error('Error message');
|
|
93
82
|
}
|
|
94
|
-
}
|
|
95
|
-
};
|
|
83
|
+
}
|
|
84
|
+
}, children);
|
|
96
85
|
const {
|
|
97
86
|
result
|
|
98
87
|
} = renderHook(() => useRootOrgData(['A0000000000']), {
|
|
@@ -142,14 +131,11 @@ describe('OrganisationUnitTree - useRootOrgData', () => {
|
|
|
142
131
|
};
|
|
143
132
|
})
|
|
144
133
|
};
|
|
145
|
-
const wrapperWithoutDisplayName =
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
data: dataProviderDataWithoutDisplayName
|
|
151
|
-
}, children);
|
|
152
|
-
};
|
|
134
|
+
const wrapperWithoutDisplayName = ({
|
|
135
|
+
children
|
|
136
|
+
}) => /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
137
|
+
data: dataProviderDataWithoutDisplayName
|
|
138
|
+
}, children);
|
|
153
139
|
const {
|
|
154
140
|
result
|
|
155
141
|
} = renderHook(() => useRootOrgData(['A0000000000']), {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhis2-ui/organisation-unit-tree",
|
|
3
|
-
"version": "10.16.
|
|
3
|
+
"version": "10.16.4",
|
|
4
4
|
"description": "UI OrganisationUnitTree",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@dhis2/prop-types": "^3.1.2",
|
|
38
|
-
"@dhis2-ui/button": "10.16.
|
|
39
|
-
"@dhis2-ui/checkbox": "10.16.
|
|
40
|
-
"@dhis2-ui/loader": "10.16.
|
|
41
|
-
"@dhis2-ui/node": "10.16.
|
|
42
|
-
"@dhis2/ui-constants": "10.16.
|
|
38
|
+
"@dhis2-ui/button": "10.16.4",
|
|
39
|
+
"@dhis2-ui/checkbox": "10.16.4",
|
|
40
|
+
"@dhis2-ui/loader": "10.16.4",
|
|
41
|
+
"@dhis2-ui/node": "10.16.4",
|
|
42
|
+
"@dhis2/ui-constants": "10.16.4",
|
|
43
43
|
"classnames": "^2.3.1",
|
|
44
44
|
"prop-types": "^15.7.2"
|
|
45
45
|
},
|
package/src/locales/index.js
CHANGED
|
@@ -28,23 +28,62 @@ import zhTranslations from './zh/translations.json'
|
|
|
28
28
|
import zh_CNTranslations from './zh_CN/translations.json'
|
|
29
29
|
|
|
30
30
|
const namespace = 'default'
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
i18n.
|
|
36
|
-
i18n.
|
|
37
|
-
|
|
38
|
-
i18n.
|
|
39
|
-
i18n.
|
|
40
|
-
|
|
41
|
-
i18n.
|
|
42
|
-
i18n.
|
|
43
|
-
|
|
44
|
-
i18n.
|
|
45
|
-
i18n.
|
|
46
|
-
|
|
47
|
-
i18n.
|
|
48
|
-
i18n.
|
|
31
|
+
|
|
32
|
+
// Use 'deep' = true and 'overwrite' = false to add to, but not overwrite,
|
|
33
|
+
// custom translations from the datastore (added by the app adapter)
|
|
34
|
+
|
|
35
|
+
i18n.addResourceBundle('ar', namespace, arTranslations, true, false)
|
|
36
|
+
i18n.addResourceBundle('ar', namespace, arTranslations, true, false)
|
|
37
|
+
|
|
38
|
+
i18n.addResourceBundle('cs', namespace, csTranslations, true, false)
|
|
39
|
+
i18n.addResourceBundle('cs', namespace, csTranslations, true, false)
|
|
40
|
+
|
|
41
|
+
i18n.addResourceBundle('en', namespace, enTranslations, true, false)
|
|
42
|
+
i18n.addResourceBundle('en', namespace, enTranslations, true, false)
|
|
43
|
+
|
|
44
|
+
i18n.addResourceBundle('es', namespace, esTranslations, true, false)
|
|
45
|
+
i18n.addResourceBundle('es', namespace, esTranslations, true, false)
|
|
46
|
+
|
|
47
|
+
i18n.addResourceBundle('es_419', namespace, es_419Translations, true, false)
|
|
48
|
+
i18n.addResourceBundle('es-419', namespace, es_419Translations, true, false)
|
|
49
|
+
|
|
50
|
+
i18n.addResourceBundle('fr', namespace, frTranslations, true, false)
|
|
51
|
+
i18n.addResourceBundle('fr', namespace, frTranslations, true, false)
|
|
52
|
+
|
|
53
|
+
i18n.addResourceBundle('lo', namespace, loTranslations, true, false)
|
|
54
|
+
i18n.addResourceBundle('lo', namespace, loTranslations, true, false)
|
|
55
|
+
|
|
56
|
+
i18n.addResourceBundle('nb', namespace, nbTranslations, true, false)
|
|
57
|
+
i18n.addResourceBundle('nb', namespace, nbTranslations, true, false)
|
|
58
|
+
|
|
59
|
+
i18n.addResourceBundle('nl', namespace, nlTranslations, true, false)
|
|
60
|
+
i18n.addResourceBundle('nl', namespace, nlTranslations, true, false)
|
|
61
|
+
|
|
62
|
+
i18n.addResourceBundle('pt', namespace, ptTranslations, true, false)
|
|
63
|
+
i18n.addResourceBundle('pt', namespace, ptTranslations, true, false)
|
|
64
|
+
|
|
65
|
+
i18n.addResourceBundle('ru', namespace, ruTranslations, true, false)
|
|
66
|
+
i18n.addResourceBundle('ru', namespace, ruTranslations, true, false)
|
|
67
|
+
|
|
68
|
+
i18n.addResourceBundle('uk', namespace, ukTranslations, true, false)
|
|
69
|
+
i18n.addResourceBundle('uk', namespace, ukTranslations, true, false)
|
|
70
|
+
|
|
71
|
+
i18n.addResourceBundle('uz_Latn', namespace, uz_LatnTranslations, true, false)
|
|
72
|
+
i18n.addResourceBundle('uz-Latn', namespace, uz_LatnTranslations, true, false)
|
|
73
|
+
|
|
74
|
+
i18n.addResourceBundle('uz_UZ_Cyrl', namespace, uz_UZ_CyrlTranslations, true, false)
|
|
75
|
+
i18n.addResourceBundle('uz-Cyrl-UZ', namespace, uz_UZ_CyrlTranslations, true, false)
|
|
76
|
+
|
|
77
|
+
i18n.addResourceBundle('uz_UZ_Latn', namespace, uz_UZ_LatnTranslations, true, false)
|
|
78
|
+
i18n.addResourceBundle('uz-Latn-UZ', namespace, uz_UZ_LatnTranslations, true, false)
|
|
79
|
+
|
|
80
|
+
i18n.addResourceBundle('vi', namespace, viTranslations, true, false)
|
|
81
|
+
i18n.addResourceBundle('vi', namespace, viTranslations, true, false)
|
|
82
|
+
|
|
83
|
+
i18n.addResourceBundle('zh', namespace, zhTranslations, true, false)
|
|
84
|
+
i18n.addResourceBundle('zh', namespace, zhTranslations, true, false)
|
|
85
|
+
|
|
86
|
+
i18n.addResourceBundle('zh_CN', namespace, zh_CNTranslations, true, false)
|
|
87
|
+
i18n.addResourceBundle('zh-CN', namespace, zh_CNTranslations, true, false)
|
|
49
88
|
|
|
50
89
|
export default i18n
|
|
@@ -67,21 +67,21 @@ describe('OrganisationUnitTree - useRootOrgData', () => {
|
|
|
67
67
|
wrapper,
|
|
68
68
|
})
|
|
69
69
|
|
|
70
|
-
await waitFor(() => {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
70
|
+
await waitFor(() => {
|
|
71
|
+
expect(result.current).toEqual(
|
|
72
|
+
expect.objectContaining({
|
|
73
|
+
loading: false,
|
|
74
|
+
error: null,
|
|
75
|
+
data: {
|
|
76
|
+
A0000000000: {
|
|
77
|
+
id: 'A0000000000',
|
|
78
|
+
path: '/A0000000000',
|
|
79
|
+
displayName: 'Org Unit 1',
|
|
80
|
+
},
|
|
81
81
|
},
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
)
|
|
82
|
+
})
|
|
83
|
+
)
|
|
84
|
+
})
|
|
85
85
|
})
|
|
86
86
|
|
|
87
87
|
it('should provide the error', async () => {
|