@truedat/dd 4.58.0 → 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.
Files changed (26) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/package.json +7 -6
  3. package/src/components/Grant.js +225 -0
  4. package/src/components/GrantApprovalRuleConditions.js +1 -1
  5. package/src/components/GrantCrumbs.js +24 -0
  6. package/src/components/GrantRemoval.js +14 -5
  7. package/src/components/GrantRoutes.js +108 -100
  8. package/src/components/__tests__/Grant.spec.js +81 -0
  9. package/src/components/__tests__/GrantApprovalRuleConditions.spec.js +0 -1
  10. package/src/components/__tests__/GrantCrumbs.spec.js +10 -0
  11. package/src/components/__tests__/GrantRemoval.spec.js +25 -4
  12. package/src/components/__tests__/GrantsTable.spec.js +7 -6
  13. package/src/components/__tests__/StructureGrants.spec.js +6 -0
  14. package/src/components/__tests__/StructureLoader.spec.js +1 -1
  15. package/src/components/__tests__/__snapshots__/Grant.spec.js.snap +468 -0
  16. package/src/components/__tests__/__snapshots__/GrantCrumbs.spec.js.snap +102 -0
  17. package/src/components/__tests__/__snapshots__/GrantRoutes.spec.js.snap +12 -4
  18. package/src/components/__tests__/__snapshots__/GrantsTable.spec.js.snap +41 -15
  19. package/src/components/__tests__/__snapshots__/StructureGrants.spec.js.snap +19 -0
  20. package/src/hooks/useGrant.js +18 -0
  21. package/src/messages/en.js +9 -2
  22. package/src/messages/es.js +9 -2
  23. package/src/sagas/__tests__/fetchStructure.spec.js +1 -1
  24. package/src/selectors/__tests__/__snapshots__/getGrantsColumns.spec.js.snap +10 -0
  25. package/src/selectors/__tests__/getGrantsColumns.spec.js +9 -0
  26. package/src/selectors/getGrantsColumns.js +20 -0
@@ -0,0 +1,102 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`<GrantCrumbs /> matches the latest snapshot 1`] = `
4
+ Object {
5
+ "asFragment": [Function],
6
+ "baseElement": <body>
7
+ <div>
8
+ <div
9
+ class="ui breadcrumb"
10
+ >
11
+ <a
12
+ class="section"
13
+ href="/grants"
14
+ >
15
+ Grants
16
+ </a>
17
+ <i
18
+ aria-hidden="true"
19
+ class="right angle icon divider"
20
+ />
21
+ <div
22
+ class="active section"
23
+ >
24
+ foo
25
+ </div>
26
+ </div>
27
+ </div>
28
+ </body>,
29
+ "container": <div>
30
+ <div
31
+ class="ui breadcrumb"
32
+ >
33
+ <a
34
+ class="section"
35
+ href="/grants"
36
+ >
37
+ Grants
38
+ </a>
39
+ <i
40
+ aria-hidden="true"
41
+ class="right angle icon divider"
42
+ />
43
+ <div
44
+ class="active section"
45
+ >
46
+ foo
47
+ </div>
48
+ </div>
49
+ </div>,
50
+ "debug": [Function],
51
+ "findAllByAltText": [Function],
52
+ "findAllByDisplayValue": [Function],
53
+ "findAllByLabelText": [Function],
54
+ "findAllByPlaceholderText": [Function],
55
+ "findAllByRole": [Function],
56
+ "findAllByTestId": [Function],
57
+ "findAllByText": [Function],
58
+ "findAllByTitle": [Function],
59
+ "findByAltText": [Function],
60
+ "findByDisplayValue": [Function],
61
+ "findByLabelText": [Function],
62
+ "findByPlaceholderText": [Function],
63
+ "findByRole": [Function],
64
+ "findByTestId": [Function],
65
+ "findByText": [Function],
66
+ "findByTitle": [Function],
67
+ "getAllByAltText": [Function],
68
+ "getAllByDisplayValue": [Function],
69
+ "getAllByLabelText": [Function],
70
+ "getAllByPlaceholderText": [Function],
71
+ "getAllByRole": [Function],
72
+ "getAllByTestId": [Function],
73
+ "getAllByText": [Function],
74
+ "getAllByTitle": [Function],
75
+ "getByAltText": [Function],
76
+ "getByDisplayValue": [Function],
77
+ "getByLabelText": [Function],
78
+ "getByPlaceholderText": [Function],
79
+ "getByRole": [Function],
80
+ "getByTestId": [Function],
81
+ "getByText": [Function],
82
+ "getByTitle": [Function],
83
+ "queryAllByAltText": [Function],
84
+ "queryAllByDisplayValue": [Function],
85
+ "queryAllByLabelText": [Function],
86
+ "queryAllByPlaceholderText": [Function],
87
+ "queryAllByRole": [Function],
88
+ "queryAllByTestId": [Function],
89
+ "queryAllByText": [Function],
90
+ "queryAllByTitle": [Function],
91
+ "queryByAltText": [Function],
92
+ "queryByDisplayValue": [Function],
93
+ "queryByLabelText": [Function],
94
+ "queryByPlaceholderText": [Function],
95
+ "queryByRole": [Function],
96
+ "queryByTestId": [Function],
97
+ "queryByText": [Function],
98
+ "queryByTitle": [Function],
99
+ "rerender": [Function],
100
+ "unmount": [Function],
101
+ }
102
+ `;
@@ -6,10 +6,18 @@ exports[`<GrantRoutes /> matches the latest snapshot 1`] = `
6
6
  path="/grantsRequests/checkout"
7
7
  render={[Function]}
8
8
  />
9
- <Route
10
- path="/grants"
11
- render={[Function]}
12
- />
9
+ <Switch>
10
+ <Route
11
+ exact={true}
12
+ path="/grants/:id"
13
+ render={[Function]}
14
+ />
15
+ <Route
16
+ exact={true}
17
+ path="/grants"
18
+ render={[Function]}
19
+ />
20
+ </Switch>
13
21
  <Route
14
22
  path="/myGrants"
15
23
  render={[Function]}
@@ -14,11 +14,19 @@ exports[`<GrantsTable /> matches the latest snapshot 1`] = `
14
14
  as="tr"
