@truedat/dd 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.
Files changed (38) hide show
  1. package/package.json +6 -6
  2. package/src/components/CatalogViewConfigs.js +62 -57
  3. package/src/components/GrantApprovalRules.js +15 -12
  4. package/src/components/GrantsTable.js +7 -1
  5. package/src/components/PendingStructureNoteRow.js +2 -10
  6. package/src/components/PendingStructureNotesTable.js +1 -1
  7. package/src/components/StructureRow.js +0 -1
  8. package/src/components/StructureSelector.js +5 -1
  9. package/src/components/StructuresGrantRequestView.js +0 -1
  10. package/src/components/StructuresSearchResults.js +3 -0
  11. package/src/components/StructuresTable.js +2 -1
  12. package/src/components/StructuresView.js +4 -9
  13. package/src/components/__tests__/CatalogViewConfigs.spec.js +1 -11
  14. package/src/components/__tests__/GrantApprovalRules.spec.js +4 -17
  15. package/src/components/__tests__/GrantsTable.spec.js +6 -7
  16. package/src/components/__tests__/PendingStructureNoteRow.spec.js +4 -5
  17. package/src/components/__tests__/PendingStructureNotesTable.spec.js +2 -4
  18. package/src/components/__tests__/StructureSelector.spec.js +3 -3
  19. package/src/components/__tests__/StructureStructureForm.spec.js +2 -1
  20. package/src/components/__tests__/StructuresGrantRequestView.spec.js +3 -2
  21. package/src/components/__tests__/StructuresView.spec.js +1 -0
  22. package/src/components/__tests__/__snapshots__/GrantApprovalRules.spec.js.snap +13 -3
  23. package/src/components/__tests__/__snapshots__/GrantsTable.spec.js.snap +17 -41
  24. package/src/components/__tests__/__snapshots__/PendingStructureNoteRow.spec.js.snap +6 -2
  25. package/src/components/__tests__/__snapshots__/PendingStructureNotes.spec.js.snap +13 -5
  26. package/src/components/__tests__/__snapshots__/PendingStructureNotesTable.spec.js.snap +13 -5
  27. package/src/components/__tests__/__snapshots__/StructureRow.spec.js.snap +0 -1
  28. package/src/components/__tests__/__snapshots__/StructureSelector.spec.js.snap +12 -4
  29. package/src/components/__tests__/__snapshots__/StructuresGrantRequestView.spec.js.snap +19 -7
  30. package/src/components/__tests__/__snapshots__/StructuresSearchResults.spec.js.snap +1 -4
  31. package/src/components/__tests__/__snapshots__/StructuresTable.spec.js.snap +3 -12
  32. package/src/selectors/__tests__/__snapshots__/getGrantsColumns.spec.js.snap +0 -10
  33. package/src/selectors/__tests__/getGrantsColumns.spec.js +0 -9
  34. package/src/selectors/getGrantRequestsColumns.js +21 -2
  35. package/src/selectors/getGrantRequestsSearchColumns.js +20 -3
  36. package/src/selectors/getGrantsColumns.js +14 -30
  37. package/src/selectors/structureColumnsSelector.js +13 -2
  38. package/src/selectors/structureNotesColumnsSelector.js +11 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/dd",
3
- "version": "6.16.4",
3
+ "version": "7.0.1",
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.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",
@@ -88,9 +88,9 @@
88
88
  },
89
89
  "dependencies": {
90
90
  "@apollo/client": "^3.7.1",
91
- "@truedat/auth": "6.15.2",
92
- "@truedat/core": "6.15.2",
93
- "@truedat/df": "6.15.2",
91
+ "@truedat/auth": "7.0.1",
92
+ "@truedat/core": "7.0.1",
93
+ "@truedat/df": "7.0.1",
94
94
  "lodash": "^4.17.21",
95
95
  "moment": "^2.29.4",
96
96
  "path-to-regexp": "^1.7.0",
@@ -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": "ecf57a30185b9e353b6e2692702b5599e4425edb"
118
+ "gitHead": "fff3313b142abb69e4d4139e0b6fd85d1af1a898"
119
119
  }
@@ -1,8 +1,9 @@
1
- import PropTypes from "prop-types";
1
+ import _ from "lodash/fp";
2
2
  import React from "react";
