@truedat/dd 4.32.1 → 4.33.3
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 +12 -0
- package/package.json +6 -6
- package/src/api.js +4 -0
- package/src/components/DictionaryRoutes.js +21 -3
- package/src/components/StructureTypesLoader.js +4 -2
- package/src/components/{StructuresDownloadButton.js → StructuresDownloadOption.js} +23 -26
- package/src/components/StructuresEditableDownloadOption.js +57 -0
- package/src/components/StructuresOptions.js +41 -0
- package/src/components/StructuresUpdateOption.js +46 -0
- package/src/components/{StructuresUploadButton.js → StructuresUploadOption.js} +17 -22
- package/src/components/StructuresView.js +6 -10
- package/src/components/SystemCreateOption.js +23 -0
- package/src/components/__tests__/StructuresDownloadOption.spec.js +45 -0
- package/src/components/__tests__/StructuresEditableDownloadOption.spec.js +39 -0
- package/src/components/__tests__/StructuresUpdateOption.spec.js +36 -0
- package/src/components/__tests__/StructuresUploadOption.spec.js +41 -0
- package/src/components/__tests__/SystemCreateOption.spec.js +22 -0
- package/src/components/__tests__/__snapshots__/StructuresDownloadOption.spec.js.snap +24 -0
- package/src/components/__tests__/__snapshots__/StructuresEditableDownloadOption.spec.js.snap +24 -0
- package/src/components/__tests__/__snapshots__/StructuresUpdateOption.spec.js.snap +19 -0
- package/src/components/__tests__/__snapshots__/StructuresUploadOption.spec.js.snap +39 -0
- package/src/components/__tests__/__snapshots__/StructuresView.spec.js.snap +2 -6
- package/src/components/__tests__/__snapshots__/SystemCreateOption.spec.js.snap +21 -0
- package/src/components/index.js +0 -2
- package/src/messages/en.js +7 -2
- package/src/messages/es.js +8 -3
- package/src/reducers/__tests__/structuresEditableDownloading.spec.js +32 -0
- package/src/reducers/index.js +2 -0
- package/src/reducers/structuresEditableDownloading.js +14 -0
- package/src/routines.js +3 -0
- package/src/sagas/__tests__/downloadEditableStructures.spec.js +80 -0
- package/src/sagas/downloadEditableStructures.js +43 -0
- package/src/sagas/fetchStructureTypes.js +5 -3
- package/src/sagas/index.js +3 -0
- package/src/selectors/__tests__/__snapshots__/getGrantsColumns.spec.js.snap +2 -2
- package/src/selectors/__tests__/getTabVisibility.spec.js +3 -6
- package/src/selectors/getTabVisibility.js +3 -12
- package/src/components/SystemCreateButton.js +0 -27
- package/src/components/__tests__/StructuresDownloadButton.spec.js +0 -26
- package/src/components/__tests__/StructuresUpdateButton.spec.js +0 -27
- package/src/components/__tests__/StructuresUploadButton.spec.js +0 -28
- package/src/components/__tests__/SystemCreateButton.spec.js +0 -14
- package/src/components/__tests__/__snapshots__/StructuresDownloadButton.spec.js.snap +0 -33
- package/src/components/__tests__/__snapshots__/StructuresUpdateButton.spec.js.snap +0 -44
- package/src/components/__tests__/__snapshots__/StructuresUploadButton.spec.js.snap +0 -515
- package/src/components/__tests__/__snapshots__/SystemCreateButton.spec.js.snap +0 -32
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/dd",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.33.3",
|
|
4
4
|
"description": "Truedat Web Data Dictionary",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"jsnext:main": "src/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@testing-library/jest-dom": "^5.14.1",
|
|
35
35
|
"@testing-library/react": "^12.0.0",
|
|
36
36
|
"@testing-library/user-event": "^13.2.1",
|
|
37
|
-
"@truedat/test": "4.
|
|
37
|
+
"@truedat/test": "4.33.3",
|
|
38
38
|
"babel-jest": "^27.0.6",
|
|
39
39
|
"babel-plugin-dynamic-import-node": "^2.3.3",
|
|
40
40
|
"babel-plugin-lodash": "^3.3.4",
|
|
@@ -84,9 +84,9 @@
|
|
|
84
84
|
]
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
|
-
"@truedat/auth": "4.
|
|
88
|
-
"@truedat/core": "4.
|
|
89
|
-
"@truedat/df": "4.
|
|
87
|
+
"@truedat/auth": "4.33.3",
|
|
88
|
+
"@truedat/core": "4.33.3",
|
|
89
|
+
"@truedat/df": "4.33.3",
|
|
90
90
|
"lodash": "^4.17.21",
|
|
91
91
|
"path-to-regexp": "^1.7.0",
|
|
92
92
|
"prop-types": "^15.7.2",
|
|
@@ -107,5 +107,5 @@
|
|
|
107
107
|
"react-dom": ">= 16.8.6 < 17",
|
|
108
108
|
"semantic-ui-react": ">= 0.88.2 < 2.1"
|
|
109
109
|
},
|
|
110
|
-
"gitHead": "
|
|
110
|
+
"gitHead": "4423c4077cf22e7d21d2679670287ed3d86ec8d7"
|
|
111
111
|
}
|
package/src/api.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const API_DATA_STRUCTURE = "/api/data_structures/:id";
|
|
2
2
|
const API_DATA_STRUCTURES_BULK_UPDATE = "/api/data_structures/bulk_update";
|
|
3
|
+
const API_DATA_STRUCTURES_EDITABLE_CSV = "/api/data_structures/editable_csv";
|
|
3
4
|
const API_DATA_STRUCTURES_CSV = "/api/data_structures/csv";
|
|
4
5
|
const API_DATA_STRUCTURES_SEARCH = "/api/data_structures/search";
|
|
5
6
|
const API_DATA_STRUCTURE_FILTERS_SEARCH = "/api/data_structure_filters/search";
|
|
@@ -28,6 +29,7 @@ const API_STRUCTURE_TAG = "/api/data_structure_tags/:id";
|
|
|
28
29
|
const API_STRUCTURE_TAGS = "/api/data_structure_tags";
|
|
29
30
|
const API_STRUCTURE_TYPE = "/api/data_structure_types/:id";
|
|
30
31
|
const API_STRUCTURE_TYPES = "/api/data_structure_types";
|
|
32
|
+
const API_STRUCTURE_TYPES_LITE = "/api/data_structure_types/lite";
|
|
31
33
|
const API_STRUCTURES_TAG = "/api/data_structures/:data_structure_id/tags/:id";
|
|
32
34
|
const API_STRUCTURES_TAGS = "/api/data_structures/:data_structure_id/tags";
|
|
33
35
|
const API_STRUCTURE_USER_FILTERS = "/api/data_structure_user_filters";
|
|
@@ -43,6 +45,7 @@ const API_UNIT_DOMAINS = "/api/unit_domains";
|
|
|
43
45
|
export {
|
|
44
46
|
API_DATA_STRUCTURE,
|
|
45
47
|
API_DATA_STRUCTURES_BULK_UPDATE,
|
|
48
|
+
API_DATA_STRUCTURES_EDITABLE_CSV,
|
|
46
49
|
API_DATA_STRUCTURES_CSV,
|
|
47
50
|
API_DATA_STRUCTURES_SEARCH,
|
|
48
51
|
API_DATA_STRUCTURE_FILTERS_SEARCH,
|
|
@@ -71,6 +74,7 @@ export {
|
|
|
71
74
|
API_STRUCTURE_TAGS,
|
|
72
75
|
API_STRUCTURE_TYPE,
|
|
73
76
|
API_STRUCTURE_TYPES,
|
|
77
|
+
API_STRUCTURE_TYPES_LITE,
|
|
74
78
|
API_STRUCTURE_USER_FILTERS,
|
|
75
79
|
API_STRUCTURE_USER_FILTER,
|
|
76
80
|
API_STRUCTURES_TAG,
|
|
@@ -30,7 +30,6 @@ const TemplatesLoader = React.lazy(() =>
|
|
|
30
30
|
const Loaders = () => (
|
|
31
31
|
<>
|
|
32
32
|
<StructuresLoader />
|
|
33
|
-
<StructureTypesLoader />
|
|
34
33
|
<StructureFiltersLoader />
|
|
35
34
|
<TemplatesLoader scope="dd" />
|
|
36
35
|
</>
|
|
@@ -49,6 +48,7 @@ export const DictionaryRoutes = () => {
|
|
|
49
48
|
path={STRUCTURES}
|
|
50
49
|
render={() => (
|
|
51
50
|
<>
|
|
51
|
+
<StructureTypesLoader liteRequest={true} />
|
|
52
52
|
<SystemsLoader />
|
|
53
53
|
<StructuresRoutes />
|
|
54
54
|
</>
|
|
@@ -58,17 +58,35 @@ export const DictionaryRoutes = () => {
|
|
|
58
58
|
path={SYSTEMS}
|
|
59
59
|
render={() => (
|
|
60
60
|
<>
|
|
61
|
+
<StructureTypesLoader liteRequest={true} />
|
|
61
62
|
<SystemsLoader />
|
|
62
63
|
<SystemsRoutes />
|
|
63
64
|
</>
|
|
64
65
|
)}
|
|
65
66
|
/>
|
|
66
|
-
<Route
|
|
67
|
-
|
|
67
|
+
<Route
|
|
68
|
+
path={STRUCTURE_TAGS}
|
|
69
|
+
render={() => (
|
|
70
|
+
<>
|
|
71
|
+
<StructureTypesLoader liteRequest={true} />
|
|
72
|
+
<StructureTagsRoutes />
|
|
73
|
+
</>
|
|
74
|
+
)}
|
|
75
|
+
/>
|
|
76
|
+
<Route
|
|
77
|
+
path={STRUCTURE_TYPES}
|
|
78
|
+
render={() => (
|
|
79
|
+
<>
|
|
80
|
+
<StructureTypesLoader />
|
|
81
|
+
<StructureTypesRoutes />
|
|
82
|
+
</>
|
|
83
|
+
)}
|
|
84
|
+
/>
|
|
68
85
|
<Route
|
|
69
86
|
path={PROFILE_GROUP}
|
|
70
87
|
render={() => (
|
|
71
88
|
<>
|
|
89
|
+
<StructureTypesLoader liteRequest={true} />
|
|
72
90
|
<Route render={() => <ProfileGroupLoader />} />
|
|
73
91
|
<Switch>
|
|
74
92
|
<Route
|
|
@@ -6,19 +6,21 @@ import { clearStructureTypes, fetchStructureTypes } from "../routines";
|
|
|
6
6
|
export const StructureTypesLoader = ({
|
|
7
7
|
clearStructureTypes,
|
|
8
8
|
fetchStructureTypes,
|
|
9
|
+
liteRequest = false,
|
|
9
10
|
}) => {
|
|
10
11
|
useEffect(() => {
|
|
11
|
-
fetchStructureTypes();
|
|
12
|
+
fetchStructureTypes({ liteRequest });
|
|
12
13
|
return () => {
|
|
13
14
|
clearStructureTypes();
|
|
14
15
|
};
|
|
15
|
-
}, [clearStructureTypes, fetchStructureTypes]);
|
|
16
|
+
}, [clearStructureTypes, fetchStructureTypes, liteRequest]);
|
|
16
17
|
return null;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
StructureTypesLoader.propTypes = {
|
|
20
21
|
clearStructureTypes: PropTypes.func,
|
|
21
22
|
fetchStructureTypes: PropTypes.func,
|
|
23
|
+
liteRequest: PropTypes.bool,
|
|
22
24
|
};
|
|
23
25
|
|
|
24
26
|
export default connect(null, { clearStructureTypes, fetchStructureTypes })(
|
|
@@ -2,7 +2,7 @@ import _ from "lodash/fp";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import { connect } from "react-redux";
|
|
5
|
-
import {
|
|
5
|
+
import { Dropdown } from "semantic-ui-react";
|
|
6
6
|
import { useIntl } from "react-intl";
|
|
7
7
|
import { downloadStructures } from "../routines";
|
|
8
8
|
|
|
@@ -19,7 +19,7 @@ const staticLabels = [
|
|
|
19
19
|
"deleted_at",
|
|
20
20
|
];
|
|
21
21
|
|
|
22
|
-
export const
|
|
22
|
+
export const StructuresDownloadOption = ({
|
|
23
23
|
structures,
|
|
24
24
|
structuresDownloading,
|
|
25
25
|
structuresLoading,
|
|
@@ -31,34 +31,31 @@ export const StructuresDownloadButton = ({
|
|
|
31
31
|
_.map((l) => [l, formatMessage({ id: `structures.props.${l}` })]),
|
|
32
32
|
_.fromPairs
|
|
33
33
|
)(staticLabels);
|
|
34
|
-
const
|
|
35
|
-
hasFilterApplied && !_.isEmpty(structures)
|
|
36
|
-
? formatMessage({ id: "structures.actions.download.tooltip" })
|
|
37
|
-
: formatMessage({ id: "structures.actions.download.popup" });
|
|
34
|
+
const isDisabled = _.isEmpty(structures) || !hasFilterApplied;
|
|
38
35
|
return (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<Button
|
|
47
|
-
secondary
|
|
48
|
-
icon="download"
|
|
49
|
-
onClick={() => downloadStructures({ headerLabels })}
|
|
50
|
-
loading={structuresDownloading}
|
|
51
|
-
disabled={_.isEmpty(structures) || !hasFilterApplied}
|
|
52
|
-
/>
|
|
36
|
+
!structuresLoading && (
|
|
37
|
+
<Dropdown.Item
|
|
38
|
+
icon="download"
|
|
39
|
+
content={
|
|
40
|
+
<>
|
|
41
|
+
<span>
|
|
42
|
+
{formatMessage({ id: "structures.actions.download.tooltip" })}
|
|
53
43
|
</span>
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
44
|
+
{isDisabled && (
|
|
45
|
+
<p className="menu-item-description">
|
|
46
|
+
{formatMessage({ id: "structures.actions.download.popup" })}
|
|
47
|
+
</p>
|
|
48
|
+
)}
|
|
49
|
+
</>
|
|
50
|
+
}
|
|
51
|
+
onClick={() => downloadStructures({ headerLabels })}
|
|
52
|
+
disabled={isDisabled || structuresDownloading}
|
|
53
|
+
/>
|
|
54
|
+
)
|
|
58
55
|
);
|
|
59
56
|
};
|
|
60
57
|
|
|
61
|
-
|
|
58
|
+
StructuresDownloadOption.propTypes = {
|
|
62
59
|
structuresDownloading: PropTypes.bool,
|
|
63
60
|
structuresLoading: PropTypes.bool,
|
|
64
61
|
downloadStructures: PropTypes.func,
|
|
@@ -71,5 +68,5 @@ const mapStateToProps = (state) => ({
|
|
|
71
68
|
});
|
|
72
69
|
|
|
73
70
|
export default connect(mapStateToProps, { downloadStructures })(
|
|
74
|
-
|
|
71
|
+
StructuresDownloadOption
|
|
75
72
|
);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import { connect } from "react-redux";
|
|
5
|
+
import { Dropdown } from "semantic-ui-react";
|
|
6
|
+
import { useIntl } from "react-intl";
|
|
7
|
+
import { downloadEditableStructures } from "../routines";
|
|
8
|
+
|
|
9
|
+
export const StructuresEditableDownloadOption = ({
|
|
10
|
+
structures,
|
|
11
|
+
structuresEditableDownloading,
|
|
12
|
+
structuresLoading,
|
|
13
|
+
downloadEditableStructures,
|
|
14
|
+
hasFilterApplied,
|
|
15
|
+
}) => {
|
|
16
|
+
const { formatMessage } = useIntl();
|
|
17
|
+
const isDisabled = _.isEmpty(structures) || !hasFilterApplied;
|
|
18
|
+
return (
|
|
19
|
+
!structuresLoading && (
|
|
20
|
+
<Dropdown.Item
|
|
21
|
+
icon="download"
|
|
22
|
+
content={
|
|
23
|
+
<>
|
|
24
|
+
<span>
|
|
25
|
+
{formatMessage({
|
|
26
|
+
id: "structures.actions.editableDownload.tooltip",
|
|
27
|
+
})}
|
|
28
|
+
</span>
|
|
29
|
+
{isDisabled && (
|
|
30
|
+
<p className="menu-item-description">
|
|
31
|
+
{formatMessage({ id: "structures.actions.download.popup" })}
|
|
32
|
+
</p>
|
|
33
|
+
)}
|
|
34
|
+
</>
|
|
35
|
+
}
|
|
36
|
+
onClick={() => downloadEditableStructures()}
|
|
37
|
+
disabled={isDisabled || structuresEditableDownloading}
|
|
38
|
+
/>
|
|
39
|
+
)
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
StructuresEditableDownloadOption.propTypes = {
|
|
44
|
+
structuresEditableDownloading: PropTypes.bool,
|
|
45
|
+
structuresLoading: PropTypes.bool,
|
|
46
|
+
downloadEditableStructures: PropTypes.func,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const mapStateToProps = (state) => ({
|
|
50
|
+
structuresEditableDownloading: state.structuresEditableDownloading,
|
|
51
|
+
structuresLoading: state.structuresLoading,
|
|
52
|
+
structures: state.structures,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
export default connect(mapStateToProps, { downloadEditableStructures })(
|
|
56
|
+
StructuresEditableDownloadOption
|
|
57
|
+
);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import { Dropdown } from "semantic-ui-react";
|
|
4
|
+
import SystemCreateOption from "./SystemCreateOption";
|
|
5
|
+
import StructuresDownloadOption from "./StructuresDownloadOption";
|
|
6
|
+
import StructuresEditableDownloadOption from "./StructuresEditableDownloadOption";
|
|
7
|
+
import StructuresUpdateOption from "./StructuresUpdateOption";
|
|
8
|
+
import StructuresUploadOption from "./StructuresUploadOption";
|
|
9
|
+
|
|
10
|
+
export const StructuresOptions = ({
|
|
11
|
+
hasFilterApplied,
|
|
12
|
+
canBulkUpload,
|
|
13
|
+
canAutoPublish,
|
|
14
|
+
}) => (
|
|
15
|
+
<Dropdown
|
|
16
|
+
icon="ellipsis vertical"
|
|
17
|
+
className="button icon group-actions button-update"
|
|
18
|
+
direction="left"
|
|
19
|
+
floating
|
|
20
|
+
>
|
|
21
|
+
<Dropdown.Menu>
|
|
22
|
+
<SystemCreateOption />
|
|
23
|
+
<Dropdown.Divider />
|
|
24
|
+
<StructuresDownloadOption hasFilterApplied={hasFilterApplied} />
|
|
25
|
+
<StructuresEditableDownloadOption hasFilterApplied={hasFilterApplied} />
|
|
26
|
+
{canBulkUpload && (
|
|
27
|
+
<StructuresUploadOption canAutoPublish={canAutoPublish} />
|
|
28
|
+
)}
|
|
29
|
+
<Dropdown.Divider />
|
|
30
|
+
<StructuresUpdateOption />
|
|
31
|
+
</Dropdown.Menu>
|
|
32
|
+
</Dropdown>
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
StructuresOptions.propTypes = {
|
|
36
|
+
hasFilterApplied: PropTypes.bool,
|
|
37
|
+
canBulkUpload: PropTypes.bool,
|
|
38
|
+
canAutoPublish: PropTypes.bool,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default StructuresOptions;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import { connect } from "react-redux";
|
|
4
|
+
import { Dropdown } from "semantic-ui-react";
|
|
5
|
+
import { Link } from "react-router-dom";
|
|
6
|
+
import { useIntl } from "react-intl";
|
|
7
|
+
import { useAuthorized } from "@truedat/core/hooks";
|
|
8
|
+
import { STRUCTURES_BULK_UPDATE } from "@truedat/core/routes";
|
|
9
|
+
import { bulkUpdateDisabledSelector } from "../selectors";
|
|
10
|
+
|
|
11
|
+
export const StructuresUpdateOption = ({ disabled }) => {
|
|
12
|
+
const { formatMessage } = useIntl();
|
|
13
|
+
const authorized = useAuthorized();
|
|
14
|
+
return (
|
|
15
|
+
authorized && (
|
|
16
|
+
<Dropdown.Item
|
|
17
|
+
icon="refresh"
|
|
18
|
+
as={Link}
|
|
19
|
+
to={STRUCTURES_BULK_UPDATE}
|
|
20
|
+
disabled={disabled}
|
|
21
|
+
content={
|
|
22
|
+
<>
|
|
23
|
+
<span>
|
|
24
|
+
{formatMessage({ id: "structures.actions.bulk_update" })}
|
|
25
|
+
</span>
|
|
26
|
+
{disabled && (
|
|
27
|
+
<p className="menu-item-description">
|
|
28
|
+
{formatMessage({ id: "structures.actions.bulk_update.popup" })}
|
|
29
|
+
</p>
|
|
30
|
+
)}
|
|
31
|
+
</>
|
|
32
|
+
}
|
|
33
|
+
/>
|
|
34
|
+
)
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
StructuresUpdateOption.propTypes = {
|
|
39
|
+
disabled: PropTypes.bool,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const mapStateToProps = (state) => ({
|
|
43
|
+
disabled: bulkUpdateDisabledSelector(state),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export default connect(mapStateToProps)(StructuresUpdateOption);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import { connect } from "react-redux";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { Dropdown } from "semantic-ui-react";
|
|
5
|
+
import { useIntl } from "react-intl";
|
|
6
6
|
import { UploadModal } from "@truedat/core/components";
|
|
7
7
|
import { uploadStructures } from "../routines";
|
|
8
8
|
|
|
9
|
-
export const
|
|
9
|
+
export const StructuresUploadOption = ({
|
|
10
10
|
uploadStructures,
|
|
11
11
|
loading,
|
|
12
12
|
canAutoPublish,
|
|
@@ -15,7 +15,7 @@ export const StructuresUploadButton = ({
|
|
|
15
15
|
const extraAction = {
|
|
16
16
|
key: "yesWithAutoPublish",
|
|
17
17
|
primary: true,
|
|
18
|
-
content:
|
|
18
|
+
content: formatMessage({ id: "uploadModal.accept.publish" }),
|
|
19
19
|
onClick: (data) => {
|
|
20
20
|
data.append("auto_publish", canAutoPublish);
|
|
21
21
|
return uploadStructures({ data });
|
|
@@ -27,23 +27,18 @@ export const StructuresUploadButton = ({
|
|
|
27
27
|
extraAction={canAutoPublish && extraAction}
|
|
28
28
|
icon="upload"
|
|
29
29
|
trigger={
|
|
30
|
-
<
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
data-tooltip={formatMessage({
|
|
36
|
-
id: "structures.actions.upload.tooltip",
|
|
37
|
-
})}
|
|
38
|
-
/>
|
|
39
|
-
</span>
|
|
40
|
-
}
|
|
41
|
-
header={
|
|
42
|
-
<FormattedMessage id="structures.actions.upload.confirmation.header" />
|
|
43
|
-
}
|
|
44
|
-
content={
|
|
45
|
-
<FormattedMessage id="structures.actions.upload.confirmation.content" />
|
|
30
|
+
<Dropdown.Item
|
|
31
|
+
icon="upload"
|
|
32
|
+
text={formatMessage({ id: "structures.actions.upload.tooltip" })}
|
|
33
|
+
disabled={loading}
|
|
34
|
+
/>
|
|
46
35
|
}
|
|
36
|
+
header={formatMessage({
|
|
37
|
+
id: "structures.actions.upload.confirmation.header",
|
|
38
|
+
})}
|
|
39
|
+
content={formatMessage({
|
|
40
|
+
id: "structures.actions.upload.confirmation.content",
|
|
41
|
+
})}
|
|
47
42
|
param={"structures"}
|
|
48
43
|
handleSubmit={(data) =>
|
|
49
44
|
uploadStructures({
|
|
@@ -54,7 +49,7 @@ export const StructuresUploadButton = ({
|
|
|
54
49
|
);
|
|
55
50
|
};
|
|
56
51
|
|
|
57
|
-
|
|
52
|
+
StructuresUploadOption.propTypes = {
|
|
58
53
|
uploadStructures: PropTypes.func,
|
|
59
54
|
loading: PropTypes.bool,
|
|
60
55
|
canAutoPublish: PropTypes.bool,
|
|
@@ -65,5 +60,5 @@ const mapStateToProps = ({ uploadingStructuresFile }) => ({
|
|
|
65
60
|
});
|
|
66
61
|
|
|
67
62
|
export default connect(mapStateToProps, { uploadStructures })(
|
|
68
|
-
|
|
63
|
+
StructuresUploadOption
|
|
69
64
|
);
|
|
@@ -8,13 +8,10 @@ import { FormattedMessage } from "react-intl";
|
|
|
8
8
|
import { linkTo } from "@truedat/core/routes";
|
|
9
9
|
import { structureRowsSelector } from "../selectors";
|
|
10
10
|
import StructureSelectedFilters from "./StructureSelectedFilters";
|
|
11
|
-
import
|
|
12
|
-
import StructuresDownloadButton from "./StructuresDownloadButton";
|
|
11
|
+
import StructuresOptions from "./StructuresOptions";
|
|
13
12
|
import StructureDateFilter from "./StructureDateFilter";
|
|
14
13
|
import StructuresSearch from "./StructuresSearch";
|
|
15
14
|
import StructuresSearchResults from "./StructuresSearchResults";
|
|
16
|
-
import StructuresUpdateButton from "./StructuresUpdateButton";
|
|
17
|
-
import SystemCreateButton from "./SystemCreateButton";
|
|
18
15
|
import SystemCards from "./SystemCards";
|
|
19
16
|
|
|
20
17
|
export const StructuresHeader = () => (
|
|
@@ -51,12 +48,11 @@ export const StructuresView = ({
|
|
|
51
48
|
<Segment loading={systemsLoading}>
|
|
52
49
|
<StructuresHeader />
|
|
53
50
|
<Divider hidden />
|
|
54
|
-
<
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
)}
|
|
51
|
+
<StructuresOptions
|
|
52
|
+
hasFilterApplied={hasFilterApplied}
|
|
53
|
+
canBulkUpload={canBulkUpload}
|
|
54
|
+
canAutoPublish={canAutoPublish}
|
|
55
|
+
/>
|
|
60
56
|
<StructuresSearch />
|
|
61
57
|
<StructureSelectedFilters />
|
|
62
58
|
<StructureDateFilter />
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Dropdown } from "semantic-ui-react";
|
|
3
|
+
import { Link } from "react-router-dom";
|
|
4
|
+
import { useIntl } from "react-intl";
|
|
5
|
+
import { useAuthorized } from "@truedat/core/hooks";
|
|
6
|
+
import { SYSTEM_NEW } from "@truedat/core/routes";
|
|
7
|
+
|
|
8
|
+
export const SystemCreateOption = () => {
|
|
9
|
+
const { formatMessage } = useIntl();
|
|
10
|
+
const authorized = useAuthorized();
|
|
11
|
+
return (
|
|
12
|
+
authorized && (
|
|
13
|
+
<Dropdown.Item
|
|
14
|
+
icon="plus square outline"
|
|
15
|
+
as={Link}
|
|
16
|
+
to={SYSTEM_NEW}
|
|
17
|
+
text={formatMessage({ id: "structures.actions.new_system" })}
|
|
18
|
+
/>
|
|
19
|
+
)
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default SystemCreateOption;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import { StructuresDownloadOption } from "../StructuresDownloadOption";
|
|
4
|
+
|
|
5
|
+
describe("<StructuresDownloadOption />", () => {
|
|
6
|
+
const downloadStructures = jest.fn();
|
|
7
|
+
const structuresLoading = false;
|
|
8
|
+
const renderOpts = {
|
|
9
|
+
messages: {
|
|
10
|
+
en: {
|
|
11
|
+
"structures.actions.download.tooltip": "tooltip",
|
|
12
|
+
"structures.actions.download.popup": "popup",
|
|
13
|
+
"structures.props.type": "type",
|
|
14
|
+
"structures.props.name": "name",
|
|
15
|
+
"structures.props.external_id": "external id",
|
|
16
|
+
"structures.props.group": "group",
|
|
17
|
+
"structures.props.domain": "domain",
|
|
18
|
+
"structures.props.system": "system",
|
|
19
|
+
"structures.props.path": "path",
|
|
20
|
+
"structures.props.description": "description",
|
|
21
|
+
"structures.props.inserted_at": "updated at",
|
|
22
|
+
"structures.props.deleted_at": "deleted at",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
it("matches the latest snapshot", () => {
|
|
28
|
+
const props = { downloadStructures, structuresLoading };
|
|
29
|
+
const { container } = render(
|
|
30
|
+
<StructuresDownloadOption {...props} />,
|
|
31
|
+
renderOpts
|
|
32
|
+
);
|
|
33
|
+
expect(container).toMatchSnapshot();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("is disabled if there are no structures to be downloaded", () => {
|
|
37
|
+
const props = { downloadStructures, structuresLoading, structures: [] };
|
|
38
|
+
const { getByRole, queryByText } = render(
|
|
39
|
+
<StructuresDownloadOption {...props} />,
|
|
40
|
+
renderOpts
|
|
41
|
+
);
|
|
42
|
+
expect(getByRole("option")).toHaveAttribute("aria-disabled");
|
|
43
|
+
expect(queryByText("popup")).toBeTruthy();
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import { StructuresEditableDownloadOption } from "../StructuresEditableDownloadOption";
|
|
4
|
+
|
|
5
|
+
describe("<StructuresEditableDownloadOption />", () => {
|
|
6
|
+
const downloadEditableStructures = jest.fn();
|
|
7
|
+
const structuresLoading = false;
|
|
8
|
+
const renderOpts = {
|
|
9
|
+
messages: {
|
|
10
|
+
en: {
|
|
11
|
+
"structures.actions.editableDownload.tooltip": "tooltip",
|
|
12
|
+
"structures.actions.download.popup": "popup",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
it("matches the latest snapshot", () => {
|
|
18
|
+
const props = { downloadEditableStructures, structuresLoading };
|
|
19
|
+
const { container } = render(
|
|
20
|
+
<StructuresEditableDownloadOption {...props} />,
|
|
21
|
+
renderOpts
|
|
22
|
+
);
|
|
23
|
+
expect(container).toMatchSnapshot();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("is disabled if there are no structures to be downloaded", () => {
|
|
27
|
+
const props = {
|
|
28
|
+
downloadEditableStructures,
|
|
29
|
+
structuresLoading,
|
|
30
|
+
structures: [],
|
|
31
|
+
};
|
|
32
|
+
const { getByRole, queryByText } = render(
|
|
33
|
+
<StructuresEditableDownloadOption {...props} />,
|
|
34
|
+
renderOpts
|
|
35
|
+
);
|
|
36
|
+
expect(getByRole("option")).toHaveAttribute("aria-disabled");
|
|
37
|
+
expect(queryByText("popup")).toBeTruthy();
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// only admin user
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { render } from "@truedat/test/render";
|
|
4
|
+
import { StructuresUpdateOption } from "../StructuresUpdateOption";
|
|
5
|
+
|
|
6
|
+
jest.mock("@truedat/core/hooks", () => ({
|
|
7
|
+
useAuthorized: jest.fn(() => true),
|
|
8
|
+
}));
|
|
9
|
+
|
|
10
|
+
describe("<StructuresUpdateOption />", () => {
|
|
11
|
+
const renderOpts = {
|
|
12
|
+
messages: {
|
|
13
|
+
en: {
|
|
14
|
+
"structures.actions.bulk_update": "update",
|
|
15
|
+
"structures.actions.bulk_update.popup": "popup",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
it("matches the latest snapshot", () => {
|
|
21
|
+
const { container } = render(<StructuresUpdateOption />, renderOpts);
|
|
22
|
+
expect(container).toMatchSnapshot();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("button will appear disabled if template is empty", () => {
|
|
26
|
+
const props = {
|
|
27
|
+
disabled: true,
|
|
28
|
+
};
|
|
29
|
+
const { getByRole, queryByText } = render(
|
|
30
|
+
<StructuresUpdateOption {...props} />,
|
|
31
|
+
renderOpts
|
|
32
|
+
);
|
|
33
|
+
expect(getByRole("option")).toHaveAttribute("aria-disabled");
|
|
34
|
+
expect(queryByText("popup")).toBeTruthy();
|
|
35
|
+
});
|
|
36
|
+
});
|