@truedat/core 4.56.9 → 4.58.1

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,6 +1,18 @@
1
1
  # Changelog
2
2
 
3
- ## [4.56.9] 2022-11-12
3
+ ## [4.58.1] 2022-12-19
4
+
5
+ ### Added
6
+
7
+ - [TD-5367] Route for grant detail
8
+
9
+ ## [4.58.0] 2022-12-15
10
+
11
+ ### Added
12
+
13
+ - [TD-3919] Add concept subscopes submenus
14
+
15
+ ## [4.56.9] 2022-12-12
4
16
 
5
17
  ### Added
6
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/core",
3
- "version": "4.56.9",
3
+ "version": "4.58.1",
4
4
  "description": "Truedat Web Core",
5
5
  "sideEffects": false,
6
6
  "jsnext:main": "src/index.js",
@@ -35,7 +35,7 @@
35
35
  "@testing-library/jest-dom": "^5.16.5",
36
36
  "@testing-library/react": "^12.0.0",
37
37
  "@testing-library/user-event": "^13.2.1",
38
- "@truedat/test": "4.56.9",
38
+ "@truedat/test": "4.58.1",
39
39
  "babel-jest": "^28.1.0",
40
40
  "babel-plugin-dynamic-import-node": "^2.3.3",
41
41
  "babel-plugin-lodash": "^3.3.4",
@@ -107,7 +107,7 @@
107
107
  "semantic-ui-react": "^2.1.4",
108
108
  "slate": "^0.47.3",
109
109
  "slate-react": "^0.22.3",
110
- "swr": "^1.3.0",
110
+ "swr": "^2.0.0",
111
111
  "validator": "^13.6.0"
112
112
  },
113
113
  "peerDependencies": {
@@ -115,5 +115,5 @@
115
115
  "react-dom": ">= 16.8.6 < 17",
116
116
  "semantic-ui-react": ">= 2.0.3 < 2.2"
117
117
  },
118
- "gitHead": "da9a49da6d48b51faf603abff56ff7b1b6c5e413"
118
+ "gitHead": "f1d6fab3f573f3f3ee9e0e6060d2761d452ca804"
119
119
  }