15
15
  cellAs="td"
16
16
  >
17
+ <TableHeaderCell
18
+ as="th"
19
+ className="disabled"
20
+ content="grant.header.id"
21
+ key="0"
22
+ onClick={[Function]}
23
+ sorted={null}
24
+ />
17
25
  <TableHeaderCell
18
26
  as="th"
19
27
  className=""
20
28
  content="grant.header.user"
21
- key="0"
29
+ key="1"
22
30
  onClick={[Function]}
23
31
  sorted={null}
24
32
  />
@@ -26,7 +34,7 @@ exports[`<GrantsTable /> matches the latest snapshot 1`] = `
26
34
  as="th"
27
35
  className=""
28
36
  content="grant.header.data_structure"
29
- key="1"
37
+ key="2"
30
38
  onClick={[Function]}
31
39
  sorted="ascending"
32
40
  />
@@ -34,7 +42,7 @@ exports[`<GrantsTable /> matches the latest snapshot 1`] = `
34
42
  as="th"
35
43
  className=""
36
44
  content="grant.header.start_date"
37
- key="2"
45
+ key="3"
38
46
  onClick={[Function]}
39
47
  sorted={null}
40
48
  />
@@ -42,7 +50,7 @@ exports[`<GrantsTable /> matches the latest snapshot 1`] = `
42
50
  as="th"
43
51
  className=""
44
52
  content="grant.header.end_date"
45
- key="3"
53
+ key="4"
46
54
  onClick={[Function]}
47
55
  sorted={null}
48
56
  />
@@ -50,7 +58,7 @@ exports[`<GrantsTable /> matches the latest snapshot 1`] = `
50
58
  as="th"
51
59
  className="disabled"
52
60
  content="metadata"
53
- key="4"
61
+ key="5"
54
62
  onClick={[Function]}
55
63
  sorted={null}
56
64
  />
