@truedat/bg 7.2.1 → 7.2.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.
Files changed (29) hide show
  1. package/package.json +6 -6
  2. package/src/concepts/components/ConceptsUploadButton.js +1 -1
  3. package/src/concepts/components/__tests__/ConceptManageDomain.spec.js +28 -4
  4. package/src/concepts/components/__tests__/__snapshots__/ConceptForm.spec.js.snap +10 -12
  5. package/src/concepts/components/__tests__/__snapshots__/ConceptManageDomain.spec.js.snap +58 -1
  6. package/src/concepts/components/__tests__/__snapshots__/ConceptsBulkUpdate.spec.js.snap +10 -12
  7. package/src/concepts/components/__tests__/__snapshots__/SharedToForm.spec.js.snap +10 -12
  8. package/src/messages/en.js +2 -0
  9. package/src/messages/es.js +2 -0
  10. package/src/taxonomy/components/Domain.js +11 -71
  11. package/src/taxonomy/components/DomainCards.js +113 -0
  12. package/src/taxonomy/components/DomainContent.js +119 -0
  13. package/src/taxonomy/components/DomainTabs.js +92 -40
  14. package/src/taxonomy/components/Domains.js +144 -25
  15. package/src/taxonomy/components/DomainsActions.js +4 -4
  16. package/src/taxonomy/components/__tests__/Domain.spec.js +127 -2
  17. package/src/taxonomy/components/__tests__/DomainCards.spec.js +148 -0
  18. package/src/taxonomy/components/__tests__/DomainContent.spec.js +168 -0
  19. package/src/taxonomy/components/__tests__/DomainTabs.spec.js +108 -0
  20. package/src/taxonomy/components/__tests__/Domains.spec.js +149 -2
  21. package/src/taxonomy/components/__tests__/DomainsActions.spec.js +15 -8
  22. package/src/taxonomy/components/__tests__/__snapshots__/Domain.spec.js.snap +8 -0
  23. package/src/taxonomy/components/__tests__/__snapshots__/DomainCards.spec.js.snap +291 -0
  24. package/src/taxonomy/components/__tests__/__snapshots__/DomainContent.spec.js.snap +305 -0
  25. package/src/taxonomy/components/__tests__/__snapshots__/DomainTabs.spec.js.snap +40 -0
  26. package/src/taxonomy/components/__tests__/__snapshots__/Domains.spec.js.snap +74 -4
  27. package/src/taxonomy/components/__tests__/__snapshots__/DomainsActions.spec.js.snap +13 -22
  28. package/src/taxonomy/styles/domainCards.less +4 -0
  29. package/src/taxonomy/styles/domains.less +15 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/bg",
3
- "version": "7.2.1",
3
+ "version": "7.2.3",
4
4
  "description": "Truedat Web Business Glossary",
5
5
  "sideEffects": false,
6
6
  "jsnext:main": "src/index.js",
@@ -34,7 +34,7 @@
34
34
  "@testing-library/jest-dom": "^5.16.5",
35
35
  "@testing-library/react": "^12.0.0",
36
36
  "@testing-library/user-event": "^13.2.1",
37
- "@truedat/test": "7.2.1",
37
+ "@truedat/test": "7.2.3",
38
38
  "babel-jest": "^28.1.0",
39
39
  "babel-plugin-dynamic-import-node": "^2.3.3",
40
40
  "babel-plugin-lodash": "^3.3.4",
@@ -86,9 +86,9 @@
86
86
  ]
87
87
  },
88
88
  "dependencies": {
89
- "@truedat/core": "7.2.1",
90
- "@truedat/df": "7.2.1",
91
- "@truedat/lm": "7.2.1",
89
+ "@truedat/core": "7.2.3",
90
+ "@truedat/df": "7.2.3",
91
+ "@truedat/lm": "7.2.3",
92
92
  "decode-uri-component": "^0.2.2",
93
93
  "file-saver": "^2.0.5",
94
94
  "moment": "^2.29.4",
@@ -111,5 +111,5 @@
111
111
  "react-dom": ">= 16.8.6 < 17",
112
112
  "semantic-ui-react": ">= 2.0.3 < 2.2"
113
113
  },
