@truedat/core 4.44.2 → 4.44.5
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 +13 -0
- package/package.json +24 -18
- package/src/api/queries.js +12 -0
- package/src/components/CatalogMenu.js +4 -3
- package/src/components/DashboardMenu.js +12 -4
- package/src/components/QualityMenu.js +15 -7
- package/src/components/SideMenu.js +11 -5
- package/src/components/SidebarToggle.js +9 -4
- package/src/components/Submenu.js +12 -10
- package/src/components/TemplateSelector.js +99 -0
- package/src/components/__tests__/DashboardMenu.spec.js +13 -14
- package/src/components/__tests__/DateTime.spec.js +5 -3
- package/src/components/__tests__/QualityMenu.spec.js +14 -14
- package/src/components/__tests__/SideMenu.spec.js +7 -14
- package/src/components/__tests__/Submenu.spec.js +7 -19
- package/src/components/__tests__/TemplateSelector.spec.js +80 -0
- package/src/components/__tests__/__snapshots__/AdminMenu.spec.js.snap +1 -1
- package/src/components/__tests__/__snapshots__/CatalogMenu.spec.js.snap +13 -0
- package/src/components/__tests__/__snapshots__/DashboardMenu.spec.js.snap +1 -16
- package/src/components/__tests__/__snapshots__/DateTime.spec.js.snap +7 -19
- package/src/components/__tests__/__snapshots__/GlossaryMenu.spec.js.snap +1 -1
- package/src/components/__tests__/__snapshots__/GrantMenu.spec.js.snap +1 -1
- package/src/components/__tests__/__snapshots__/IngestMenu.spec.js.snap +1 -1
- package/src/components/__tests__/__snapshots__/LineageMenu.spec.js.snap +1 -1
- package/src/components/__tests__/__snapshots__/MembersMenu.spec.js.snap +1 -1
- package/src/components/__tests__/__snapshots__/QualityMenu.spec.js.snap +60 -26
- package/src/components/__tests__/__snapshots__/SearchMenu.spec.js.snap +1 -1
- package/src/components/__tests__/__snapshots__/SideMenu.spec.js.snap +58 -30
- package/src/components/__tests__/__snapshots__/Submenu.spec.js.snap +30 -38
- package/src/components/__tests__/__snapshots__/TaxonomyMenu.spec.js.snap +1 -1
- package/src/components/__tests__/__snapshots__/TemplateSelector.spec.js.snap +210 -0
- package/src/components/index.js +2 -0
- package/src/messages/en.js +6 -0
- package/src/messages/es.js +6 -0
- package/src/routes.js +21 -18
- package/src/services/file.js +9 -0
- package/src/services/sort.js +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [4.44.5] 2022-05-20
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- [TD-4230] `TemplateSelector` GraphQL fetchPolicy changed to
|
|
8
|
+
`cache-and-network` and changed hidden logic
|
|
9
|
+
|
|
10
|
+
## [4.44.4] 2022-05-19
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- [TD-4660] `lowerDeburrTrim` function, reference data routes and i18n messages
|
|
15
|
+
|
|
3
16
|
## [4.44.1] 2022-05-11
|
|
4
17
|
|
|
5
18
|
### Changed
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/core",
|
|
3
|
-
"version": "4.44.
|
|
3
|
+
"version": "4.44.5",
|
|
4
4
|
"description": "Truedat Web Core",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"jsnext:main": "src/index.js",
|
|
@@ -17,23 +17,26 @@
|
|
|
17
17
|
"scripts": {
|
|
18
18
|
"clean": "rimraf yarn-error.log",
|
|
19
19
|
"debug": "node --inspect-brk node_modules/.bin/jest --runInBand",
|
|
20
|
-
"test": "jest --coverage",
|
|
21
|
-
"test:watch": "jest --watch",
|
|
20
|
+
"test": "TZ=UTC jest --coverage",
|
|
21
|
+
"test:watch": "TZ=UTC jest --watch",
|
|
22
22
|
"eslint": "eslint src/**",
|
|
23
23
|
"eslint:fix": "eslint --fix src/**"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@babel/cli": "^7.
|
|
27
|
-
"@babel/core": "^7.
|
|
28
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
|
29
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.
|
|
30
|
-
"@babel/plugin-proposal-optional-chaining": "^7.
|
|
26
|
+
"@babel/cli": "^7.17.10",
|
|
27
|
+
"@babel/core": "^7.18.0",
|
|
28
|
+
"@babel/plugin-proposal-class-properties": "^7.17.12",
|
|
29
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.18.0",
|
|
30
|
+
"@babel/plugin-proposal-optional-chaining": "^7.17.12",
|
|
31
31
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
32
|
-
"@babel/plugin-transform-modules-commonjs": "^7.
|
|
33
|
-
"@babel/preset-env": "^7.
|
|
34
|
-
"@babel/preset-react": "^7.
|
|
35
|
-
"@
|
|
36
|
-
"
|
|
32
|
+
"@babel/plugin-transform-modules-commonjs": "^7.18.0",
|
|
33
|
+
"@babel/preset-env": "^7.18.0",
|
|
34
|
+
"@babel/preset-react": "^7.17.12",
|
|
35
|
+
"@testing-library/jest-dom": "^5.16.4",
|
|
36
|
+
"@testing-library/react": "^12.0.0",
|
|
37
|
+
"@testing-library/user-event": "^13.2.1",
|
|
38
|
+
"@truedat/test": "4.44.5",
|
|
39
|
+
"babel-jest": "^28.1.0",
|
|
37
40
|
"babel-plugin-dynamic-import-node": "^2.3.3",
|
|
38
41
|
"babel-plugin-lodash": "^3.3.4",
|
|
39
42
|
"babel-plugin-react-intl": "^5.1.18",
|
|
@@ -41,7 +44,8 @@
|
|
|
41
44
|
"enzyme": "^3.11.0",
|
|
42
45
|
"enzyme-to-json": "^3.6.2",
|
|
43
46
|
"identity-obj-proxy": "^3.0.0",
|
|
44
|
-
"jest": "^
|
|
47
|
+
"jest": "^28.1.0",
|
|
48
|
+
"jest-environment-jsdom": "^28.1.0",
|
|
45
49
|
"jest-localstorage-mock": "^2.4.14",
|
|
46
50
|
"react": "^16.14.0",
|
|
47
51
|
"react-dom": "^16.14.0",
|
|
@@ -50,6 +54,8 @@
|
|
|
50
54
|
"semantic-ui-react": "^2.0.3"
|
|
51
55
|
},
|
|
52
56
|
"jest": {
|
|
57
|
+
"maxWorkers": "50%",
|
|
58
|
+
"testTimeout": 10000,
|
|
53
59
|
"moduleDirectories": [
|
|
54
60
|
"<rootDir>/src",
|
|
55
61
|
"../../node_modules"
|
|
@@ -82,16 +88,16 @@
|
|
|
82
88
|
}
|
|
83
89
|
},
|
|
84
90
|
"dependencies": {
|
|
85
|
-
"@apollo/client": "^3.4
|
|
91
|
+
"@apollo/client": "^3.6.4",
|
|
86
92
|
"axios": "^0.19.2",
|
|
87
93
|
"immutable": "^4.0.0-rc.12",
|
|
88
94
|
"is-hotkey": "^0.1.6",
|
|
89
95
|
"is-url": "^1.2.4",
|
|
90
|
-
"prop-types": "^15.
|
|
96
|
+
"prop-types": "^15.8.1",
|
|
91
97
|
"react-csv": "^2.2.2",
|
|
92
98
|
"react-dropzone": "^4.2.13",
|
|
93
99
|
"react-intl": "^5.20.10",
|
|
94
|
-
"react-moment": "^
|
|
100
|
+
"react-moment": "^1.1.2",
|
|
95
101
|
"react-redux": "^7.2.4",
|
|
96
102
|
"react-router-dom": "^5.2.0",
|
|
97
103
|
"redux": "^4.1.1",
|
|
@@ -106,5 +112,5 @@
|
|
|
106
112
|
"react-dom": ">= 16.8.6 < 17",
|
|
107
113
|
"semantic-ui-react": ">= 0.88.2 < 2.1"
|
|
108
114
|
},
|
|
109
|
-
"gitHead": "
|
|
115
|
+
"gitHead": "5a339468198c803592b285eddd0dd0c0b0eced93"
|
|
110
116
|
}
|
package/src/api/queries.js
CHANGED
|
@@ -9,3 +9,15 @@ export const DOMAINS_QUERY = gql`
|
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
`;
|
|
12
|
+
|
|
13
|
+
export const TEMPLATES_QUERY = gql`
|
|
14
|
+
query Templates($scope: String, $domainIds: [ID]) {
|
|
15
|
+
templates(scope: $scope, domainIds: $domainIds) {
|
|
16
|
+
id
|
|
17
|
+
name
|
|
18
|
+
label
|
|
19
|
+
scope
|
|
20
|
+
content
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import _ from "lodash/fp";
|
|
2
1
|
import React from "react";
|
|
3
2
|
import { useAuthorized } from "../hooks";
|
|
4
3
|
import {
|
|
5
|
-
STRUCTURES_UPLOAD_EVENTS,
|
|
6
4
|
PENDING_STRUCTURE_NOTES,
|
|
5
|
+
REFERENCE_DATASETS,
|
|
6
|
+
STRUCTURES,
|
|
7
|
+
STRUCTURES_UPLOAD_EVENTS,
|
|
7
8
|
STRUCTURE_TAGS,
|
|
8
9
|
STRUCTURE_TYPES,
|
|
9
|
-
STRUCTURES,
|
|
10
10
|
SYSTEMS,
|
|
11
11
|
} from "../routes";
|
|
12
12
|
import Submenu from "./Submenu";
|
|
@@ -16,6 +16,7 @@ const items = [{ name: "structures", routes: [STRUCTURES, SYSTEMS] }];
|
|
|
16
16
|
const adminItems = [
|
|
17
17
|
{ name: "structureTypes", routes: [STRUCTURE_TYPES] },
|
|
18
18
|
{ name: "structureTags", routes: [STRUCTURE_TAGS] },
|
|
19
|
+
{ name: "referenceData", routes: [REFERENCE_DATASETS] },
|
|
19
20
|
];
|
|
20
21
|
|
|
21
22
|
const structureNoteItems = [
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import { connect } from "react-redux";
|
|
4
5
|
import { DASHBOARD } from "@truedat/core/routes";
|
|
5
6
|
import { getDashboardConfig } from "../selectors";
|
|
6
7
|
import { useAuthorized } from "../hooks";
|
|
@@ -8,9 +9,8 @@ import Submenu from "./Submenu";
|
|
|
8
9
|
|
|
9
10
|
const items = [{ name: "dashboard", routes: [DASHBOARD] }];
|
|
10
11
|
|
|
11
|
-
export const DashboardMenu = () => {
|
|
12
|
+
export const DashboardMenu = ({ dashboardConfig }) => {
|
|
12
13
|
const authorized = useAuthorized("dashboards");
|
|
13
|
-
const dashboardConfig = useSelector(getDashboardConfig);
|
|
14
14
|
|
|
15
15
|
return authorized && !_.isEmpty(dashboardConfig) ? (
|
|
16
16
|
<Submenu items={items} icon="chart line" name="dashboard" />
|
|
@@ -19,4 +19,12 @@ export const DashboardMenu = () => {
|
|
|
19
19
|
);
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
DashboardMenu.propTypes = {
|
|
23
|
+
dashboardConfig: PropTypes.object,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const mapStateToProps = (state) => ({
|
|
27
|
+
dashboardConfig: getDashboardConfig(state),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export default connect(mapStateToProps)(DashboardMenu);
|
|
@@ -1,28 +1,36 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import { connect } from "react-redux";
|
|
4
5
|
import { useAuthorized } from "../hooks";
|
|
5
6
|
import { RULES, QUALITY_DASHBOARD, IMPLEMENTATIONS } from "../routes";
|
|
6
7
|
import { getQualityDashboardConfig } from "../selectors";
|
|
7
8
|
import Submenu from "./Submenu";
|
|
8
9
|
|
|
9
|
-
const
|
|
10
|
+
export const ITEMS = [
|
|
10
11
|
{ name: "rules", routes: [RULES] },
|
|
11
12
|
{ name: "implementations", routes: [IMPLEMENTATIONS] },
|
|
12
|
-
{ name: "quality_dashboard", routes: [QUALITY_DASHBOARD] }
|
|
13
|
+
{ name: "quality_dashboard", routes: [QUALITY_DASHBOARD] },
|
|
13
14
|
];
|
|
14
15
|
|
|
15
|
-
export const QualityMenu = () => {
|
|
16
|
+
export const QualityMenu = ({ dashboardConfig }) => {
|
|
16
17
|
const authorized = useAuthorized("data_quality");
|
|
17
|
-
const dashboardConfig = useSelector(getQualityDashboardConfig);
|
|
18
18
|
|
|
19
19
|
const filteredItems = _.filter(
|
|
20
20
|
({ name }) => name != "quality_dashboard" || !_.isEmpty(dashboardConfig)
|
|
21
|
-
)(
|
|
21
|
+
)(ITEMS);
|
|
22
22
|
|
|
23
23
|
return authorized ? (
|
|
24
24
|
<Submenu items={filteredItems} icon="check square" name="quality" />
|
|
25
25
|
) : null;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
QualityMenu.propTypes = {
|
|
29
|
+
dashboardConfig: PropTypes.object,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const mapStateToProps = (state) => ({
|
|
33
|
+
dashboardConfig: getQualityDashboardConfig(state),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export default connect(mapStateToProps)(QualityMenu);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
|
-
import {
|
|
3
|
+
import { connect } from "react-redux";
|
|
4
4
|
import { Menu, Sidebar } from "semantic-ui-react";
|
|
5
5
|
import AdminMenu from "./AdminMenu";
|
|
6
6
|
import CatalogMenu from "./CatalogMenu";
|
|
@@ -15,9 +15,12 @@ import TaxonomyMenu from "./TaxonomyMenu";
|
|
|
15
15
|
import GrantMenu from "./GrantMenu";
|
|
16
16
|
import MembersMenu from "./MembersMenu";
|
|
17
17
|
|
|
18
|
-
export const SideMenu = ({
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
export const SideMenu = ({
|
|
19
|
+
animation = "push",
|
|
20
|
+
children,
|
|
21
|
+
inverted,
|
|
22
|
+
sidebarVisible,
|
|
23
|
+
}) => {
|
|
21
24
|
const width = sidebarVisible ? null : "very thin";
|
|
22
25
|
|
|
23
26
|
return (
|
|
@@ -53,6 +56,9 @@ SideMenu.propTypes = {
|
|
|
53
56
|
animation: PropTypes.string,
|
|
54
57
|
children: PropTypes.node,
|
|
55
58
|
inverted: PropTypes.bool,
|
|
59
|
+
sidebarVisible: PropTypes.bool,
|
|
56
60
|
};
|
|
57
61
|
|
|
58
|
-
export
|
|
62
|
+
export const mapStateToProps = ({ sidebarVisible }) => ({ sidebarVisible });
|
|
63
|
+
|
|
64
|
+
export default connect(mapStateToProps)(SideMenu);
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import React, { useEffect } from "react";
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import { FormattedMessage } from "react-intl";
|
|
4
|
-
import { connect
|
|
4
|
+
import { connect } from "react-redux";
|
|
5
5
|
import { useLocation } from "react-router-dom";
|
|
6
6
|
import { Icon, Menu } from "semantic-ui-react";
|
|
7
7
|
import { hideSidebar, toggleSidebar } from "@truedat/core/routines";
|
|
8
8
|
|
|
9
9
|
export const SidebarToggle = ({
|
|
10
|
+
animation = "push",
|
|
10
11
|
hideSidebar,
|
|
12
|
+
sidebarVisible,
|
|
11
13
|
toggleSidebar,
|
|
12
|
-
animation = "push",
|
|
13
14
|
}) => {
|
|
14
15
|
const location = useLocation();
|
|
15
|
-
const sidebarVisible = useSelector((state) => state.sidebarVisible);
|
|
16
16
|
useEffect(() => {
|
|
17
17
|
if (animation == "overlay") {
|
|
18
18
|
hideSidebar();
|
|
@@ -45,6 +45,11 @@ SidebarToggle.propTypes = {
|
|
|
45
45
|
animation: PropTypes.string,
|
|
46
46
|
hideSidebar: PropTypes.func,
|
|
47
47
|
toggleSidebar: PropTypes.func,
|
|
48
|
+
sidebarVisible: PropTypes.bool,
|
|
48
49
|
};
|
|
49
50
|
|
|
50
|
-
export
|
|
51
|
+
export const mapStateToProps = ({ sidebarVisible }) => ({ sidebarVisible });
|
|
52
|
+
|
|
53
|
+
export default connect(mapStateToProps, { hideSidebar, toggleSidebar })(
|
|
54
|
+
SidebarToggle
|
|
55
|
+
);
|
|
@@ -2,7 +2,7 @@ import _ from "lodash/fp";
|
|
|
2
2
|
import React, { useEffect, useState } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import { useIntl, FormattedMessage } from "react-intl";
|
|
5
|
-
import {
|
|
5
|
+
import { connect } from "react-redux";
|
|
6
6
|
import { useLocation, useHistory, Link } from "react-router-dom";
|
|
7
7
|
import { Dropdown, Icon, Menu } from "semantic-ui-react";
|
|
8
8
|
import { useAuthorizedItems, useActiveRoutes } from "@truedat/core/hooks";
|
|
@@ -19,14 +19,14 @@ export const MenuItem = ({ name, routes }) => {
|
|
|
19
19
|
to={primaryRoute}
|
|
20
20
|
active={active}
|
|
21
21
|
content={formatMessage({ id: `sidemenu.${name}`, defaultMessage: name })}
|
|
22
|
-
onClick={e => e.stopPropagation()}
|
|
22
|
+
onClick={(e) => e.stopPropagation()}
|
|
23
23
|
/>
|
|
24
24
|
);
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
MenuItem.propTypes = {
|
|
28
28
|
name: PropTypes.string,
|
|
29
|
-
routes: PropTypes.array
|
|
29
|
+
routes: PropTypes.array,
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
export const DropdownItem = ({ name, routes }) => {
|
|
@@ -40,19 +40,18 @@ export const DropdownItem = ({ name, routes }) => {
|
|
|
40
40
|
to={primaryRoute}
|
|
41
41
|
active={active}
|
|
42
42
|
content={formatMessage({ id: `sidemenu.${name}`, defaultMessage: name })}
|
|
43
|
-
onClick={e => e.stopPropagation()}
|
|
43
|
+
onClick={(e) => e.stopPropagation()}
|
|
44
44
|
/>
|
|
45
45
|
);
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
DropdownItem.propTypes = {
|
|
49
49
|
name: PropTypes.string,
|
|
50
|
-
routes: PropTypes.array
|
|
50
|
+
routes: PropTypes.array,
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
export const Submenu = ({ items, icon, name }) => {
|
|
53
|
+
export const Submenu = ({ items, icon, name, sidebarVisible }) => {
|
|
54
54
|
const [open, setOpen] = useState(false);
|
|
55
|
-
const sidebarVisible = useSelector(state => state.sidebarVisible);
|
|
56
55
|
const active = useActiveRoutes(_.flatMap("routes")(items));
|
|
57
56
|
const filteredItems = useAuthorizedItems(items);
|
|
58
57
|
const location = useLocation();
|
|
@@ -107,7 +106,7 @@ export const Submenu = ({ items, icon, name }) => {
|
|
|
107
106
|
trigger={trigger}
|
|
108
107
|
onClick={() => history.push(primaryRoute)}
|
|
109
108
|
>
|
|
110
|
-
<Dropdown.Menu onClick={e => e.stopPropagation()}>
|
|
109
|
+
<Dropdown.Menu onClick={(e) => e.stopPropagation()}>
|
|
111
110
|
{_.size(filteredItems) > 1 && (
|
|
112
111
|
<>
|
|
113
112
|
<Dropdown.Header
|
|
@@ -132,7 +131,10 @@ export const Submenu = ({ items, icon, name }) => {
|
|
|
132
131
|
|
|
133
132
|
Submenu.propTypes = {
|
|
134
133
|
items: PropTypes.array,
|
|
135
|
-
icon: PropTypes.string
|
|
134
|
+
icon: PropTypes.string,
|
|
135
|
+
sidebarVisible: PropTypes.bool,
|
|
136
136
|
};
|
|
137
137
|
|
|
138
|
-
export
|
|
138
|
+
export const mapStateToProps = ({ sidebarVisible }) => ({ sidebarVisible });
|
|
139
|
+
|
|
140
|
+
export default connect(mapStateToProps)(Submenu);
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import { Form, Label } from "semantic-ui-react";
|
|
5
|
+
import { useIntl, FormattedMessage } from "react-intl";
|
|
6
|
+
import { useQuery } from "@apollo/client";
|
|
7
|
+
import { accentInsensitivePathOrder } from "../services/sort";
|
|
8
|
+
import { TEMPLATES_QUERY } from "../api/queries";
|
|
9
|
+
|
|
10
|
+
const makeOptions = _.flow(
|
|
11
|
+
_.map(({ label: text, id: value }) => ({
|
|
12
|
+
key: value,
|
|
13
|
+
value,
|
|
14
|
+
text,
|
|
15
|
+
})),
|
|
16
|
+
_.sortBy(accentInsensitivePathOrder("text"))
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
export const TemplateSelector = ({
|
|
20
|
+
clearable,
|
|
21
|
+
loading,
|
|
22
|
+
name = "template",
|
|
23
|
+
onChange,
|
|
24
|
+
required,
|
|
25
|
+
selectedValue,
|
|
26
|
+
templates,
|
|
27
|
+
}) => {
|
|
28
|
+
const { formatMessage } = useIntl();
|
|
29
|
+
const options = makeOptions(templates);
|
|
30
|
+
const hidden = loading ? false : _.size(templates) <= 1;
|
|
31
|
+
|
|
32
|
+
const handleChange = (e, { value, ...data }) => {
|
|
33
|
+
const template = _.find({ id: value })(templates);
|
|
34
|
+
onChange(e, { ...data, value, template });
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return hidden ? null : (
|
|
38
|
+
<Form.Field required={required}>
|
|
39
|
+
<label>
|
|
40
|
+
<FormattedMessage id="template.selector.label" />
|
|
41
|
+
{!selectedValue && required ? (
|
|
42
|
+
<Label pointing="left">
|
|
43
|
+
<FormattedMessage id="template.form.validation.empty_required" />
|
|
44
|
+
</Label>
|
|
45
|
+
) : null}
|
|
46
|
+
</label>
|
|
47
|
+
<Form.Dropdown
|
|
48
|
+
clearable={clearable}
|
|
49
|
+
loading={loading}
|
|
50
|
+
name={name}
|
|
51
|
+
onChange={handleChange}
|
|
52
|
+
options={options}
|
|
53
|
+
placeholder={formatMessage({
|
|
54
|
+
id: loading ? "loading" : "template.selector.placeholder",
|
|
55
|
+
})}
|
|
56
|
+
search
|
|
57
|
+
selection
|
|
58
|
+
value={_.toString(selectedValue)}
|
|
59
|
+
/>
|
|
60
|
+
</Form.Field>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
TemplateSelector.propTypes = {
|
|
65
|
+
clearable: PropTypes.bool,
|
|
66
|
+
loading: PropTypes.bool,
|
|
67
|
+
onChange: PropTypes.func,
|
|
68
|
+
name: PropTypes.string,
|
|
69
|
+
required: PropTypes.bool,
|
|
70
|
+
selectedValue: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
71
|
+
templates: PropTypes.array,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const emptyTemplates = [];
|
|
75
|
+
export const TemplateSelectorLoader = ({
|
|
76
|
+
scope,
|
|
77
|
+
onLoad,
|
|
78
|
+
domainIds,
|
|
79
|
+
...props
|
|
80
|
+
}) => {
|
|
81
|
+
const { loading, error, data } = useQuery(TEMPLATES_QUERY, {
|
|
82
|
+
fetchPolicy: "cache-and-network",
|
|
83
|
+
variables: { scope, domainIds },
|
|
84
|
+
onCompleted: onLoad,
|
|
85
|
+
});
|
|
86
|
+
if (error) return null;
|
|
87
|
+
const templates = data?.templates || emptyTemplates;
|
|
88
|
+
return (
|
|
89
|
+
<TemplateSelector loading={loading} templates={templates} {...props} />
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
TemplateSelectorLoader.propTypes = {
|
|
94
|
+
domainIds: PropTypes.array,
|
|
95
|
+
scope: PropTypes.string.isRequired,
|
|
96
|
+
onLoad: PropTypes.func,
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export default TemplateSelectorLoader;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import DashboardMenu from "../DashboardMenu";
|
|
4
4
|
|
|
5
5
|
jest.mock("../../hooks", () => ({
|
|
6
6
|
useActiveRoutes: jest.fn(() => true),
|
|
7
|
-
useAuthorized: jest.fn(() => true)
|
|
7
|
+
useAuthorized: jest.fn(() => true),
|
|
8
8
|
}));
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
useSelector: jest.fn(() => ({
|
|
10
|
+
const renderOpts = {
|
|
11
|
+
state: {
|
|
13
12
|
systemConfiguration: [
|
|
14
13
|
{
|
|
15
14
|
external_id: "config_metabase",
|
|
@@ -18,16 +17,16 @@ jest.mock("react-redux", () => ({
|
|
|
18
17
|
dashboard_id: 2,
|
|
19
18
|
quality_dashboard_id: 8,
|
|
20
19
|
metabase_url: "http://metabase.com",
|
|
21
|
-
secret_key: "###"
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
]
|
|
25
|
-
}
|
|
26
|
-
}
|
|
20
|
+
secret_key: "###",
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
};
|
|
27
26
|
|
|
28
27
|
describe("<DashboardMenu />", () => {
|
|
29
28
|
it("matches the latest snapshot", () => {
|
|
30
|
-
const
|
|
31
|
-
expect(
|
|
29
|
+
const { container } = render(<DashboardMenu />, renderOpts);
|
|
30
|
+
expect(container).toMatchSnapshot();
|
|
32
31
|
});
|
|
33
32
|
});
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
3
|
import { DateTime } from "..";
|
|
4
4
|
|
|
5
5
|
describe("<DateTime />", () => {
|
|
6
6
|
it("matches the latest snapshot", () => {
|
|
7
|
-
const
|
|
8
|
-
|
|
7
|
+
const { container } = render(
|
|
8
|
+
<DateTime value="2018-06-27T07:32:53.154377Z" />
|
|
9
|
+
);
|
|
10
|
+
expect(container).toMatchSnapshot();
|
|
9
11
|
});
|
|
10
12
|
});
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import QualityMenu from "../QualityMenu";
|
|
4
4
|
|
|
5
5
|
jest.mock("../../hooks", () => ({
|
|
6
6
|
useActiveRoutes: jest.fn(() => true),
|
|
7
|
-
useAuthorized: jest.fn(() => true)
|
|
7
|
+
useAuthorized: jest.fn(() => true),
|
|
8
|
+
useAuthorizedItems: jest.fn((items) => items),
|
|
8
9
|
}));
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
useSelector: jest.fn(() => ({
|
|
11
|
+
const renderOpts = {
|
|
12
|
+
state: {
|
|
13
13
|
systemConfiguration: [
|
|
14
14
|
{
|
|
15
15
|
external_id: "config_metabase",
|
|
@@ -18,16 +18,16 @@ jest.mock("react-redux", () => ({
|
|
|
18
18
|
dashboard_id: 2,
|
|
19
19
|
quality_dashboard_id: 8,
|
|
20
20
|
metabase_url: "http://metabase.com",
|
|
21
|
-
secret_key: "###"
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
]
|
|
25
|
-
}
|
|
26
|
-
}
|
|
21
|
+
secret_key: "###",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
27
|
|
|
28
28
|
describe("<QualityMenu />", () => {
|
|
29
29
|
it("matches the latest snapshot", () => {
|
|
30
|
-
const
|
|
31
|
-
expect(
|
|
30
|
+
const { container } = render(<QualityMenu />, renderOpts);
|
|
31
|
+
expect(container).toMatchSnapshot();
|
|
32
32
|
});
|
|
33
33
|
});
|
|
@@ -1,24 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import SideMenu from "../SideMenu";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
documentRef: null,
|
|
7
|
-
windowRef: null
|
|
8
|
-
}));
|
|
9
|
-
|
|
10
|
-
jest.mock("react-redux", () => ({
|
|
11
|
-
...jest.requireActual("react-redux"),
|
|
12
|
-
useSelector: jest.fn(() => ({ sidebarVisible: true }))
|
|
13
|
-
}));
|
|
5
|
+
const renderOpts = { state: { sidebarVisible: true } };
|
|
14
6
|
|
|
15
7
|
describe("<SideMenu />", () => {
|
|
16
8
|
it("matches the latest snapshot", () => {
|
|
17
|
-
const
|
|
9
|
+
const { container } = render(
|
|
18
10
|
<SideMenu>
|
|
19
11
|
<p>Hello</p>
|
|
20
|
-
</SideMenu
|
|
12
|
+
</SideMenu>,
|
|
13
|
+
renderOpts
|
|
21
14
|
);
|
|
22
|
-
expect(
|
|
15
|
+
expect(container).toMatchSnapshot();
|
|
23
16
|
});
|
|
24
17
|
});
|
|
@@ -1,29 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import Submenu from "../Submenu";
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
push: jest.fn()
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
jest.mock("react-redux", () => ({
|
|
10
|
-
...jest.requireActual("react-redux"),
|
|
11
|
-
useSelector: jest.fn(() => ({ sidebarVisible: true }))
|
|
12
|
-
}));
|
|
13
|
-
|
|
14
|
-
jest.mock("react-router-dom", () => ({
|
|
15
|
-
...jest.requireActual("react-router-dom"),
|
|
16
|
-
useLocation: () => ({ pathname: "/bar" }),
|
|
17
|
-
useHistory: () => mockHistory
|
|
18
|
-
}));
|
|
5
|
+
const renderOpts = { state: { sidebarVisible: true }, routes: ["/bar"] };
|
|
19
6
|
|
|
20
7
|
describe("<Submenu />", () => {
|
|
21
8
|
it("matches the latest snapshot", () => {
|
|
22
9
|
const items = [
|
|
23
10
|
{ name: "foo", routes: ["/foo", "/bar"] },
|
|
24
|
-
{ name: "baz", routes: ["/baz"] }
|
|
11
|
+
{ name: "baz", routes: ["/baz"] },
|
|
25
12
|
];
|
|
26
|
-
const
|
|
27
|
-
|
|
13
|
+
const props = { name: "foo", items };
|
|
14
|
+
const { container } = render(<Submenu {...props} />, renderOpts);
|
|
15
|
+
expect(container).toMatchSnapshot();
|
|
28
16
|
});
|
|
29
17
|
});
|