@@ -64,6 +72,15 @@ exports[`<GrantsTable /> matches the latest snapshot 1`] = `
64
72
  cellAs="td"
65
73
  key="0"
66
74
  >
75
+ <TableCell
76
+ as="td"
77
+ content={
78
+ <idDecorator
79
+ id={6}
80
+ />
81
+ }
82
+ key="0"
83
+ />
67
84
  <TableCell
68
85
  as="td"
69
86
  content={
@@ -77,7 +94,7 @@ exports[`<GrantsTable /> matches the latest snapshot 1`] = `
77
94
  }
78
95
  />
79
96
  }
80
- key="0"
97
+ key="1"
81
98
  />
82
99
  <TableCell
83
100
  as="td"
@@ -102,7 +119,7 @@ exports[`<GrantsTable /> matches the latest snapshot 1`] = `
102
119
  }
103
120
  />
104
121
  }
105
- key="1"
122
+ key="2"
106
123
  />
107
124
  <TableCell
108
125
  as="td"
@@ -111,7 +128,7 @@ exports[`<GrantsTable /> matches the latest snapshot 1`] = `
111
128
  start_date="2020-05-17"
112
129
  />
113
130
  }
114
- key="2"
131
+ key="3"
115
132
  />
116
133
  <TableCell
117
134
  as="td"
@@ -120,7 +137,7 @@ exports[`<GrantsTable /> matches the latest snapshot 1`] = `
120
137
  end_date="2023-05-16"
121
138
  />
122
139
  }
123
- key="3"
140
+ key="4"
124
141
  />
125
142
  <TableCell
126
143
  as="td"
@@ -133,7 +150,7 @@ exports[`<GrantsTable /> matches the latest snapshot 1`] = `
133
150
  }
134
151
  />
135
152
  }
136
- key="4"
153
+ key="5"
137
154
  />
138
155
  </TableRow>
139
156
  <TableRow
@@ -141,6 +158,15 @@ exports[`<GrantsTable /> matches the latest snapshot 1`] = `
141
158
  cellAs="td"
142
159
  key="1"
143
160
  >
161
+ <TableCell
162
+ as="td"
163
+ content={
164
+ <idDecorator
165
+ id={8}
166
+ />
167
+ }
168
+ key="0"
169
+ />
144
170
  <TableCell
145
171
  as="td"
146
172
  content={
@@ -154,7 +180,7 @@ exports[`<GrantsTable /> matches the latest snapshot 1`] = `
154
180
  }
155
181
  />
156
182
  }
157
- key="0"
183
+ key="1"
158
184
  />
159
185
  <TableCell
160
186
  as="td"
@@ -185,7 +211,7 @@ exports[`<GrantsTable /> matches the latest snapshot 1`] = `
185
211
  }
186
212
  />
187
213
  }
188
- key="1"
214
+ key="2"
189
215
  />
190
216
  <TableCell
191
217
  as="td"
@@ -194,7 +220,7 @@ exports[`<GrantsTable /> matches the latest snapshot 1`] = `
194
220
  start_date="2011-05-17"
195
221
  />
196
222
  }
197
- key="2"
223
+ key="3"
198
224
  />
199
225
  <TableCell
200
226
  as="td"
@@ -203,7 +229,7 @@ exports[`<GrantsTable /> matches the latest snapshot 1`] = `
203
229
  end_date="2023-05-18"
204
230
  />
205
231
  }
206
- key="3"
232
+ key="4"
207
233
  />
208
234
  <TableCell
209
235
  as="td"
@@ -222,7 +248,7 @@ exports[`<GrantsTable /> matches the latest snapshot 1`] = `
222
248
  }
223
249
  />
224
250
  }
225
- key="4"
251
+ key="5"
226
252
  />
227
253
  </TableRow>
228
254
  </TableBody>
@@ -11,6 +11,11 @@ exports[`<StructureGrants /> matches the latest snapshot 1`] = `
11
11
  <tr
12
12
  class=""
13
13
  >
14
+ <th
15
+ class=""
16
+ >
17
+ Id
18
+ </th>
14
19
  <th
15
20
  class=""
16
21
  >
@@ -42,6 +47,13 @@ exports[`<StructureGrants /> matches the latest snapshot 1`] = `
42
47
  <tr
43
48
  class=""