@@ -7,6 +7,7 @@ import { FormattedMessage } from "react-intl";
7
7
  export const GenericCrumbs = ({ header, title }) => {
8
8
  const history = useHistory();
9
9
  const goBack = () => history.goBack();
10
+
10
11
  return (
11
12
  <Breadcrumb>
12
13
  <Breadcrumb.Section onClick={goBack} active={false}>
@@ -1,30 +1,69 @@
1
+ import _ from "lodash/fp";
1
2
  import React from "react";
3
+ import TemplatesLoader from "@truedat/df/templates/components/TemplatesLoader";
4
+ import { connect } from "react-redux";
5
+ import PropTypes from "prop-types";
6
+ import { makeGetSubscopes } from "@truedat/df/selectors/subscopedTemplates";
7
+ import { linkTo } from "@truedat/core/routes";
2
8
  import { useAuthorized } from "../hooks";
3
9
  import { CONCEPTS, CONCEPTS_PENDING } from "../routes";
4
10
  import Submenu from "./Submenu";
5
11
 
6
- const items = [
12
+ const items = (bgSubscopes = []) => [
7
13
  {
8
14
  name: "concepts",
9
15
  routes: [CONCEPTS],
10
- groups: ["business_glossary_view"]
16
+ groups: ["business_glossary_view"],
11
17
  },
18
+ ...bgSubscopes,
12
19
  {
13
20
  name: "concepts_management",
14
21
  routes: [CONCEPTS_PENDING],
15
- groups: ["business_glossary_management"]
16
- }
22
+ groups: ["business_glossary_management"],
23
+ },
17
24
  ];
18
25
 
19
- export const GlossaryMenu = () => {
26
+ const subscopeItems = _.flow(
27
+ _.map((bgSubscope) => ({
28
+ name: bgSubscope,
29
+ routes: [linkTo.CONCEPTS_SUBSCOPED({ subscope: bgSubscope })],
30
+ groups: ["business_glossary_view"],
31
+ })),
32
+ _.orderBy(["name"], ["asc"])
33
+ );
34
+
35
+ export const GlossaryMenu = ({ bgSubscopes }) => {
20
36
  const authorized = useAuthorized([
21
37
  "business_glossary_view",
22
- "business_glossary_management"
38
+ "business_glossary_management",
23
39
  ]);
24
40
 
25
41
  return authorized ? (
26
- <Submenu items={items} icon="tags" name="glossary" />
42
+ // Use TemplatesLoader without scope, so that templates are saved in the
43
+ // "allTemplates" reducer, and thus do not collide with other
44
+ // <TemplatesLoader scope="..."> that collect templates in the "templates"
45
+ // reducer.
46
+ <>
47
+ <TemplatesLoader />
48
+ <Submenu
49
+ items={items(subscopeItems(bgSubscopes))}
50
+ icon="tags"
51
+ name="glossary"
52
+ />
53
+ </>
27
54
  ) : null;
28
55
  };
29
56
 
30
- export default GlossaryMenu;
57
+ GlossaryMenu.propTypes = {
58
+ bgSubscopes: PropTypes.array,
59
+ };
60
+
61
+ const makeMapStateToProps = () => {
62
+ const getSubscopes = makeGetSubscopes("bg");
63
+ const mapStateToProps = (state, props) => ({
64
+ bgSubscopes: getSubscopes(state, props),
65
+ });
66
+ return mapStateToProps;
67
+ };
68
+
69
+ export default connect(makeMapStateToProps)(GlossaryMenu);
@@ -81,6 +81,7 @@ export const Submenu = ({ items, icon, name, sidebarVisible }) => {
81
81
  );
82
82
  } else {
83
83
  const className = active ? "active" : null;
84
+
84
85
  const trigger = (
85
86
  <Link to={primaryRoute} className="ui">
86
87
  <Icon size="large" name={icon} />
@@ -1,16 +1,80 @@
1
1
  import React from "react";
2
- import { shallow } from "enzyme";
3
- import { GlossaryMenu } from "../GlossaryMenu";
2
+ import { render } from "@truedat/test/render";
3
+ import GlossaryMenu from "../GlossaryMenu";
4
4
 
5
5
  jest.mock("../../hooks", () => ({
6
6
  useActiveRoutes: jest.fn(() => true),
7
7
  useAuthorized: jest.fn(() => true),
8
- useAuthorizedItems: jest.fn(() => true)
8
+ useAuthorizedItems: jest.fn((items) => items),
9
9
  }));
10
10
 
11
+ const messages = {
12
+ en: {
13
+ "sidemenu.concepts": "sidemenu.concepts",
14
+ "sidemenu.concepts_management": "sidemenu.concepts_management",
15
+ },
16
+ };
17
+
18
+ const renderOpts = {
19
+ messages,
20
+ state: {
21
+ allTemplates: [
22
+ {
23
+ content: [],
24
+ id: 7,
25
+ label: "Término",
26
+ name: "termino",
27
+ scope: "bg",
28
+ subscope: null,
29
+ },
30
+ {
31
+ content: [],
32
+ id: 2,
33
+ label: "Métrica",
34
+ name: "metrica",
35
+ scope: "bg",
36
+ subscope: null,
37
+ },
38
+ {
39
+ content: [],
40
+ id: 3,
41
+ label: "Dimensión",
42
+ name: "dimension",
43
+ scope: "bg",
44
+ subscope: null,
45
+ },
46
+ {
47
+ content: [],
48
+ id: 53,
49
+ label: "subscope1",
50
+ name: "subscope1",
51
+ scope: "bg",
52
+ subscope: "subscope1",
53
+ },
54
+ {
55
+ content: [],
56
+ id: 54,
57
+ label: "subscope2",
58
+ name: "subscope2",
59
+ scope: "bg",
60
+ subscope: "subscope2",
61
+ },
62
+ ],
63
+ },
64
+ };
65
+
11
66
  describe("<GlossaryMenu />", () => {
12
- it("matches the latest snapshot", () => {
13
- const wrapper = shallow(<GlossaryMenu />);
14
- expect(wrapper).toMatchSnapshot();
67
+ it("matches the latest snapshot, finds fixed and subscopes submenus", () => {
68
+ const { container, queryByRole } = render(<GlossaryMenu />, renderOpts);
69
+
70
+ expect(container).toMatchSnapshot();
71
+ expect(
72
+ queryByRole("option", { name: "sidemenu.concepts" })
73
+ ).toBeInTheDocument();
74
+ expect(
75
+ queryByRole("option", { name: "sidemenu.concepts_management" })
76
+ ).toBeInTheDocument();
77
+ expect(queryByRole("option", { name: "subscope1" })).toBeInTheDocument();
78
+ expect(queryByRole("option", { name: "subscope2" })).toBeInTheDocument();
15
79
  });
16
80
  });
@@ -1,30 +1,90 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`<GlossaryMenu /> matches the latest snapshot 1`] = `
4
- <Connect(Submenu)
5
- icon="tags"
6
- items={
7
- Array [
8
- Object {
9
- "groups": Array [
10
- "business_glossary_view",
11
- ],
12
- "name": "concepts",
13
- "routes": Array [
14
- "/concepts",
15
- ],
16
- },
17
- Object {
18
- "groups": Array [
19
- "business_glossary_management",
20
- ],
21
- "name": "concepts_management",
22
- "routes": Array [
23
- "/pendingConcepts",
24
- ],
25
- },
26
- ]
27
- }
28
- name="glossary"
29
- />
3
+ exports[`<GlossaryMenu /> matches the latest snapshot, finds fixed and subscopes submenus 1`] = `
4
+ <div>
5
+ <div
6
+ class="active"
7
+ >
8
+ <div
9
+ aria-expanded="false"
10
+ class="ui item dropdown active"
11
+ role="listbox"
12
+ tabindex="0"
13
+ >
14
+ <a
15
+ class="ui"
16
+ href="/concepts"
17
+ >
18
+ <i
19
+ aria-hidden="true"
20
+ class="tags large icon"
21
+ />
22
+ </a>
23
+ <div
24
+ class="menu transition"
25
+ >
26
+ <div
27
+ class="header selectable"
28
+ >
29
+ glossary
30
+ </div>
31
+ <div
32
+ class="divider"
33
+ />
34
+ <a
35
+ aria-checked="true"
36
+ class="active item"
37
+ href="/concepts"
38
+ name="concepts"
39
+ role="option"
40
+ >
41
+ <span
42
+ class="text"
43
+ >
44
+ sidemenu.concepts
45
+ </span>
46
+ </a>
47
+ <a
48
+ aria-checked="true"
49
+ class="active item"
50
+ href="/subscopedConcepts/subscope1"
51
+ name="subscope1"
52
+ role="option"
53
+ >
54
+ <span
55
+ class="text"
56
+ >
57
+ subscope1
58
+ </span>
59
+ </a>
60
+ <a
61
+ aria-checked="true"
62
+ class="active item"
63
+ href="/subscopedConcepts/subscope2"
64
+ name="subscope2"
65
+ role="option"
66
+ >
67
+ <span
68
+ class="text"
69
+ >
70
+ subscope2
71
+ </span>
72
+ </a>
73
+ <a
74
+ aria-checked="true"
75
+ class="active item"
76
+ href="/pendingConcepts"
77
+ name="concepts_management"
78
+ role="option"
79
+ >
80
+ <span
81
+ class="text"
82
+ >
83
+ sidemenu.concepts_management
84
+ </span>
85
+ </a>
86
+ </div>
87
+ </div>
88
+ </div>
89
+ </div>
30
90
  `;
@@ -82,7 +82,7 @@ export default {
82
82
  "sidemenu.admin": "Administration",
83
83
  "sidemenu.catalog": "Catalog",
84
84
  "sidemenu.concepts_management": "Drafts",
85
- "sidemenu.concepts": "Concepts",
85
+ "sidemenu.concepts": "Glossary",
86
86
  "sidemenu.configurations": "Configuration",
87
87
  "sidemenu.dashboard": "Dashboard",
88
88
  "sidemenu.executions": "My Executions",
@@ -85,7 +85,7 @@ export default {
85
85
  "sidemenu.admin": "Administración",
86
86
  "sidemenu.catalog": "Catálogo",
87
87
  "sidemenu.concepts_management": "Borradores",
88
- "sidemenu.concepts": "Conceptos",
88
+ "sidemenu.concepts": "Glosario",
89
89
  "sidemenu.configurations": "Configuración",
90
90
  "sidemenu.dashboard": "Dashboard",
91
91
  "sidemenu.executions": "Mis ejecuciones",
package/src/routes.js CHANGED
@@ -6,6 +6,7 @@ export const CONCEPTS = "/concepts";
6
6
  export const CONCEPTS_BULK_UPDATE = "/concepts/bulk_update";
7
7
  export const CONCEPTS_NEW = "/concepts/new";
8
8
  export const CONCEPTS_PENDING = "/pendingConcepts";
9
+ export const CONCEPTS_SUBSCOPED = "/subscopedConcepts/:subscope";
9
10
  export const CONCEPT_ARCHIVE =
10
11
  "/concepts/:business_concept_id/versions/:id/archive";
11
12
  export const CONCEPT_EDIT = "/concepts/:business_concept_id/versions/:id/edit";
@@ -49,6 +50,7 @@ export const GRANT_APPROVAL_RULE = "/grantApproveRules/:id";
49
50
  export const GRANT_APPROVAL_RULE_NEW = "/grantApproveRules/new";
50
51
  export const GRANT_APPROVAL_RULE_EDIT = "/grantApproveRules/:id/edit";
51
52
  export const GRANT_APPROVAL_RULES = "/grantApprovalRules";
53
+ export const GRANT = "/grants/:id";
52
54
  export const GRANTS = "/grants";
53
55
  export const GRANTS_REQUESTS_CHECKOUT = "/grantsRequests/checkout";
54
56
  export const GRANT_REQUEST = "/grantRequests/:id";
@@ -210,6 +212,7 @@ const routes = {
210
212
  CONCEPTS_BULK_UPDATE,
211
213
  CONCEPTS_NEW,
212
214
  CONCEPTS_PENDING,
215
+ CONCEPTS_SUBSCOPED,
213
216
  CONCEPT_ARCHIVE,
214
217
  CONCEPT_EDIT,
215
218
  CONCEPT_EVENTS,
@@ -238,6 +241,7 @@ const routes = {
238
241
  DOMAIN_STRUCTURES,
239
242
  EXECUTION_GROUP,
240
243
  EXECUTION_GROUPS,
244
+ GRANT,
241
245
  GRANT_APPROVAL_RULE,
242
246
  GRANT_APPROVAL_RULE_NEW,
243
247
  GRANT_APPROVAL_RULE_EDIT,