@truedat/dd 4.53.4 → 4.53.6

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,10 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.53.5] 2022-10-07
4
+
5
+ ### Changed
6
+
7
+ - [TD-5167] "Remove Grant" action is now only displayed on the grant's data
8
+ structure, not on it's descendents
9
+
3
10
  ## [4.53.4] 2022-10-07
4
11
 
5
12
  ### Fixed
6
13
 
7
- - [TD-5098] Missing value modifier parameter translations, put key in Fragment
14
+ - [TD-5098] Missing value modifier parameter translations
8
15
 
9
16
  ## [4.53.3] 2022-10-07
10
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/dd",
3
- "version": "4.53.4",
3
+ "version": "4.53.6",
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.4",
35
35
  "@testing-library/react": "^12.0.0",
36
36
  "@testing-library/user-event": "^13.2.1",
37
- "@truedat/test": "4.53.4",
37
+ "@truedat/test": "4.53.6",
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.6.4",
91
- "@truedat/auth": "4.53.4",
92
- "@truedat/core": "4.53.4",
93
- "@truedat/df": "4.53.4",
91
+ "@truedat/auth": "4.53.6",
92
+ "@truedat/core": "4.53.6",
93
+ "@truedat/df": "4.53.6",
94
94
  "lodash": "^4.17.21",
95
95
  "path-to-regexp": "^1.7.0",
96
96
  "prop-types": "^15.8.1",
@@ -112,5 +112,5 @@
112
112
  "react-dom": ">= 16.8.6 < 17",
113
113
  "semantic-ui-react": ">= 0.88.2 < 2.1"
114
114
  },
115
- "gitHead": "b21b4051e9370c3a28d4f0e43a53e34d3ccd59d5"
115
+ "gitHead": "ff29c0e4f51c049077545c425533dd45a704e440"
116
116
  }
@@ -8,7 +8,7 @@ import { columnDecorator } from "@truedat/core/services";
8
8
  import { getGrantsColumns } from "../selectors";
9
9
  import GrantRemoval from "./GrantRemoval";
10
10
 