44
49
  >
50
+ <td
51
+ class=""
52
+ >
53
+ <p>
54
+ 1
55
+ </p>
56
+ </td>
45
57
  <td
46
58
  class=""
47
59
  >
@@ -82,6 +94,13 @@ exports[`<StructureGrants /> matches the latest snapshot 1`] = `
82
94
  <tr
83
95
  class=""
84
96
  >
97
+ <td
98
+ class=""
99
+ >
100
+ <p>
101
+ 2
102
+ </p>
103
+ </td>
85
104
  <td
86
105
  class=""
87
106
  >
@@ -0,0 +1,18 @@
1
+ import { compile } from "path-to-regexp";
2
+ import useSWR from "swr";
3
+ import useSWRMutations from "swr/mutation";
4
+ import { apiJson, apiJsonPatch } from "@truedat/core/services/api";
5
+ import { API_GRANT } from "../api";
6
+
7
+ const toApiPath = compile(API_GRANT);
8
+
9
+ export const useGrant = (id) => {
10
+ const url = toApiPath({ id });
11
+ const { data, error, mutate } = useSWR(url, apiJson);
12
+ return { data: data?.data, error, loading: !error && !data, mutate };
13
+ };
14
+
15
+ export const useGrantRemoval = (id) => {
16
+ const url = toApiPath({ id });
17
+ return useSWRMutations(url, (url, { arg }) => apiJsonPatch(url, arg));
18
+ };
@@ -42,6 +42,8 @@ export default {
42
42
  "grant.actions.cancel_removal.confirmation.content":
43
43
  "Cancelling grant removal. Are you sure?",
44
44
  "grant.actions.cancel_removal.confirmation.header": "Cancel grant removal",
45
+ "grant.actions.request_removal.button": "Remove",
46
+ "grant.actions.cancel_removal.button": "Reactivate",
45
47
  "grant.actions.request_removal.confirmation.content":
46
48
  "Requesting this grant to be revoked. Are you sure?",
47
49
  "grant.actions.request_removal.confirmation.header": "Request grant removal",
@@ -50,10 +52,15 @@ export default {
50
52
  "grant.cell.end_date.null": "No expiration set",
51
53
  "grant.cell.end_date.pending_removal": "Grant pending removal",
52
54
  "grant.cell.end_date.same_user": "It's you",
53
- "grant.header.user": "Account",
55
+ "grant.header": "Grants",
54
56
  "grant.header.data_structure": "Structure",
55
- "grant.header.end_date": "Expires",
57
+ "grant.header.id": "Id",
58
+ "grant.header.user": "Account",
59
+ "grant.header.user_name": "User name",
60
+ "grant.header.created_at": "Grant created",
56
61
  "grant.header.start_date": "Access granted",
62
+ "grant.header.end_date": "Expires",
63
+ "grant.header.details": "Details",
57
64
  "grant.updated_at": "Last changed",
58
65
  "grantApprovalRule.action": "Action",
59
66
  "grantApprovalRule.action.approve": "Approve",
@@ -45,6 +45,8 @@ export default {
45
45
  "Cancelar solicitud de eliminar acceso. ¿Estás seguro?",
46
46
  "grant.actions.cancel_removal.confirmation.header":
47
47
  "Cancelar retirada de acceso",
48
+ "grant.actions.request_removal.button": "Eliminar",
49
+ "grant.actions.cancel_removal.button": "Reactivar",
48
50
  "grant.actions.request_removal.confirmation.content":
49
51
  "El acceso será eliminado. ¿Estás seguro?",
50
52
  "grant.actions.request_removal.confirmation.header":
@@ -54,10 +56,15 @@ export default {
54
56
  "grant.cell.end_date.null": "Sin fecha de expiración",
55
57
  "grant.cell.end_date.pending_removal": "Solicitada expiración del acceso",
56
58
  "grant.cell.end_date.same_user": "Eres tú",
59
+ "grant.header": "Acceso",
57
60
  "grant.header.data_structure": "Estructura",
58
- "grant.header.end_date": "Expira",
59
- "grant.header.start_date": "Acceso desde",
61
+ "grant.header.id": "Id",
60
62
  "grant.header.user": "Cuenta",
63
+ "grant.header.user_name": "Usuario",
64
+ "grant.header.created_at": "Acceso creado",
65
+ "grant.header.start_date": "Acceso desde",
66
+ "grant.header.end_date": "Expira",
67
+ "grant.header.details": "Detalles",
61
68
  "grant.updated_at": "Actualizada",
62
69
  "grantApprovalRules.header": "Reglas de aprobación",
63
70
  "grantApprovalRules.subheader":
@@ -3,7 +3,7 @@ import { testSaga } from "redux-saga-test-plan";
3
3
  import { apiJson, JSON_OPTS } from "@truedat/core/services/api";
4
4
  import {
5
5
  fetchStructureRequestSaga,
6
- fetchStructureSaga
6
+ fetchStructureSaga,
7
7
  } from "../fetchStructure";
8
8
  import { fetchStructure } from "../../routines";
9
9
  import { API_DATA_STRUCTURE_VERSION } from "../../api";
@@ -18,6 +18,16 @@ exports[`EndDateDecorator matches the latest snapshot 1`] = `
18
18
  </div>
