@truedat/bg 6.16.4 → 7.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/bg",
3
- "version": "6.16.4",
3
+ "version": "7.0.1",
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": "6.15.2",
37
+ "@truedat/test": "7.0.1",
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": "6.15.2",
90
- "@truedat/df": "6.15.2",
91
- "@truedat/lm": "6.16.4",
89
+ "@truedat/core": "7.0.1",
90
+ "@truedat/df": "7.0.1",
91
+ "@truedat/lm": "7.0.1",
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": "ecf57a30185b9e353b6e2692702b5599e4425edb"
114
+ "gitHead": "fff3313b142abb69e4d4139e0b6fd85d1af1a898"
115
115
  }
@@ -1,19 +1,14 @@
1
1
  import _ from "lodash/fp";
2
2
  import React from "react";
3
3
  import PropTypes from "prop-types";
4
- import { useHistory } from "react-router-dom";
5
4
  import { Table } from "semantic-ui-react";
6
5
  import { columnDecorator } from "@truedat/core/services";
7
- import { linkTo } from "@truedat/core/routes";
8
6
 
9
7
  export const ConceptRow = ({ concept, columns }) => {
10
8
  const id = _.prop("id")(concept);
11
- const history = useHistory();
9
+
12
10
  return _.isEmpty(columns) || _.isEmpty(concept) ? null : (
13
- <Table.Row
14
- key={id}
15
- onClick={() => history.push(linkTo.CONCEPT_VERSION(concept))}
16
- >
11
+ <Table.Row key={id}>
17
12
  {columns.map((column, i) => (
18
13
  <Table.Cell
19
14
  key={i}
@@ -27,7 +22,7 @@ export const ConceptRow = ({ concept, columns }) => {
27
22
 
28
23
  ConceptRow.propTypes = {
29
24
  concept: PropTypes.object.isRequired,
30
- columns: PropTypes.array.isRequired
25
+ columns: PropTypes.array.isRequired,
31
26
  };
32
27
 
33
28
  export default ConceptRow;
@@ -32,7 +32,7 @@ export const ConceptsTable = ({ columnsByScope }) => {
32
32
  return (
33
33
  <>
34
34
  {!_.isEmpty(concepts) && (
35
- <Table selectable sortable>
35
+ <Table sortable>
36
36
  <Table.Header>
37
37
  <Table.Row>
38
38
  {conceptColumns &&
@@ -1,34 +1,58 @@
1
1
  import React from "react";
2
- import { shallow } from "enzyme";
2
+ import { render } from "@truedat/test/render";
3
3
  import { ConceptRow } from "../ConceptRow";
4
+ import { getConceptColumns } from "../../selectors";
4
5
 
5
- const mockHistory = {
6
- push: jest.fn()
6
+ const renderOpts = {
7
+ messages: {
8
+ en: {
9
+ "concepts.status.draft": "draft",
10
+ },
11
+ },
7
12
  };
8
13
 
9
- jest.mock("react-router-dom", () => ({
10
- ...jest.requireActual("react-router-dom"),
11
- useHistory: () => mockHistory
12
- }));
13
-
14
14
  describe("<ConceptRow />", () => {
15
15
  it("matches the latest snapshot", () => {
16
- const columns = [{ name: "foo" }, { name: "bar" }];
17
- const concept = { business_concept_id: 12, id: 42 };
16
+ const columns = getConceptColumns({ conceptColumns: null }).concepts;
17
+ const concept = {
18
+ business_concept_id: 12,
19
+ id: 42,
20
+ name: "foo",
21
+ status: "draft",
22
+ last_change_at: "2018-06-27T07:32:53.154377Z",
23
+ };
18
24
  const props = { columns, concept };
19
- const wrapper = shallow(<ConceptRow {...props} />);
20
- expect(wrapper).toMatchSnapshot();
25
+ const { container } = render(
26
+ <table>
27
+ <tbody>
28
+ <ConceptRow {...props} />
29
+ </tbody>
30
+ </table>,
31
+ renderOpts
32
+ );
33
+ expect(container).toMatchSnapshot();
21
34
  });
22
35
 
23
- it("clicking the row will push to history", () => {
24
- const columns = [{ name: "foo" }, { name: "bar" }];
25
- const concept = { business_concept_id: 12, id: 42 };
36
+ it("renders concept name as link", () => {
37
+ const columns = getConceptColumns({ conceptColumns: null }).concepts;
38
+ const concept = {
39
+ business_concept_id: 12,
40
+ id: 42,
41
+ name: "foo",
42
+ status: "draft",
43
+ last_change_at: "2018-06-27T07:32:53.154377Z",
44
+ };
26
45
  const props = { columns, concept };
27
- const wrapper = shallow(<ConceptRow {...props} />);
28
- wrapper.find("TableRow").prop("onClick")();
29
- expect(mockHistory.push.mock.calls.length).toBe(1);
30
- expect(mockHistory.push.mock.calls[0][0]).toEqual(
31
- "/concepts/12/versions/42"
46
+ const wrapper = render(
47
+ <table>
48
+ <tbody>
49
+ <ConceptRow {...props} />
50
+ </tbody>
51
+ </table>,
52
+ renderOpts
32
53
  );
54
+
55
+ const link = wrapper.getByText("foo");
56
+ expect(link).toHaveAttribute("href", "/concepts/12/versions/42");
33
57
  });
34
58
  });
@@ -8,6 +8,7 @@ const data = {
8
8
  data: [
9
9
  {
10
10
  id: 1,
11
+ business_concept_id: 1,
11
12
  name: "s1",
12
13
  description: "dd",
13
14
  version: "vs",
@@ -8,6 +8,7 @@ const data = {
8
8
  data: [
9
9
  {
10
10
  id: 1,
11
+ business_concept_id: 1,
11
12
  name: "concept",
12
13
  domain: { name: "domain" },
13
14
  status: "published",
@@ -1,19 +1,50 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`<ConceptRow /> matches the latest snapshot 1`] = `
4
- <TableRow
5
- as="tr"
6
- cellAs="td"
7
- key="42"
8
- onClick={[Function]}
9
- >
10
- <TableCell
11
- as="td"
12
- key="0"
13
- />
14
- <TableCell
15
- as="td"
16
- key="1"
17
- />
18
- </TableRow>
4
+ <div>
5
+ <table>
6
+ <tbody>
7
+ <tr
8
+ class=""
9
+ >
10
+ <td
11
+ class=""
12
+ >
13
+ <a
14
+ href="/concepts/12/versions/42"
15
+ >
16
+ foo
17
+ </a>
18
+ </td>
19
+ <td
20
+ class=""
21
+ />
22
+ <td
23
+ class=""
24
+ >
25
+ draft
26
+ </td>
27
+ <td
28
+ class="center aligned"
29
+ >
30
+
31
+ </td>
32
+ <td
33
+ class="center aligned"
34
+ >
35
+
36
+ </td>
37
+ <td
38
+ class="center aligned"
39
+ >
40
+ <time
41
+ datetime="1530084773154"
42
+ >
43
+ 2018-06-27 07:32
44
+ </time>
45
+ </td>
46
+ </tr>
47
+ </tbody>
48
+ </table>
49
+ </div>
19
50
  `;
@@ -96,7 +96,7 @@ exports[`<Concepts /> matches the latest snapshot 1`] = `
96
96
  123 concepts found
97
97
  </div>
98
98
  <table
99
- class="ui selectable sortable table"
99
+ class="ui sortable table"
100
100
  >
101
101
  <thead
102
102
  class=""
@@ -140,7 +140,11 @@ exports[`<Concepts /> matches the latest snapshot 1`] = `
140
140
  <td
141
141
  class=""
142
142
  >
143
- s1
143
+ <a
144
+ href="/concepts/1/versions/1"
145
+ >
146
+ s1
147
+ </a>
144
148
  </td>
145
149
  <td
146
150
  class=""
@@ -72,7 +72,7 @@ exports[`<ConceptsPanel /> matches latest snapshot 1`] = `
72
72
  123 concepts found
73
73
  </div>
74
74
  <table
75
- class="ui selectable sortable table"
75
+ class="ui sortable table"
76
76
  >
77
77
  <thead
78
78
  class=""
@@ -116,7 +116,11 @@ exports[`<ConceptsPanel /> matches latest snapshot 1`] = `
116
116
  <td
117
117
  class=""
118
118
  >
119
- concept
119
+ <a
120
+ href="/concepts/1/versions/1"
121
+ >
122
+ concept
123
+ </a>
120
124
  </td>
121
125
  <td
122
126
  class=""
@@ -3,7 +3,7 @@
3
3
  exports[`<ConceptsTable /> matches the latest snapshot 1`] = `
4
4
  <div>
5
5
  <table
6
- class="ui selectable sortable table"
6
+ class="ui sortable table"
7
7
  >
8
8
  <thead
9
9
  class=""
@@ -4,6 +4,13 @@ import { Icon } from "semantic-ui-react";
4
4
  import { FormattedMessage } from "react-intl";
5
5
  import { createSelector } from "reselect";
6
6
  import Moment from "react-moment";
7
+ import { Link } from "react-router-dom";
8
+ import { linkTo } from "@truedat/core/routes";
9
+
10
+ const ConceptLink = (concept) =>
11
+ concept?.id ? (
12
+ <Link to={linkTo.CONCEPT_VERSION(concept)}>{concept?.name}</Link>
13
+ ) : null;
7
14
 
8
15
  const iconDecorator = (field) =>
9
16
  field > 0 ? <Icon name="check circle" /> : "";
@@ -15,7 +22,13 @@ const dateDecorator = (date) => (
15
22
  );
16
23
 
17
24
  export const defaultConceptColumns = [
18
- { name: "name", sort: { name: "name.raw" }, width: 7 },
25
+ {
26
+ name: "name",
27
+ sort: { name: "name.raw" },
28
+ width: 7,
29
+ fieldDecorator: ConceptLink,
30
+ fieldSelector: _.identity,
31
+ },
19
32
  {
20
33
  name: "domain",
21
34
  sort: { name: "domain.name.sort" },