@truedat/dd 5.18.3 → 5.20.0

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 (50) hide show
  1. package/package.json +5 -5
  2. package/src/api/queries.js +19 -1
  3. package/src/components/Grant.js +9 -27
  4. package/src/components/GrantRemoval.js +26 -34
  5. package/src/components/GrantRemovalDirectButton.js +89 -0
  6. package/src/components/GrantRemovalWorkflow.js +107 -0
  7. package/src/components/GrantRemovalWorkflowDropdown.js +144 -0
  8. package/src/components/GrantRequest.js +2 -1
  9. package/src/components/GrantRequestCancel.js +5 -2
  10. package/src/components/GrantRequestHeader.js +13 -7
  11. package/src/components/GrantRequestRow.js +8 -1
  12. package/src/components/GrantRequests.js +8 -3
  13. package/src/components/GrantRequestsTable.js +1 -1
  14. package/src/components/StructureGrantDropdown.js +7 -40
  15. package/src/components/StructureGrantSummaryButton.js +2 -2
  16. package/src/components/StructureGrants.js +21 -17
  17. package/src/components/StructureNoteActions.js +1 -0
  18. package/src/components/StructureNoteSuggestions.js +179 -0
  19. package/src/components/StructureNotesEdit.js +19 -2
  20. package/src/components/__tests__/Grant.spec.js +11 -7
  21. package/src/components/__tests__/GrantRemoval.spec.js +19 -54
  22. package/src/components/__tests__/GrantRemovalDirectButton.spec.js +66 -0
  23. package/src/components/__tests__/GrantRemovalWorkflow.spec.js +157 -0
  24. package/src/components/__tests__/GrantRequest.spec.js +2 -0
  25. package/src/components/__tests__/GrantRequestHeader.spec.js +2 -5
  26. package/src/components/__tests__/StructureGrantDropdown.spec.js +1 -16
  27. package/src/components/__tests__/StructureGrantSummaryButton.spec.js +3 -2
  28. package/src/components/__tests__/StructureGrants.spec.js +5 -1
  29. package/src/components/__tests__/StructureNoteSuggestions.spec.js +151 -0
  30. package/src/components/__tests__/StructureNotesEdit.spec.js +34 -0
  31. package/src/components/__tests__/__snapshots__/Grant.spec.js.snap +5 -4
  32. package/src/components/__tests__/__snapshots__/GrantRequest.spec.js.snap +3 -3
  33. package/src/components/__tests__/__snapshots__/GrantRequestHeader.spec.js.snap +4 -4
  34. package/src/components/__tests__/__snapshots__/GrantRequestsSearchResults.spec.js.snap +1 -1
  35. package/src/components/__tests__/__snapshots__/StructureGrantDropdown.spec.js.snap +0 -52
  36. package/src/components/__tests__/__snapshots__/StructureGrantListButton.spec.js.snap +0 -14
  37. package/src/components/__tests__/__snapshots__/StructureGrantSummaryButton.spec.js.snap +0 -14
  38. package/src/components/__tests__/__snapshots__/StructureGrants.spec.js.snap +4 -5
  39. package/src/components/__tests__/__snapshots__/StructureNoteSuggestions.spec.js.snap +316 -0
  40. package/src/components/__tests__/__snapshots__/StructureNotesEdit.spec.js.snap +49 -0
  41. package/src/hooks/useGrantRequest.js +10 -1
  42. package/src/messages/en.js +23 -8
  43. package/src/messages/es.js +26 -9
  44. package/src/reducers/structure.js +1 -0
  45. package/src/sagas/__tests__/createGrantRequestStatus.spec.js +1 -1
  46. package/src/sagas/createGrantRequestStatus.js +24 -8
  47. package/src/selectors/getGrantRequestsColumns.js +32 -5
  48. package/src/selectors/getGrantRequestsSearchColumns.js +20 -14
  49. package/src/selectors/utils/decorators.js +68 -0
  50. package/src/components/__tests__/__snapshots__/GrantRemoval.spec.js.snap +0 -9
@@ -2,6 +2,8 @@ import _ from "lodash/fp";
2
2
  import React from "react";
3
3
  import { Header, Icon, Popup } from "semantic-ui-react";
4
4
  import { createSelector } from "reselect";
5
+ import { linkTo } from "@truedat/core/routes";
6
+ import { Link } from "react-router-dom";
5
7
  import { useIntl } from "react-intl";
6
8
  import PropTypes from "prop-types";
7
9
  import Moment from "react-moment";
@@ -26,29 +28,34 @@ export const PathDecorator = ({ data_structure_version }) => {
26
28
  };
27
29
 
28
30
  PathDecorator.propTypes = {
29
- data_structure: PropTypes.object,
31
+ data_structure_version: PropTypes.object,
30
32
  };
31
33
 