11
- export const RemovalButtonDecorator = (grant) => (
11
+ export const RemovalButton = ({ grant }) => (
12
12
  <GrantRemoval grant={grant}>
13
13
  {grant.pending_removal ? (
14
14
  <Button size="mini" color="olive" icon="undo" />
@@ -18,68 +18,76 @@ export const RemovalButtonDecorator = (grant) => (
18
18
  </GrantRemoval>
19
19
  );
20
20
 
21
- export const StructureGrants = ({ columns, grants, userPermissions }) => {
22
- const { formatMessage } = useIntl();
23
- const canUpdateRemoval = _.getOr(
24
- false,
25
- "update_grant_removal"
26
- )(userPermissions);
21
+ RemovalButton.propTypes = {
22
+ grant: PropTypes.object,
23
+ };
27
24
 
28
- const columnsWithActions = [
29
- ...columns,
30
- ...(canUpdateRemoval
31
- ? [
32
- {
33
- fieldSelector: _.identity,
34
- fieldDecorator: RemovalButtonDecorator,
35
- },
36
- ]
37
- : []),
38
- ];
25
+ const matchesStructure = ({ id }) => _.pathEq("data_structure.id", id);
26
+
27
+ export const StructureGrants = ({
28
+ columns,
29
+ grants,
30
+ structure,
31
+ userPermissions,
32
+ }) => {
33
+ const { formatMessage } = useIntl();
34
+ const canUpdateRemoval =
35
+ userPermissions?.update_grant_removal &&
36
+ _.any(matchesStructure(structure))(grants);
39
37
 
40
- return (
41
- grants && (
42
- <Table basic="very">
43
- <Table.Header>
44
- <Table.Row>
45
- {columns.map((column, i) => (
46
- <Table.HeaderCell
47
- key={i}
38
+ return grants ? (
39
+ <Table basic="very">
40
+ <Table.Header>
41
+ <Table.Row>
42
+ {columns.map((column, i) => (
43
+ <Table.HeaderCell
44
+ key={i}
45
+ textAlign={column.textAlign}
46
+ content={formatMessage({
47
+ id: `grant.header.${column.name}`,
48
+ defaultMessage: column.name,
49
+ })}
50
+ />
51
+ ))}
52
+ {canUpdateRemoval ? <Table.HeaderCell /> : null}
53
+ </Table.Row>
54
+ </Table.Header>
55
+ <Table.Body>
56
+ {grants.map((grant, i) => (
57
+ <Table.Row key={i}>
58
+ {columns.map((column, key) => (
59
+ <Table.Cell
60
+ key={key}
48
61
  textAlign={column.textAlign}
49
- content={formatMessage({
50
- id: `grant.header.${column.name}`,
51
- defaultMessage: column.name,
52
- })}
62
+ content={columnDecorator(column)(grant)}
53
63
  />
54
64
  ))}
65
+ {canUpdateRemoval ? (
66
+ <Table.Cell
67
+ content={
68
+ matchesStructure(structure)(grant) ? (
69
+ <RemovalButton grant={grant} />
70
+ ) : null
71
+ }
72
+ />
73
+ ) : null}
55
74
  </Table.Row>
56
- </Table.Header>
57
- <Table.Body>
58
- {grants.map((grant, i) => (
59
- <Table.Row key={i}>
60
- {columnsWithActions.map((column, key) => (
61
- <Table.Cell
62
- key={key}
63
- textAlign={column.textAlign}
64
- content={columnDecorator(column)(grant)}
65
- />
66
- ))}
67
- </Table.Row>
68
- ))}
69
- </Table.Body>
70
- </Table>
71
- )
72
- );
75
+ ))}
76
+ </Table.Body>
77
+ </Table>
78
+ ) : null;
73
79
  };
74
80
 
75
81
  StructureGrants.propTypes = {
76
82
  grants: PropTypes.array,
77
83
  columns: PropTypes.array,
84
+ structure: PropTypes.object,
78
85
  userPermissions: PropTypes.object,
79
86
  };
80
87
 
81
88
  const mapStateToProps = (state) => ({
82
- grants: state.structure.grants,
89
+ grants: state.structure?.grants,
90
+ structure: state.structure,
83
91
  columns: getGrantsColumns(state),
84
92
  userPermissions: state.userPermissions,
85
93
  });
@@ -1,53 +1,14 @@
1
- import _ from "lodash/fp";
2
1
  import React from "react";
3
2
  import { shallow } from "enzyme";
4
3
  import { intl } from "@truedat/test/intl-stub";
5
4
  import { GrantsTable } from "../GrantsTable";
6
- import {
7
- userDecorator,
8
- GrantTableStructureDecorator,
9
- StartDateDecorator,
10
- EndDateDecorator,
11
- GenericObjectDecorator,
12
- } from "../../selectors/getGrantsColumns";
5
+ import { defaultGrantsTableColumns } from "../../selectors/getGrantsColumns";
13
6
 
14
7
  // workaround for enzyme issue with React.useContext
15
8
  // see https://github.com/airbnb/enzyme/issues/2176#issuecomment-532361526
16
9
  jest.spyOn(React, "useContext").mockImplementation(() => intl);
17
10
 
18
11
  describe("<GrantsTable />", () => {
19
- const defaultGrantsTableColumns = [
20
- {
21
- name: "user",
22
- sort: { name: "user.user_name.raw" },
23
- fieldSelector: _.pick(["user"]),
24
- fieldDecorator: userDecorator,
25
- },
26
- {
27
- name: "data_structure_version",
28
- sort: { name: "data_structure_version.name.raw" },
29
- fieldSelector: _.pick(["data_structure", "data_structure_version"]),
30
- fieldDecorator: GrantTableStructureDecorator,
31
- },
32
- {
33
- name: "start_date",
34
- sort: { name: "start_date" },
35
- fieldSelector: _.pick(["start_date"]),
36
- fieldDecorator: StartDateDecorator,
37
- },
38
- {
39
- name: "end_date",
40
- sort: { name: "end_date" },
41
- fieldSelector: _.pick(["end_date"]),
42
- fieldDecorator: EndDateDecorator,
43
- },
44
- {
45
- name: "metadata",
46
- fieldSelector: _.pick(["data_structure_version.metadata"]),
47
- fieldDecorator: GenericObjectDecorator,
48
- },
49
- ];
50
-
51
12
  const grants = [
52
13
  {
53
14
  data_structure_version: {
@@ -32,11 +32,14 @@ describe("<StructureGrants />", () => {
32
32
  fieldSelector: _.pick(["foo"]),
33
33
  },
34
34
  ];
35
+
36
+ const structure = { id: 99, external_id: "foo_strucutre" };
37
+
35
38
  const grants = [
36
39
  {
37
40
  id: 1,
38
41
  user: { id: 1, full_name: "foo user" },
39
- data_structure: { name: "foo structure" },
42
+ data_structure: structure,
40
43
  end_date: "2021/08/02",
41
44
  },
42
45
  {
@@ -46,20 +49,13 @@ describe("<StructureGrants />", () => {
46
49
  end_date: "2021/09/02",
47
50
  },
48
51
  ];
49
- const props = { grants, columns };
50
52
 
51
- const messages = {
52
- en: {
53
- "grant.header.user": "User",
54
- "grant.header.data_structure": "Structure",
55
- "grant.header.end_date": "Date",
56
- },
57
- };
53
+ const userPermissions = { update_grant_removal: {} };
54
+
55
+ const props = { grants, columns, structure, userPermissions };
58
56
 
59
57
  it("matches the latest snapshot", () => {
60
- const { container } = render(<StructureGrants {...props} />, {
61
- messages,
62
- });
58
+ const { container } = render(<StructureGrants {...props} />);
63
59
  expect(container).toMatchSnapshot();
64
60
  });
65
61
  });
@@ -25,7 +25,7 @@ exports[`<GrantsTable /> matches the latest snapshot 1`] = `
25
25
  <TableHeaderCell
26
26
  as="th"
27
27
  className=""
28
- content="grant.header.data_structure_version"
28
+ content="grant.header.data_structure"
29
29
  key="1"
30
30
  onClick={[Function]}
31
31
  sorted="ascending"
@@ -14,7 +14,7 @@ exports[`<StructureGrants /> matches the latest snapshot 1`] = `
14
14
  <th
15
15
  class=""
16
16
  >
17
- User
17
+ Account
18
18
  </th>
19
19
  <th
20
20
  class=""
@@ -24,13 +24,16 @@ exports[`<StructureGrants /> matches the latest snapshot 1`] = `
24
24
  <th
25
25
  class=""
26
26
  >
27
- Date
27
+ Expires
28
28
  </th>
29
29
  <th
30
30
  class=""
31
31
  >
32
32
  foo
33
33
  </th>
34
+ <th
35
+ class=""
36
+ />
34
37
  </tr>
35
38
  </thead>
36
39
  <tbody
@@ -49,9 +52,7 @@ exports[`<StructureGrants /> matches the latest snapshot 1`] = `
49
52
  <td
50
53
  class=""
51
54
  >
52
- <p>
53
- foo structure
54
- </p>
55
+ <p />
55
56
  </td>
56
57
  <td
57
58
  class=""
@@ -65,6 +66,18 @@ exports[`<StructureGrants /> matches the latest snapshot 1`] = `
65
66
  >
66
67
  foo
67
68
  </td>
69
+ <td
70
+ class=""
71
+ >
72
+ <button
73
+ class="ui red mini icon button"
74
+ >
75
+ <i
76
+ aria-hidden="true"
77
+ class="delete icon"
78
+ />
79
+ </button>
80
+ </td>
68
81
  </tr>
69
82
  <tr
70
83
  class=""
@@ -95,6 +108,9 @@ exports[`<StructureGrants /> matches the latest snapshot 1`] = `
95
108
  >
96
109
  foo
97
110
  </td>
111
+ <td
112
+ class=""
113
+ />
98
114
  </tr>
99
115
  </tbody>
100
116
  </table>
@@ -51,7 +51,7 @@ export default {
51
51
  "grant.cell.end_date.pending_removal": "Grant pending removal",
52
52
  "grant.cell.end_date.same_user": "It's you",
53
53
  "grant.header.user": "Account",
54
- "grant.header.data_structure_version": "Structure",
54
+ "grant.header.data_structure": "Structure",
55
55
  "grant.header.end_date": "Expires",
56
56
  "grant.header.start_date": "Access granted",
57
57
  "grant.updated_at": "Last changed",
@@ -54,7 +54,7 @@ export default {
54
54
  "grant.cell.end_date.null": "Sin fecha de expiración",
55
55
  "grant.cell.end_date.pending_removal": "Solicitada expiración del acceso",
56
56
  "grant.cell.end_date.same_user": "Eres tú",
57
- "grant.header.data_structure_version": "Estructura",
57
+ "grant.header.data_structure": "Estructura",
58
58
  "grant.header.end_date": "Expira",
59
59
  "grant.header.start_date": "Acceso desde",
60
60
  "grant.header.user": "Cuenta",
@@ -201,7 +201,7 @@ export const defaultGrantsTableColumns = [
201
201
  fieldDecorator: userDecorator,
202
202
  },
203
203
  {
204
- name: "data_structure_version",
204
+ name: "data_structure",
205
205
  sort: { name: "data_structure_version.name.raw" },
206
206
  fieldSelector: _.pick(["data_structure", "data_structure_version"]),
207
207
  fieldDecorator: GrantTableStructureDecorator,