3
+ import PropTypes from "prop-types";
3
4
  import { useIntl, FormattedMessage } from "react-intl";
4
5
  import { columnDecoratorComponent } from "@truedat/core/services";
5
- import { Link, useHistory } from "react-router-dom";
6
+ import { Link } from "react-router-dom";
6
7
  import { BUCKET_VIEW_CONFIG_NEW, linkTo } from "@truedat/core/routes";
7
8
  import { useQuery } from "@apollo/client";
8
9
  import { Button, Segment, Table } from "semantic-ui-react";
@@ -11,17 +12,30 @@ import { connect } from "react-redux";
11
12
  import { CATALOG_VIEW_CONFIGS_QUERY } from "../api/queries";
12
13
  import { deleteCatalogViewConfig as deleteCatalogViewConfigRoutine } from "../routines";
13
14
 
15
+ const ConfigLink = (config) =>
16
+ config?.id ? (
17
+ <Link
18
+ to={linkTo.BUCKET_VIEW_CONFIG_EDIT({ id: config.id })}
19
+ title={config?.fieldType}
20
+ >
21
+ {config?.fieldType}
22
+ </Link>
23
+ ) : null;
24
+
14
25
  export const CatalogViewConfigs = ({
15
26
  deleteCatalogViewConfig,
16
27
  configs,
17
28
  loading,
18
29
  }) => {
19
30
  const { formatMessage } = useIntl();
20
- const history = useHistory();
21
31
 
22
32
  const columns = [
23
- { name: "Field type", fieldSelector: "fieldType" },
24
- { name: "Field name", fieldSelector: "fieldName" },
33
+ {
34
+ name: "fieldType",
35
+ fieldDecorator: ConfigLink,
36
+ fieldSelector: _.identity,
37
+ },
38
+ { name: "fieldName", fieldSelector: "fieldName" },
25
39
  ];
26
40
 
27
41
  return loading ? null : (
@@ -37,65 +51,56 @@ export const CatalogViewConfigs = ({
37
51
  <Table>
38
52
  <Table.Header>
39
53
  <Table.Row>
40
- {columns.map((column, i) => {
41
- return (
42
- <Table.HeaderCell
43
- key={i}
44
- width={column.width}
45
- content={formatMessage({
46
- id: `bucketViewConfig.${column.fieldSelector}`,
47
- })}
48
- />
49
- );
50
- })}
54
+ {columns.map((column, i) => (
55
+ <Table.HeaderCell
56
+ key={i}
57
+ width={column.width}
58
+ content={formatMessage({
59
+ id: `bucketViewConfig.${column.header || column.name}`,
60
+ })}
61
+ />
62
+ ))}
51
63
  <Table.HeaderCell textAlign="center">
52
64
  <FormattedMessage id="actions.delete" />
53
65
  </Table.HeaderCell>
54
66
  </Table.Row>
55
67
  </Table.Header>
56
68
  <Table.Body>
57
- {configs.map((config, rowNumber) => {
58
- return (
59
- <Table.Row style={{ cursor: "pointer" }} key={rowNumber}>
60
- {columns.map((column, columnNumber) => (
61
- <Table.Cell
62
- key={`${rowNumber}_${columnNumber}`}
63
- content={columnDecoratorComponent(column)(config)}
64
- onClick={() =>
65
- history.push(
66
- linkTo.BUCKET_VIEW_CONFIG_EDIT({ id: config.id })
67
- )
68
- }
69
- />
70
- ))}
69
+ {configs.map((config, rowNumber) => (
70
+ <Table.Row key={rowNumber}>
71
+ {columns.map((column, columnNumber) => (
71
72
  <Table.Cell
72
- style={{ cursor: "default" }}
73
- collapsing
74
- width="1"
75
- textAlign="center"
76
- >
77
- <ConfirmModal
78
- icon="trash"
79
- trigger={
80
- <Button
81
- aria-label="delete"
82
- basic
83
- icon="trash"
84
- color="red"
85
- />
86
- }
87
- header={
88
- <FormattedMessage id="relations.actions.data_field.delete.confirmation.header" />
89
- }
90
- content={
91
- <FormattedMessage id="relations.actions.data_field.delete.confirmation.content" />
92
- }
93
- onConfirm={() => deleteCatalogViewConfig({ id: config.id })}
94
- />
95
- </Table.Cell>
96
- </Table.Row>
97
- );
98
- })}
73
+ key={`${rowNumber}_${columnNumber}`}
74
+ content={columnDecoratorComponent(column)(config)}
75
+ />
76
+ ))}
77
+ <Table.Cell
78
+ style={{ cursor: "default" }}
79
+ collapsing
80
+ width="1"
81
+ textAlign="center"
82
+ >
83
+ <ConfirmModal
84
+ icon="trash"
85
+ trigger={
86
+ <Button
87
+ aria-label="delete"
88
+ basic
89
+ icon="trash"
90
+ color="red"
91
+ />
92
+ }
93
+ header={
94
+ <FormattedMessage id="relations.actions.data_field.delete.confirmation.header" />
95
+ }
96
+ content={
97
+ <FormattedMessage id="relations.actions.data_field.delete.confirmation.content" />
98
+ }
99
+ onConfirm={() => deleteCatalogViewConfig({ id: config.id })}
100
+ />
101
+ </Table.Cell>
102
+ </Table.Row>
103
+ ))}
99
104
  </Table.Body>
100
105
  </Table>
101
106
  </Segment>
@@ -10,17 +10,27 @@ import {
10
10
  Segment,
11
11
  Table,
12
12
  } from "semantic-ui-react";
13
- import { Link, useHistory } from "react-router-dom";
13
+ import { Link } from "react-router-dom";
14
14
  import { GRANT_APPROVAL_RULE_NEW, linkTo } from "@truedat/core/routes";
15
15
  import { columnDecoratorComponent } from "@truedat/core/services";
16
16
  import { GRANT_APPROVAL_RULES_QUERY } from "../api/queries";
17
17
 
18
+ const ApprovalRuleLink = (rule) =>
19
+ rule?.id ? (
20
+ <Link to={linkTo.GRANT_APPROVAL_RULE(rule)} title={rule?.name}>
21
+ {rule?.name}
22
+ </Link>
23
+ ) : null;
24
+
18
25
  export default function GrantApprovalRules() {
19
26
  const { formatMessage } = useIntl();
20
- const history = useHistory();
21
27
 
22
28
  const columns = [
23
- { name: "name" },
29
+ {
30
+ name: "name",
31
+ fieldDecorator: ApprovalRuleLink,
32
+ fieldSelector: _.identity,
33
+ },
24
34
  { name: "action" },
25
35
  { name: "role" },
26
36
  {
@@ -63,7 +73,7 @@ export default function GrantApprovalRules() {
63
73
  </Segment>
64
74
 
65
75
  {!_.isEmpty(grantApprovalRules) && !loading ? (
66
- <Table selectable>
76
+ <Table>
67
77
  <Table.Header>
68
78
  <Table.Row>
69
79
  {columns.map((column, i) => {
@@ -82,14 +92,7 @@ export default function GrantApprovalRules() {
82
92
  <Table.Body>
83
93
  {grantApprovalRules.map((grantApprovalRule, i) => {
84
94
  return (
85
- <Table.Row
86
- key={i}
87
- onClick={() =>
88
- history.push(
89
- linkTo.GRANT_APPROVAL_RULE({ id: grantApprovalRule.id })
90
- )
91
- }
92
- >
95
+ <Table.Row key={i}>
93
96
  {columns.map((column, key) => (
94
97
  <Table.Cell
95
98
  key={key}
@@ -2,10 +2,12 @@ import _ from "lodash/fp";
2
2
  import React, { useState } from "react";
3
3
  import PropTypes from "prop-types";
4
4
  import { useIntl } from "react-intl";
5
+ import { useHistory } from "react-router-dom";
5
6
  import { Table, Header, Icon } from "semantic-ui-react";
6
7
  import { connect } from "react-redux";
7
8
  import { columnDecoratorComponent } from "@truedat/core/services";
8
9
  import { getSortInfo, sortColumn } from "@truedat/core/services/sort";
10
+ import { linkTo } from "@truedat/core/routes";
9
11
  import { getGrantsTableColumns } from "../selectors";
10
12
  import { sortGrants } from "../routines";
11
13
 
@@ -17,6 +19,7 @@ export const GrantsTable = ({
17
19
  grantsSorting,
18
20
  }) => {
19
21
  const { formatMessage } = useIntl();
22
+ const history = useHistory();
20
23
  const filteredColumns = _.filter((c) => _.any(_.prop(c.name))(grants))(
21
24
  columns
22
25
  );
@@ -68,7 +71,10 @@ export const GrantsTable = ({
68
71
  </Table.Header>
69
72
  <Table.Body>
70
73
  {grants.map((grant, i) => (
71
- <Table.Row key={i}>
74
+ <Table.Row
75
+ key={i}
76
+ onClick={() => history.push(linkTo.GRANT(grant))}
77
+ >
72
78
  {columns &&
73
79
  columns.map((column, key) => (
74
80
  <Table.Cell
@@ -2,31 +2,23 @@ import _ from "lodash/fp";
2
2
  import React from "react";
3
3
  import PropTypes from "prop-types";
4
4
  import { Table } from "semantic-ui-react";
5
- import { useHistory } from "react-router-dom";
6
5
  import { columnDecorator } from "@truedat/core/services";
7
- import { linkTo } from "@truedat/core/routes";
8
6
 
9
- const PendingStructureNoteRow = ({ structure, columns }) => {
10
- const history = useHistory();
11
- return _.isEmpty(columns) || _.isEmpty(structure) ? null : (
7
+ const PendingStructureNoteRow = ({ structure, columns }) =>
8
+ _.isEmpty(columns) || _.isEmpty(structure) ? null : (
12
9
  <Table.Row key={structure.id}>
13
10
  {columns.map((column, i) => (
14
11
  <Table.Cell
15
12
  key={i}
16
13
  {...(i == 0 && {
17
- title: columnDecorator(column)(structure),
18
14
  className: "structure-cell-overflow",
19
15
  })}
20
16
  textAlign={column.textAlign}
21
17
  content={columnDecorator(column)(structure)}
22
- onClick={() =>
23
- history.push(linkTo.STRUCTURE_NOTES({ id: structure.id }))
24
- }
25
18
  />
26
19
  ))}
27
20
  </Table.Row>
28
21
  );
29
- };
30
22
 
31
23
  PendingStructureNoteRow.propTypes = {
32
24
  structure: PropTypes.object.isRequired,
@@ -21,7 +21,7 @@ const PendingStructureNotesTable = ({ columns }) => {
21
21
  </Header.Content>
22
22
  </Header>
23
23
  ) : (
24
- <Table selectable sortable>
24
+ <Table sortable>
25
25
  <Table.Header>
26
26
  <Table.Row>
27
27
  {columns &&
@@ -20,7 +20,6 @@ export const StructureRow = ({
20
20
  <Table.Cell
21
21
  key={i}
22
22
  {...(i == 0 && {
23
- title: columnDecorator(column)(structure),
24
23
  className: "structure-cell-overflow",
25
24
  })}
26
25
  textAlign={column.textAlign}
@@ -15,12 +15,13 @@ import {
15
15
  } from "../hooks/useStructures";
16
16
  import StructuresSearchResults from "./StructuresSearchResults";
17
17
 
18
- export function StructureSelectorContent({
18
+ function StructureSelectorContent({
19
19
  overwriteColumns,
20
20
  selectedStructure: structure,
21
21
  onSelect,
22
22
  links,
23
23
  placeToTop,
24
+ selectable = true,
24
25
  }) {
25
26
  const [selectedStructure, setSelectedStructure] = useState(null);
26
27
  const { searchData, loading } = useSearchContext();
@@ -48,6 +49,7 @@ export function StructureSelectorContent({
48
49
  selectedStructure={selectedStructure}
49
50
  links={links}
50
51
  placeToTop={placeToTop}
52
+ selectable={selectable}
51
53
  />
52
54
  </Segment>
53
55
  );
@@ -59,6 +61,7 @@ StructureSelectorContent.propTypes = {
59
61
  selectedStructure: PropTypes.object,
60
62
  links: PropTypes.array,
61
63
  placeToTop: PropTypes.bool,
64
+ selectable: PropTypes.bool,
62
65
  };
63
66
 
64
67
  export const StructureSelector = (props) => {
@@ -107,6 +110,7 @@ StructureSelector.propTypes = {
107
110
  overwriteColumns: PropTypes.array,
108
111
  links: PropTypes.array,
109
112
  placeToTop: PropTypes.bool,
113
+ selectable: PropTypes.bool,
110
114
  };
111
115
 
112
116
  const mapStateToProps = (state) => ({
@@ -95,7 +95,6 @@ export function StructuresGrantRequestViewContent() {
95
95
  structures={structures}
96
96
  loading={loading}
97
97
  grantable
98
- onSelect={({ id }) => history.push(linkTo.STRUCTURE({ id }))}
99
98
  />
100
99
  </div>
101
100
  </div>
@@ -18,6 +18,7 @@ export const StructuresSearchResults = ({
18
18
  loading,
19
19
  links,
20
20
  placeToTop,
21
+ selectable,
21
22
  }) => (
22
23
  <Dimmer.Dimmable dimmed={loading} className="structure-table-overflow">
23
24
  <Dimmer active={loading} inverted>
@@ -35,6 +36,7 @@ export const StructuresSearchResults = ({
35
36
  onStructureSelected={onSelect}
36
37
  links={links}
37
38
  placeToTop={placeToTop}
39
+ selectable={selectable}
38
40
  />
39
41
  <StructuresPagination size={size} />
40
42
  </>
@@ -64,6 +66,7 @@ StructuresSearchResults.propTypes = {
64
66
  loading: PropTypes.bool,
65
67
  links: PropTypes.array,
66
68
  placeToTop: PropTypes.bool,
69
+ selectable: PropTypes.bool,
67
70
  };
68
71
 
69
72
  export default StructuresSearchResults;
@@ -25,6 +25,7 @@ export const StructuresTable = ({
25
25
  size,
26
26
  links = [],
27
27
  placeToTop = true,
28
+ selectable = false,
28
29
  }) => {
29
30
  const {
30
31
  searchData,
@@ -87,8 +88,8 @@ export const StructuresTable = ({
87
88
  );
88
89
  return (
89
90
  <Table
90
- selectable
91
91
  sortable
92
+ selectable={selectable}
92
93
  size={size}
93
94
  headerRow={headerRow}
94
95
  renderBodyRow={renderBodyRow}
@@ -2,10 +2,9 @@ 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 { useHistory, useRouteMatch } from "react-router-dom";
5
+ import { useRouteMatch } from "react-router-dom";
6
6
  import { Header, Icon, Segment, Divider } from "semantic-ui-react";
7
7
  import { FormattedMessage, useIntl } from "react-intl";
8
- import { linkTo } from "@truedat/core/routes";
9
8
  import { BUCKETS_VIEW } from "@truedat/core/routes";
10
9
  import SearchWidget from "@truedat/core/search/SearchWidget";
11
10
  import {
@@ -70,22 +69,18 @@ export const StructuresViewContent = ({ embedded, customView }) => {
70
69
  _.flow(_.values, _.some(_.negate(_.isEmpty)))(allActiveFilters);
71
70
  const hasFilterApplied =
72
71
  !_.isEmpty(query) || selectedFilters(allActiveFilters, toggleDateFilter);
73
- const history = useHistory();
72
+
74
73
  return (
75
74
  <>
76
75
  {!customView ? (
77
76
  <>
78
77
  <StructuresOptions hasFilterApplied={hasFilterApplied} {...actions} />
79
- <SearchWidget dateFilter />
78
+ <SearchWidget dateFilter searchField="last_change_at" />
80
79
  </>
81
80
  ) : null}
82
81
 
83
82
  {hasFilterApplied || embedded ? (
84
- <StructuresSearchResults
85
- structures={structures}
86
- loading={loading}
87
- onSelect={({ id }) => history.push(linkTo.STRUCTURE({ id }))}
88
- />
83
+ <StructuresSearchResults structures={structures} loading={loading} />
89
84
  ) : customView ? (
90
85
  <CatalogCustomViewCards />
91
86
  ) : (
@@ -24,15 +24,6 @@ jest.mock("@truedat/core/hooks", () => ({
24
24
  useAuthorized: jest.fn(() => true),
25
25
  }));
26
26
 
27
- const mockHistoryPush = jest.fn();
28
-
29
- jest.mock("react-router-dom", () => ({
30
- ...jest.requireActual("react-router-dom"),
31
- useHistory: () => ({
32
- push: mockHistoryPush,
33
- }),
34
- }));
35
-
36
27
  describe("<CatalogViewConfigsLoader />", () => {
37
28
  it("loads all catalog view configs and shows them in a table", async () => {
38
29
  const { findByRole } = render(<CatalogViewConfigsLoader />, renderOpts);
@@ -43,8 +34,7 @@ describe("<CatalogViewConfigsLoader />", () => {
43
34
  const fieldName = within(row).getByText(/someFieldName/);
44
35
  expect(fieldType).toBeInTheDocument();
45
36
  expect(fieldName).toBeInTheDocument();
46
- userEvent.click(fieldName);
47
- expect(mockHistoryPush).toHaveBeenCalledWith("/bucketViewConfigs/123/edit");
37
+ expect(fieldType).toHaveAttribute("href", "/bucketViewConfigs/123/edit");
48
38
  });
49
39
 
50
40
  it("deletes a catalog view config", async () => {
@@ -1,21 +1,10 @@
1
1
  import React from "react";
2
2
  import { render } from "@truedat/test/render";
3
- import userEvent from "@testing-library/user-event";
4
3
  import { waitFor } from "@testing-library/react";
5
- import { linkTo } from "@truedat/core/routes";
6
4
  import GrantApprovalRules from "../GrantApprovalRules";
7
5
  import { GRANT_APPROVAL_RULES_QUERY } from "../../api/queries";
8
6
  import en from "../../messages/en";
9
7
 
10
- const mockHistory = {
11
- push: jest.fn(),
12
- };
13
-
14
- jest.mock("react-router-dom", () => ({
15
- ...jest.requireActual("react-router-dom"),
16
- useHistory: () => mockHistory,
17
- }));
18
-
19
8
  const grantApprovalRules = {
20
9
  grantApprovalRules: [
21
10
  {
@@ -87,8 +76,8 @@ describe("<GrantApprovalRules />", () => {
87
76
  expect(container).toMatchSnapshot();
88
77
  });
89
78
 
90
- it("navigates to ApprovalRule detail on click", async () => {
91
- const { queryByText } = render(
79
+ it("renders ApprovalRule name as Link", async () => {
80
+ const { queryByText, getByText } = render(
92
81
  <GrantApprovalRules />,
93
82
  renderOpts(grantApprovalRules)
94
83
  );
@@ -97,9 +86,7 @@ describe("<GrantApprovalRules />", () => {
97
86
  expect(queryByText(/loading/i)).not.toBeInTheDocument()
98
87
  );
99
88
 
100
- userEvent.click(queryByText(/rule_name/i));
101
- expect(mockHistory.push).toHaveBeenCalledWith(
102
- linkTo.GRANT_APPROVAL_RULE({ id: 123 })
103
- );
89
+ const link = getByText("rule_name");
90
+ expect(link).toHaveAttribute("href", "/grantApproveRules/123");
104
91
  });
105
92
  });
@@ -100,10 +100,9 @@ describe("<GrantsTable />", () => {
100
100
  .find("TableHeaderCell");
101
101
 
102
102
  expect(tableHeaderCells.at(0).props().sorted).toEqual(null);
103
- expect(tableHeaderCells.at(1).props().sorted).toEqual(null);
104
- expect(tableHeaderCells.at(2).props().sorted).toEqual("ascending");
103
+ expect(tableHeaderCells.at(1).props().sorted).toEqual("ascending");
104
+ expect(tableHeaderCells.at(2).props().sorted).toEqual(null);
105
105
  expect(tableHeaderCells.at(3).props().sorted).toEqual(null);
106
- expect(tableHeaderCells.at(4).props().sorted).toEqual(null);
107
106
  });
108
107
 
109
108
  it("handles sort when column header is clicked", () => {
@@ -114,7 +113,7 @@ describe("<GrantsTable />", () => {
114
113
  .find("TableRow")
115
114
  .dive()
116
115
  .find("TableHeaderCell")
117
- .at(1)
116
+ .at(0)
118
117
  .simulate("click");
119
118
 
120
119
  expect(
@@ -123,7 +122,7 @@ describe("<GrantsTable />", () => {
123
122
  .find("TableRow")
124
123
  .dive()
125
124
  .find("TableHeaderCell")
126
- .at(1)
125
+ .at(0)
127
126
  .props().sorted
128
127
  ).toEqual("ascending");
129
128
 
@@ -132,7 +131,7 @@ describe("<GrantsTable />", () => {
132
131
  .find("TableRow")
133
132
  .dive()
134
133
  .find("TableHeaderCell")
135
- .at(1)
134
+ .at(0)
136
135
  .simulate("click");
137
136
  expect(
138
137
  wrapper
@@ -140,7 +139,7 @@ describe("<GrantsTable />", () => {
140
139
  .find("TableRow")
141
140
  .dive()
142
141
  .find("TableHeaderCell")
143
- .at(1)
142
+ .at(0)
144
143
  .props().sorted
145
144
  ).toEqual("descending");
146
145
  });
@@ -18,7 +18,7 @@ const columns = getStructureNotesColumnsSelector({});
18
18
  const structure = {
19
19
  id: "7207",
20
20
  note: { status: "draft" },
21
- name: "bar",
21
+ name: "bar_name",
22
22
  path: ["bar rute"],
23
23
  domains: [{ name: "bar domain" }, { name: "baz domain" }],
24
24
  system: { name: "bar system" },
@@ -63,7 +63,7 @@ describe("<PendingStructureNoteRow />", () => {
63
63
  expect(container).toMatchSnapshot();
64
64
  });
65
65
 
66
- it("navigates to the job route when row is clicked", () => {
66
+ it("renders structure note name as link", () => {
67
67
  const props = { columns, structure };
68
68
  const { getByText } = render(
69
69
  <table>
@@ -73,9 +73,8 @@ describe("<PendingStructureNoteRow />", () => {
73
73
  </table>,
74
74
  renderOpts
75
75
  );
76
- userEvent.click(getByText(/bar system/));
77
- expect(mockHistory.push.mock.calls.length).toBe(1);
78
- expect(mockHistory.push.mock.calls[0][0]).toBe("/structures/7207/notes");
76
+ const link = getByText("bar_name");
77
+ expect(link).toHaveAttribute("href", "/structures/7207/notes");
79
78
  });
80
79
 
81
80
  it("renders empty table if structure is empty", () => {
@@ -2,6 +2,7 @@ import React from "react";
2
2
  import { waitFor } from "@testing-library/react";
3
3
  import { render } from "@truedat/test/render";
4
4
  import SearchContext from "@truedat/core/search/SearchContext";
5
+ import { getColumns } from "../../selectors/structureNotesColumnsSelector";
5
6
  import PendingStructureNotesTable from "../PendingStructureNotesTable";
6
7
 
7
8
  const structures = {
@@ -53,10 +54,7 @@ const renderOpts = {
53
54
  };
54
55
 
55
56
  describe("<PendingStructureNotesTable />", () => {
56
- const columns = [
57
- { name: "foo", sort: { name: "name.raw" } },
58
- { name: "bar", sort: { name: "bar.raw" } },
59
- ];
57
+ const columns = getColumns;
60
58
  const props = { columns };
61
59
 
62
60
  it("matches the latest snapshot", async () => {
@@ -6,8 +6,8 @@ import { StructureSelector } from "../StructureSelector";
6
6
  const data = {
7
7
  _actions: { bulkUpdate: {} },
8
8
  data: [
9
- { id: 1, name: "1", updated_at: "2021-12-10T12:22:37.797978Z" },
10
- { id: 2, name: "2", updated_at: "2021-12-10T12:22:37.797978Z" },
9
+ { id: 1, name: "1", last_change_at: "2021-12-10T12:22:37.797978Z" },
10
+ { id: 2, name: "2", last_change_at: "2021-12-10T12:22:37.797978Z" },
11
11
  ],
12
12
  headers: { "x-total-count": 2 },
13
13
  };
@@ -56,7 +56,7 @@ const messages = {
56
56
  "structures.loading.header": "Header",
57
57
  "structure.type.undefined.text": "text",
58
58
  "structure.relation.relation_type_name": "relation",
59
- "structure.updated_at": "Updated at",
59
+ "structure.last_change_at": "Updated at",
60
60
  "structure.type": "type",
61
61
  },
62
62
  };