32
- export const StructureDecorator = ({ name, modificationGrant }) => {
34
+ export const StructureDecorator = (grantRequest) => {
33
35
  const { formatMessage } = useIntl();
34
36
  return (
35
37
  <>
36
- {modificationGrant ? (
38
+ {grantRequest.modification_grant_id ? (
37
39
  <Popup
38
40
  content={formatMessage({ id: "grantRequest.modification_grant_id" })}
39
41
  trigger={<Icon name="edit" />}
40
42
  />
43
+ ) : grantRequest.request_type === "grant_removal" ? (
44
+ <Popup
45
+ content={formatMessage({ id: "request.grantRemoval" })}
46
+ trigger={
47
+ <Link to={linkTo.GRANT({ id: grantRequest.grant.id })}>
48
+ <Icon name="key" />
49
+ </Link>
50
+ }
51
+ />
41
52
  ) : null}
42
- {name}
53
+ {grantRequest?.data_structure_version?.name ||
54
+ grantRequest?.grant?.data_structure_version?.name}
43
55
  </>
44
56
  );
45
57
  };
46
58
 
47
- StructureDecorator.propTypes = {
48
- name: PropTypes.string,
49
- modificationGrant: PropTypes.string,
50
- };
51
-
52
59
  const DateDecorator = ({ date }) => {
53
60
  const { locale } = useIntl();
54
61
  return date ? (
@@ -83,16 +90,15 @@ export const defaultGrantRequestsSearchTableColumns = [
83
90
  {
84
91
  name: "data_structure",
85
92
  sort: { name: "data_structure_version.name.raw" },
86
- fieldSelector: (grantRequest) => ({
87
- name: grantRequest?.data_structure_version?.name,
88
- modificationGrant: _.prop("modification_grant_id")(grantRequest),
89
- }),
93
+ fieldSelector: (grantRequest) => grantRequest,
90
94
  fieldDecorator: StructureDecorator,
91
95
  },
92
96
  {
93
97
  name: "path",
94
98
  fieldSelector: (grantRequest) => ({
95
- data_structure_version: grantRequest?.data_structure_version,
99
+ data_structure_version:
100
+ grantRequest?.data_structure_version ||
101
+ grantRequest?.grant?.data_structure_version,
96
102
  }),
97
103
  fieldDecorator: PathDecorator,
98
104
  },
@@ -0,0 +1,68 @@
1
+ import _ from "lodash/fp";
2
+ import React from "react";
3
+ import { Header, Icon, Popup } from "semantic-ui-react";
4
+ import { linkTo } from "@truedat/core/routes";
5
+ import { Link } from "react-router-dom";
6
+ import { useIntl } from "react-intl";
7
+ import PropTypes from "prop-types";
8
+ import Moment from "react-moment";
9
+
10
+ export const UserDecorator = ({ user }) =>
11
+ user ? (
12
+ <Header as="h4">
13
+ <Header.Content>
14
+ {user.full_name} <Header.Subheader>{user.email}</Header.Subheader>
15
+ </Header.Content>
16
+ </Header>
17
+ ) : null;
18
+
19
+ UserDecorator.propTypes = {
20
+ user: PropTypes.object,
21
+ };
22
+
23
+ export const GrantRequestStructureDecorator = (grantRequest) => {
24
+ const { formatMessage } = useIntl();
25
+ return (
26
+ <>
27
+ {grantRequest?.modification_grant_id ? (
28
+ <Popup
29
+ content={formatMessage({ id: "grantRequest.isModification" })}
30
+ trigger={<Icon name="edit" />}
31
+ />
32
+ ) : grantRequest?.request_type === "grant_removal" ? (
33
+ <Popup
34
+ content={formatMessage({ id: "grantRequest.isModification" })}
35
+ trigger={
36
+ <Link to={linkTo.GRANT({ id: grantRequest?.grant?.id || 0 })}>
37
+ <Icon name="key" />
38
+ </Link>
39
+ }
40
+ />
41
+ ) : null}
42
+ { grantRequest?.data_structure_version?.name ||
43
+ grantRequest?.grant?.data_structure_version?.name}
44
+ </>
45
+ );
46
+ };
47
+
48
+ export const DateDecorator = ({ date }) => {
49
+ const { locale } = useIntl();
50
+ return date ? (
51
+ <Moment locale={locale} date={date} format="YYYY-MM-DD HH:mm" />
52
+ ) : null;
53
+ };
54
+
55
+ DateDecorator.propTypes = {
56
+ date: PropTypes.string,
57
+ };
58
+
59
+ export const StatusDecorator = ({ status }) => {
60
+ const { formatMessage } = useIntl();
61
+ return status ? (
62
+ <>{formatMessage({ id: `grantRequest.content.${status}` })}</>
63
+ ) : null;
64
+ };
65
+
66
+ StatusDecorator.propTypes = {
67
+ status: PropTypes.string,
68
+ };
@@ -1,9 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`<GrantRemoval /> matches the latest snapshot 1`] = `
4
- <div>
5
- <p>
6
- child
7
- </p>
8
- </div>
9
- `;