19
19
  `;
20
20
 
21
+ exports[`GrantIdDecorator matches the latest snapshot 1`] = `
22
+ <div>
23
+ <a
24
+ href="/grants/1"
25
+ >
26
+ 1
27
+ </a>
28
+ </div>
29
+ `;
30
+
21
31
  exports[`GrantStructureDecorator matches the latest snapshot when structure is direct 1`] = `
22
32
  <div>
23
33
  <div
@@ -6,6 +6,7 @@ import {
6
6
  defaultGrantsTableColumns,
7
7
  getGrantsColumns,
8
8
  getGrantsTableColumns,
9
+ GrantIdDecorator,
9
10
  GrantUserDecorator,
10
11
  GrantStructureDecorator,
11
12
  GrantTableStructureDecorator,
@@ -80,6 +81,14 @@ describe("selectors: getGrantsTableColumns", () => {
80
81
  });
81
82
  });
82
83
 
84
+ describe("GrantIdDecorator", () => {
85
+ it("matches the latest snapshot", () => {
86
+ const props = { id: 1 };
87
+ const { container } = render(<GrantIdDecorator {...props} />, renderOpts);
88
+ expect(container).toMatchSnapshot();
89
+ });
90
+ });
91
+
83
92
  describe("GrantUserDecorator", () => {
84
93
  it("matches the latest snapshot", () => {
85
94
  const props = {
@@ -8,6 +8,16 @@ import { useIntl } from "react-intl";
8
8
  import Moment from "react-moment";
9
9
  import PropTypes from "prop-types";
10
10
 
11
+ export const GrantIdDecorator = ({ id }) => (
12
+ <Link to={linkTo.GRANT({ id })}>{id}</Link>
13
+ );
14
+
15
+ GrantIdDecorator.propTypes = {
16
+ id: PropTypes.number,
17
+ };
18
+
19
+ export const idDecorator = ({ id }) => GrantIdDecorator({ id });
20
+
11
21
  export const GrantUserDecorator = ({ authentication, user }) => {
12
22
  const { formatMessage } = useIntl();
13
23
  const sameUser = user?.user_name === authentication?.user_name;
@@ -156,6 +166,11 @@ EndDateDecorator.propTypes = {
156
166
  };
157
167
 
158
168
  export const defaultGrantsColumns = [
169
+ {
170
+ name: "id",
171
+ fieldSelector: _.pick(["id"]),
172
+ fieldDecorator: idDecorator,
173
+ },
159
174
  {
160
175
  name: "user",
161
176
  fieldSelector: _.pick(["user"]),
@@ -194,6 +209,11 @@ export const getGrantsColumns = createSelector(
194
209
  );
195
210
 
196
211
  export const defaultGrantsTableColumns = [
212
+ {
213
+ name: "id",
214
+ fieldSelector: _.pick(["id"]),
215
+ fieldDecorator: idDecorator,
216
+ },
197
217
  {
198
218
  name: "user",
199
219
  sort: { name: "user.user_name.raw" },