114
- "gitHead": "10ba779646ef549e6db1235b3acd6d430526f487"
114
+ "gitHead": "1f8b6f4d6fbd6e278493c35885e540c14f9c551b"
115
115
  }
@@ -33,7 +33,7 @@ export const ConceptsUploadButton = ({
33
33
  };
34
34
  return (
35
35
  <UploadModal
36
- extraAction={canAutoPublish && extraAction}
36
+ extraAction={canAutoPublish ? extraAction : null}
37
37
  icon="upload"
38
38
  trigger={
39
39
  <Button
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  import { waitFor } from "@testing-library/react";
3
3
  import { render } from "@truedat/test/render";
4
+ import { DOMAINS_QUERY } from "@truedat/core/api/queries";
4
5
  import { ConceptManageDomain } from "../ConceptManageDomain";
5
6
 
6
7
  describe("<ConceptManageDomain />", () => {
@@ -11,16 +12,33 @@ describe("<ConceptManageDomain />", () => {
11
12
  { id: 3, name: "baz", level: 0 },
12
13
  ];
13
14
  const conceptAction = jest.fn();
14
- // const saving = false;
15
15
  const setToDomain = [{ id: 2, name: "bar" }];
16
16
  const props = {
17
17
  domainOptions,
18
- // id,
19
18
  conceptAction,
20
- // saving,
21
19
  setToDomain,
22
20
  };
21
+
22
+ const domains = [
23
+ {
24
+ id: 1,
25
+ name: "foo",
26
+ parentId: 6,
27
+ actions: [],
28
+ externalId: "external_foo",
29
+ },
30
+ ];
31
+ const variables = {
32
+ action: "manageConcept",
33
+ };
34
+
35
+ const domainsMock = {
36
+ request: { query: DOMAINS_QUERY, variables },
37
+ result: { data: { domains: domains } },
38
+ };
39
+
23
40
  const renderOpts = {
41
+ mocks: [domainsMock],
24
42
  messages: {
25
43
  en: {
26
44
  "concept.changeDomain.header": "edit domain",
@@ -30,13 +48,19 @@ describe("<ConceptManageDomain />", () => {
30
48
  "domain.selector.placeholder": "select a domain...",
31
49
  },
32
50
  },
51
+ fallback: "lazy",
33
52
  };
34
53
 
35
54
  it("matches the latest snapshot", async () => {
36
- const { container } = render(
55
+ const { container, queryByText } = render(
37
56
  <ConceptManageDomain {...props} />,
38
57
  renderOpts
39
58
  );
59
+ await waitFor(() => expect(queryByText(/lazy/i)).not.toBeInTheDocument());
60
+ await waitFor(() =>
61
+ expect(queryByText(/loading/i)).not.toBeInTheDocument()
62
+ );
63
+
40
64
  await waitFor(() => {
41
65
  expect(container).toMatchSnapshot();
42
66
  });
@@ -53,14 +53,16 @@ exports[`<ConceptForm /> with multiple templates matches the latest snapshot 1`]
53
53
  role="option"
54
54
  >
55
55
  <div
56
- style="margin-left: 0px;"
56
+ class="item-content"
57
+ style="margin-left: 0px; padding-left: 5px;"
57
58
  >
58
59
  <i
59
60
  aria-hidden="true"
60
- class="chevron circle down icon"
61
+ class="chevron right icon"
61
62
  />
62
63
  <span
63
64
  style="opacity: 1;"
65
+ title="barDomain"
64
66
  >
65
67
  barDomain
66
68
  </span>
@@ -72,14 +74,12 @@ exports[`<ConceptForm /> with multiple templates matches the latest snapshot 1`]
72
74
  role="option"
73
75
  >
74
76
  <div
75
- style="margin-left: 0px;"
77
+ class="item-content"
78
+ style="margin-left: 0px; padding-left: 25px;"
76
79
  >
77
- <i
78
- aria-hidden="true"
79
- class="circle icon"
80
- />
81
80
  <span
82
81
  style="opacity: 1;"
82
+ title="bazDomain"
83
83
  >
84
84
  bazDomain
85
85
  </span>
@@ -91,14 +91,12 @@ exports[`<ConceptForm /> with multiple templates matches the latest snapshot 1`]
91
91
  role="option"
92
92
  >
93
93
  <div
94
- style="margin-left: 0px;"
94
+ class="item-content"
95
+ style="margin-left: 0px; padding-left: 25px;"
95
96
  >
96
- <i
97
- aria-hidden="true"
98
- class="circle icon"
99
- />
100
97
  <span
101
98
  style="opacity: 1;"
99
+ title="fooDomain"
102
100
  >
103
101
  fooDomain
104
102
  </span>
@@ -12,8 +12,65 @@ exports[`<ConceptManageDomain /> matches the latest snapshot 1`] = `
12
12
  edit domain
13
13
  </h2>
14
14
  <form
15
- class="ui loading form"
15
+ class="ui form"
16
16
  >
17
+ <div
18
+ class="required field fix-dropdown-selector "
19
+ >
20
+ <div
21
+ aria-disabled="false"
22
+ aria-expanded="false"
23
+ aria-multiselectable="false"
24
+ class="ui floating dropdown"
25
+ required=""
26
+ role="listbox"
27
+ tabindex="0"
28
+ >
29
+ <label>
30
+ select a domain...
31
+ </label>
32
+ <i
33
+ aria-hidden="true"
34
+ class="dropdown icon"
35
+ />
36
+ <div
37
+ class="menu transition"
38
+ >
39
+ <div
40
+ class="ui fluid left icon input search "
41
+ >
42
+ <input
43
+ type="text"
44
+ />
45
+ <i
46
+ aria-hidden="true"
47
+ class="search icon"
48
+ />
49
+ </div>
50
+ <div
51
+ class="scrolling menu transition"
52
+ >
53
+ <div
54
+ aria-selected="false"
55
+ class="item"
56
+ role="option"
57
+ >
58
+ <div
59
+ class="item-content"
60
+ style="margin-left: 0px; padding-left: 25px;"
61
+ >
62
+ <span
63
+ style="opacity: 1;"
64
+ title="foo"
65
+ >
66
+ foo
67
+ </span>
68
+ </div>
69
+ </div>
70
+ </div>
71
+ </div>
72
+ </div>
73
+ </div>
17
74
  <div
18
75
  class="actions"
19
76
  >
@@ -81,14 +81,16 @@ exports[`<ConceptsBulkUpdate /> matches the latest snapshot 1`] = `
81
81
  role="option"
82
82
  >
83
83
  <div
84
- style="margin-left: 0px;"
84
+ class="item-content"
85
+ style="margin-left: 0px; padding-left: 5px;"
85
86
  >
86
87
  <i
87
88
  aria-hidden="true"
88
- class="chevron circle down icon"
89
+ class="chevron right icon"
89
90
  />
90
91
  <span
91
92
  style="opacity: 1;"
93
+ title="barDomain"
92
94
  >
93
95
  barDomain
94
96
  </span>
@@ -100,14 +102,12 @@ exports[`<ConceptsBulkUpdate /> matches the latest snapshot 1`] = `
100
102
  role="option"
101
103
  >
102
104
  <div
103
- style="margin-left: 0px;"
105
+ class="item-content"
106
+ style="margin-left: 0px; padding-left: 25px;"
104
107
  >
105
- <i
106
- aria-hidden="true"
107
- class="circle icon"
108
- />
109
108
  <span
110
109
  style="opacity: 1;"
110
+ title="bazDomain"
111
111
  >
112
112
  bazDomain
113
113
  </span>
@@ -119,14 +119,12 @@ exports[`<ConceptsBulkUpdate /> matches the latest snapshot 1`] = `
119
119
  role="option"
120
120
  >
121
121
  <div
122
- style="margin-left: 0px;"
122
+ class="item-content"
123
+ style="margin-left: 0px; padding-left: 25px;"
123
124
  >
124
- <i
125
- aria-hidden="true"
126
- class="circle icon"
127
- />
128
125
  <span
129
126
  style="opacity: 1;"
127
+ title="fooDomain"
130
128
  >
131
129
  fooDomain
132
130
  </span>
@@ -61,14 +61,16 @@ exports[`<SharedToForm /> matches the latest snapshot 1`] = `
61
61
  role="option"
62
62
  >
63
63
  <div
64
- style="margin-left: 0px;"
64
+ class="item-content"
65
+ style="margin-left: 0px; padding-left: 5px;"
65
66
  >
66
67
  <i
67
68
  aria-hidden="true"
68
- class="chevron circle down icon"
69
+ class="chevron right icon"
69
70
  />
70
71
  <span
71
72
  style="opacity: 1;"
73
+ title="barDomain"
72
74
  >
73
75
  barDomain
74
76
  </span>
@@ -80,14 +82,12 @@ exports[`<SharedToForm /> matches the latest snapshot 1`] = `
80
82
  role="option"
81
83
  >
82
84
  <div
83
- style="margin-left: 0px;"
85
+ class="item-content"
86
+ style="margin-left: 0px; padding-left: 25px;"
84
87
  >
85
- <i
86
- aria-hidden="true"
87
- class="circle icon"
88
- />
89
88
  <span
90
89
  style="opacity: 1;"
90
+ title="bazDomain"
91
91
  >
92
92
  bazDomain
93
93
  </span>
@@ -99,14 +99,12 @@ exports[`<SharedToForm /> matches the latest snapshot 1`] = `
99
99
  role="option"
100
100
  >
101
101
  <div
102
- style="margin-left: 0px;"
102
+ class="item-content"
103
+ style="margin-left: 0px; padding-left: 25px;"
103
104
  >
104
- <i
105
- aria-hidden="true"
106
- class="circle icon"
107
- />
108
105
  <span
109
106
  style="opacity: 1;"
107
+ title="fooDomain"
110
108
  >
111
109
  fooDomain
112
110
  </span>
@@ -290,6 +290,8 @@ export default {
290
290
  "domain.selector.label": "Domain",
291
291
  "domain.selector.placeholder": "Select a domain...",
292
292
  "domains.actions.create": "New Domain",
293
+ "domains.list.hide": "Hide Domains List",
294
+ "domains.list.show": "Show Domains List",
293
295
  "domains.search.placeholder": "Search domains...",
294
296
  "domains.search.error.fields": "Search fields not valid",
295
297
  "domains.search.results.count": "{count} domains found:",
@@ -292,6 +292,8 @@ export default {
292
292
  "domain.selector.label": "Dominio",
293
293
  "domain.selector.placeholder": "Selecciona un dominio...",
294
294
  "domains.actions.create": "Nuevo dominio",
295
+ "domains.list.hide": "Ocultar lista de dominios",
296
+ "domains.list.show": "Mostrar lista de dominios",
295
297
  "domains.search.placeholder": "Buscar dominios...",
296
298
  "domains.search.error.fields": "Campos de búsqueda no válidos",
297
299
  "domains.search.results.count": "{count} dominios encontrados:",
@@ -2,37 +2,16 @@ import React from "react";
2
2
  import PropTypes from "prop-types";
3
3
  import { Route, Switch } from "react-router-dom";
4
4
  import { Segment } from "semantic-ui-react";
5
- import { Unauthorized } from "@truedat/core/components";
6
- import { useAuthorized } from "@truedat/core/hooks";
7
- import {
8
- DOMAIN_CONCEPTS,
9
- DOMAIN_IMPLEMENTATIONS,
10
- DOMAIN_MEMBERS,
11
- DOMAIN_MEMBERS_NEW,
12
- DOMAIN_STRUCTURES,
13
- DOMAIN_NEW,
14
- DOMAIN_EDIT,
15
- } from "@truedat/core/routes";
16
- import UserSearchFiltersLoader from "@truedat/dd/components/UserSearchFiltersLoader";
17
- import DomainConcepts from "../../concepts/components/DomainConcepts";
5
+ import { DOMAIN_NEW, DOMAIN_EDIT } from "@truedat/core/routes";
18
6
  import { useDomain } from "../../hooks/useDomains";
19
7
  import DomainDetail from "./DomainDetail";
20
- import DomainImplementations from "./DomainImplementations";
21
- import DomainMembers from "./DomainMembers";
22
- import DomainStructures from "./DomainStructures";
23
8
  import DomainTabs from "./DomainTabs";
24
9
  import EditDomain from "./EditDomain";
25
10
  import NewDomain from "./NewDomain";
26
- import AddDomainMember from "./AddDomainMember";
11
+ import DomainContent from "./DomainContent";
27
12
 
28
- const RolesLoader = React.lazy(() =>
29
- import("@truedat/auth/roles/components/RolesLoader")
30
- );
31
-
32
- export const Domain = ({ domainId }) => {
13
+ export const Domain = ({ domainId, domains, taxonomyConfig }) => {
33
14
  const { data: domain } = useDomain(domainId);
34
- const ddAuthorized = useAuthorized("data_dictionary");
35
- const dqAuthorized = useAuthorized("quality");
36
15
 
37
16
  return domain ? (
38
17
  <Segment>
@@ -49,54 +28,13 @@ export const Domain = ({ domainId }) => {
49
28
  />
50
29
  <>
51
30
  <DomainDetail id={domain.id} />
52
- <DomainTabs domain={domain} />
31
+ <DomainTabs domain={domain} taxonomyConfig={taxonomyConfig} />
53
32
  <Segment attached="bottom">
54
- <Switch>
55
- <Route
56
- exact
57
- path={DOMAIN_CONCEPTS}
58
- render={() => <DomainConcepts domain={domain} />}
59
- />
60
- <Route
61
- exact
62
- path={DOMAIN_STRUCTURES}
63
- render={() =>
64
- ddAuthorized ? (
65
- <DomainStructures domain={domain} />
66
- ) : (
67
- <Unauthorized />
68
- )
69
- }
70
- />
71
- <Route
72
- exact
73
- path={DOMAIN_IMPLEMENTATIONS}
74
- render={() =>
75
- dqAuthorized ? (
76
- <>
77
- <UserSearchFiltersLoader scope="rule_implementation" />
78
- <DomainImplementations domain={domain} />
79
- </>
80
- ) : (
81
- <Unauthorized />
82
- )
83
- }
84
- />
85
- <Route
86
- exact
87
- path={DOMAIN_MEMBERS}
88
- render={() => <DomainMembers domainId={domain.id} />}
89
- />
90
- <Route
91
- path={DOMAIN_MEMBERS_NEW}
92
- render={({ match }) => (
93
- <>
94
- <RolesLoader />
95
- <AddDomainMember id={parseInt(match?.params?.id)} />
96
- </>
97
- )}
98
- />
99
- </Switch>
33
+ <DomainContent
34
+ domain={domain}
35
+ domains={domains}
36
+ taxonomyConfig={taxonomyConfig}
37
+ />
100
38
  </Segment>
101
39
  </>
102
40
  </Switch>
@@ -106,6 +44,8 @@ export const Domain = ({ domainId }) => {
106
44
 
107
45
  Domain.propTypes = {
108
46
  domainId: PropTypes.number,
47
+ domains: PropTypes.array,
48
+ taxonomyConfig: PropTypes.object,
109
49
  };
110
50
 
111
51
  export default Domain;
@@ -0,0 +1,113 @@
1
+ import _ from "lodash/fp";
2
+ import React, { useState } from "react";
3
+ import PropTypes from "prop-types";
4
+ import { Link } from "react-router-dom";
5
+ import { Card, Header, Icon, Message, Input } from "semantic-ui-react";
6
+ import { FormattedMessage, useIntl } from "react-intl";
7
+ import { linkTo } from "@truedat/core/routes";
8
+ import DomainsActions from "./DomainsActions";
9
+
10
+ export const DomainCard = ({
11
+ id,
12
+ name,
13
+ type,
14
+ description,
15
+ childCount,
16
+ domain_group,
17
+ }) => (
18
+ <Card key={id} link as={Link} to={linkTo.DOMAIN({ id })}>
19
+ <Card.Content>
20
+ <Card.Header>
21
+ <Icon name="cube" />
22
+ {name}
23
+ </Card.Header>
24
+ <Card.Meta>
25
+ {_.get("name")(domain_group) && (
26
+ <>
27
+ <Icon name="object group" /> {_.get("name")(domain_group)}
28
+ <br />
29
+ </>
30
+ )}
31
+ <span>{type || <FormattedMessage id="domain" />}</span>
32
+ </Card.Meta>
33
+ </Card.Content>
34
+ <Card.Content description={description} />
35
+ <Card.Content extra>
36
+ <Icon name="cubes" />
37
+ <FormattedMessage
38
+ id="domain.props.children"
39
+ values={{ count: childCount }}
40
+ />
41
+ </Card.Content>
42
+ </Card>
43
+ );
44
+
45
+ DomainCard.propTypes = {
46
+ id: PropTypes.number,
47
+ name: PropTypes.string,
48
+ type: PropTypes.string,
49
+ childCount: PropTypes.number,
50
+ description: PropTypes.string,
51
+ domain_group: PropTypes.object,
52
+ };
53
+
54
+ export const DomainCards = ({ actions, domain, domains }) => {
55
+ const [domainsFilter, setDomainFilter] = useState("");
56
+ const { formatMessage } = useIntl();
57
+
58
+ const domainChildren = _.filter(["parent_id", domain?.id || null])(domains);
59
+ const visibleDomains = _.flow(
60
+ _.map((domain) => {
61
+ const children = _.filter(({ parent_id }) => parent_id == domain.id)(
62
+ domains
63
+ );
64
+ return { childCount: children.length, ...domain };
65
+ }),
66
+ _.filter((domain) =>
67
+ domain.name.toLowerCase().includes(domainsFilter.toLowerCase())
68
+ ),
69
+ _.orderBy("name", "asc")
70
+ )(domainChildren);
71
+ return (
72
+ <>
73
+ <Header as="h4">
74
+ <Header.Content className="taxonomy-domains-domaincards-header-content">
75
+ <div>
76
+ <Input
77
+ icon="search"
78
+ value={domainsFilter}
79
+ placeholder={formatMessage({
80
+ id: "domains.search.placeholder",
81
+ })}
82
+ onChange={(_e, { value }) => setDomainFilter(value)}
83
+ />
84
+ </div>
85
+ {_.isEmpty(domain) ? <DomainsActions actions={actions} /> : null}
86
+ </Header.Content>
87
+ </Header>
88
+
89
+ {_.isEmpty(visibleDomains) && !_.isEmpty(domainChildren) ? (
90
+ <Header as="h4">
91
+ <Icon name="search" />
92
+ <Header.Content>
93
+ <FormattedMessage id="domains.search.results.empty" />
94
+ </Header.Content>
95
+ </Header>
96
+ ) : null}
97
+
98
+ {_.isEmpty(domainChildren) && domain && domain.id ? (
99
+ <Message header={formatMessage({ id: "domain.children.empty" })} />
100
+ ) : null}
101
+
102
+ <Card.Group>{visibleDomains.map(DomainCard)}</Card.Group>
103
+ </>
104
+ );
105
+ };
106
+
107
+ DomainCards.propTypes = {
108
+ actions: PropTypes.object,
109
+ domains: PropTypes.array,
110
+ domain: PropTypes.object,
111
+ };
112
+
113
+ export default DomainCards;