@truedat/dd 4.28.1 → 4.28.5

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 (72) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/package.json +6 -6
  3. package/src/api.js +4 -0
  4. package/src/components/EditDomainForm.js +1 -0
  5. package/src/components/GrantDateFilter.js +30 -0
  6. package/src/components/GrantFilters.js +28 -0
  7. package/src/components/GrantFiltersLoader.js +24 -0
  8. package/src/components/GrantSelectedFilters.js +63 -0
  9. package/src/components/Grants.js +49 -0
  10. package/src/components/GrantsLabelResults.js +32 -0
  11. package/src/components/GrantsLoader.js +41 -0
  12. package/src/components/GrantsPagination.js +14 -0
  13. package/src/components/GrantsRoutes.js +33 -0
  14. package/src/components/GrantsSearch.js +51 -0
  15. package/src/components/GrantsTable.js +112 -0
  16. package/src/components/StructureGrantCart.js +16 -14
  17. package/src/components/StructureGrantCartCheckout.js +9 -9
  18. package/src/components/StructureSummary.js +5 -5
  19. package/src/components/StructureTabPane.js +3 -3
  20. package/src/components/StructureView.js +14 -6
  21. package/src/components/__tests__/GrantDateFilter.spec.js +11 -0
  22. package/src/components/__tests__/GrantsLabelResults.js +17 -0
  23. package/src/components/__tests__/GrantsLoader.spec.js +41 -0
  24. package/src/components/__tests__/GrantsRoutes.spec.js +19 -0
  25. package/src/components/__tests__/GrantsTable.spec.js +185 -0
  26. package/src/components/__tests__/StructureGrantRequestButton.spec.js +20 -9
  27. package/src/components/__tests__/StructureSummary.spec.js +1 -1
  28. package/src/components/__tests__/__snapshots__/GrantDateFilter.spec.js.snap +16 -0
  29. package/src/components/__tests__/__snapshots__/GrantsLabelResults.js.snap +16 -0
  30. package/src/components/__tests__/__snapshots__/GrantsLoader.spec.js.snap +24 -0
  31. package/src/components/__tests__/__snapshots__/GrantsRoutes.spec.js.snap +8 -0
  32. package/src/components/__tests__/__snapshots__/GrantsTable.spec.js.snap +231 -0
  33. package/src/components/index.js +6 -0
  34. package/src/messages/en.js +9 -1
  35. package/src/messages/es.js +9 -1
  36. package/src/reducers/__tests__/grantDateFilter.spec.js +54 -0
  37. package/src/reducers/__tests__/grantFilters.spec.js +37 -0
  38. package/src/reducers/__tests__/grantQuery.spec.js +113 -0
  39. package/src/reducers/__tests__/grants.spec.js +102 -0
  40. package/src/reducers/grantActiveFilters.js +46 -0
  41. package/src/reducers/grantCount.js +20 -0
  42. package/src/reducers/grantDateFilter.js +31 -0
  43. package/src/reducers/grantFilters.js +19 -0
  44. package/src/reducers/grantLoading.js +16 -0
  45. package/src/reducers/grantQuery.js +62 -0
  46. package/src/reducers/grantSelectedFilter.js +34 -0
  47. package/src/reducers/grants.js +24 -0
  48. package/src/reducers/grantsFilters.js +19 -0
  49. package/src/reducers/grantsPageSize.js +15 -0
  50. package/src/reducers/index.js +18 -0
  51. package/src/reducers/structureDateFilter.js +2 -2
  52. package/src/reducers/structureQuery.js +2 -2
  53. package/src/routines.js +20 -0
  54. package/src/sagas/__tests__/fetchGrants.spec.js +74 -0
  55. package/src/sagas/fetchGrantFilters.js +29 -0
  56. package/src/sagas/fetchGrants.js +26 -0
  57. package/src/sagas/index.js +6 -0
  58. package/src/selectors/__tests__/__snapshots__/getGrantsColumns.spec.js.snap +10 -0
  59. package/src/selectors/__tests__/getGrantAvailableFilters.spec.js +15 -0
  60. package/src/selectors/__tests__/getGrantSelectedFilterActiveValues.spec.js +16 -0
  61. package/src/selectors/__tests__/getGrantSelectedFilterValues.spec.js +15 -0
  62. package/src/selectors/__tests__/getGrantSelectedFilters.spec.js +15 -0
  63. package/src/selectors/__tests__/getGrantsColumns.spec.js +40 -0
  64. package/src/selectors/__tests__/getTabVisibility.spec.js +30 -30
  65. package/src/selectors/getGrantAvailableFilters.js +17 -0
  66. package/src/selectors/getGrantSelectedFilterActiveValues.js +8 -0
  67. package/src/selectors/getGrantSelectedFilterValues.js +13 -0
  68. package/src/selectors/getGrantSelectedFilters.js +7 -0
  69. package/src/selectors/getGrantsColumns.js +82 -8
  70. package/src/selectors/getStructureSelectedFilterValues.js +5 -3
  71. package/src/selectors/getTabVisibility.js +7 -7
  72. package/src/selectors/index.js +4 -0
@@ -0,0 +1,13 @@
1
+ import _ from "lodash/fp";
2
+ import { createSelector } from "reselect";
3
+ import { formatFilterValues } from "@truedat/core/services/filters";
4
+
5
+ export const getGrantSelectedFilterValues = createSelector(
6
+ [_.prop("grantSelectedFilter"), _.prop("grantFilters")],
7
+ (grantSelectedFilter, grantFilters) => {
8
+ return _.flow(
9
+ _.propOr([], grantSelectedFilter),
10
+ formatFilterValues(grantSelectedFilter)
11
+ )(grantFilters);
12
+ }
13
+ );
@@ -0,0 +1,7 @@
1
+ import _ from "lodash/fp";
2
+ import { createSelector } from "reselect";
3
+
4
+ export const getGrantSelectedFilters = createSelector(
5
+ [_.prop("grantActiveFilters")],
6
+ _.keys
7
+ );
@@ -7,6 +7,7 @@ import { linkTo } from "@truedat/core/routes";
7
7
  import { useIntl } from "react-intl";
8
8
  import Moment from "react-moment";
9
9
  import PropTypes from "prop-types";
10
+ import { findDOMNode } from "react-dom";
10
11
 
11
12
  export const GrantUserDecorator = ({ authentication, user }) => {
12
13
  const { formatMessage } = useIntl();
@@ -42,7 +43,7 @@ export const GrantStructureDecorator = ({
42
43
  data_structure,
43
44
  }) => {
44
45
  const { formatMessage } = useIntl();
45
- const direct = grant_structure.id === data_structure.id;
46
+ const direct = grant_structure?.id === data_structure?.id;
46
47
 
47
48
  const path =
48
49
  !direct &&
@@ -69,8 +70,36 @@ GrantStructureDecorator.propTypes = {
69
70
  grant_structure: PropTypes.object,
70
71
  };
71
72
 
72
- export const structureDecorator = (structure) => (props) =>
73
- GrantStructureDecorator({ grant_structure: structure, ...props });
73
+ export const structureDecorator = (structure) => (props) => {
74
+ return GrantStructureDecorator({ grant_structure: structure, ...props });
75
+ };
76
+
77
+ export const GrantTableStructureDecorator = ({ data_structure_version }) => {
78
+ return (
79
+ <Link
80
+ to={linkTo.STRUCTURE({ id: data_structure_version.data_structure_id })}
81
+ >
82
+ {data_structure_version.name}
83
+ </Link>
84
+ );
85
+ };
86
+
87
+ GrantTableStructureDecorator.propTypes = {
88
+ data_structure_version: PropTypes.object,
89
+ };
90
+
91
+ export const GenericObjectDecorator = ({
92
+ data_structure_version: { metadata },
93
+ }) =>
94
+ Object.entries(metadata).map(([k, v], i) => [
95
+ <div key={i}>
96
+ {k}: {v}
97
+ </div>,
98
+ ]);
99
+
100
+ GenericObjectDecorator.propTypes = {
101
+ metadata: PropTypes.object,
102
+ };
74
103
 
75
104
  export const StartDateDecorator = ({ start_date }) => {
76
105
  const { locale } = useIntl();
@@ -140,7 +169,7 @@ export const defaultGrantsColumns = [
140
169
  {
141
170
  name: "start_date",
142
171
  fieldSelector: _.pick(["start_date"]),
143
- fieldDecorator: StartDateDecorator,
172
+ fieldDecorator: (field) => field.start_date,
144
173
  },
145
174
  {
146
175
  name: "end_date",
@@ -154,12 +183,57 @@ export const getGrantsColumns = createSelector(
154
183
  (grantsColumns, structure, authentication) =>
155
184
  _.flow(
156
185
  _.defaultTo(defaultGrantsColumns),
157
- _.map((c) =>
158
- c.name === "data_structure"
186
+ _.map((c) => {
187
+ return c.name === "data_structure"
159
188
  ? { ...c, fieldDecorator: c.fieldDecorator(structure) }
160
189
  : c.name === "user"
161
190
  ? { ...c, fieldDecorator: c.fieldDecorator(authentication) }
162
- : c
163
- )
191
+ : c;
192
+ })
193
+ )(grantsColumns)
194
+ );
195
+
196
+ export const defaultGrantsTableColumns = [
197
+ {
198
+ name: "user",
199
+ sort: { name: "user.user_name.raw" },
200
+ fieldSelector: _.pick(["user"]),
201
+ fieldDecorator: userDecorator,
202
+ },
203
+ {
204
+ name: "data_structure_version",
205
+ sort: { name: "data_structure_version.name.raw" },
206
+ fieldSelector: _.pick(["data_structure", "data_structure_version"]),
207
+ fieldDecorator: GrantTableStructureDecorator,
208
+ },
209
+ {
210
+ name: "start_date",
211
+ sort: { name: "start_date" },
212
+ fieldSelector: _.pick(["start_date"]),
213
+ fieldDecorator: StartDateDecorator,
214
+ },
215
+ {
216
+ name: "end_date",
217
+ sort: { name: "end_date" },
218
+ fieldSelector: _.pick(["end_date"]),
219
+ fieldDecorator: EndDateDecorator,
220
+ },
221
+ {
222
+ name: "metadata",
223
+ fieldSelector: _.pick(["data_structure_version.metadata"]),
224
+ fieldDecorator: GenericObjectDecorator,
225
+ },
226
+ ];
227
+
228
+ export const getGrantsTableColumns = createSelector(
229
+ [_.prop("grantsColumns"), _.prop("authentication")],
230
+ (grantsColumns, authentication) =>
231
+ _.flow(
232
+ _.defaultTo(defaultGrantsTableColumns),
233
+ _.map((c) => {
234
+ return c.name === "user"
235
+ ? { ...c, fieldDecorator: c.fieldDecorator(authentication) }
236
+ : c;
237
+ })
164
238
  )(grantsColumns)
165
239
  );
@@ -4,9 +4,11 @@ import { formatFilterValues } from "@truedat/core/services/filters";
4
4
 
5
5
  export const getStructureSelectedFilterValues = createSelector(
6
6
  [_.prop("structureSelectedFilter"), _.prop("structureFilters")],
7
- (structureSelectedFilter, structureFilters) =>
8
- _.flow(
7
+ (structureSelectedFilter, structureFilters) => {
8
+ const result = _.flow(
9
9
  _.propOr([], structureSelectedFilter),
10
10
  formatFilterValues(structureSelectedFilter)
11
- )(structureFilters)
11
+ )(structureFilters);
12
+ return result;
13
+ }
12
14
  );
@@ -3,7 +3,7 @@ import { getStructureToConceptLinks } from "./getStructureLinks";
3
3
  import { metadataViewsSelector } from "./metadataViewsSelector";
4
4
 
5
5
  const notEmpty = _.negate(_.isEmpty);
6
- const notEmptyPath = path => _.flow(_.path(path), notEmpty);
6
+ const notEmptyPath = (path) => _.flow(_.path(path), notEmpty);
7
7
  const hasProfile = notEmptyPath("profile");
8
8
 
9
9
  const fieldsTabVisible = _.conformsTo({ structureFields: notEmpty });
@@ -11,14 +11,14 @@ const fieldsTabVisible = _.conformsTo({ structureFields: notEmpty });
11
11
  const profileTabVisible = ({
12
12
  userPermissions,
13
13
  structureFields,
14
- structureProfile
14
+ structureProfile,
15
15
  }) =>
16
16
  _.anyPass([_.prop("view_profiling_permission")])(userPermissions) &&
17
17
  (_.some(hasProfile)(structureFields) ||
18
18
  notEmpty(structureProfile?.most_frequent) ||
19
19
  notEmpty(structureProfile?.patterns));
20
20
 
21
- const linksTabVisible = state => {
21
+ const linksTabVisible = (state) => {
22
22
  const { conceptCount } = state;
23
23
  const structureLinks = getStructureToConceptLinks(state);
24
24
  return conceptCount > 0 || !_.isEmpty(structureLinks);
@@ -29,7 +29,7 @@ const notesTabVisible = ({
29
29
  templates,
30
30
  structure,
31
31
  structureTypes,
32
- structureTypesLoading
32
+ structureTypesLoading,
33
33
  }) =>
34
34
  !templatesLoading &&
35
35
  notEmpty(templates) &&
@@ -38,7 +38,7 @@ const notesTabVisible = ({
38
38
  notEmpty(structureTypes) &&
39
39
  _.flow(
40
40
  _.find({
41
- name: _.prop("type")(structure)
41
+ name: _.prop("type")(structure),
42
42
  }),
43
43
  _.get("template"),
44
44
  _.negate(_.isNil)
@@ -56,7 +56,7 @@ const grantsTabVisible = _.flow(
56
56
  _.negate(_.isEmpty)
57
57
  );
58
58
 
59
- export const getTabVisibility = state => ({
59
+ export const getTabVisibility = (state) => ({
60
60
  fields: fieldsTabVisible(state),
61
61
  profile: profileTabVisible(state),
62
62
  links: linksTabVisible(state),
@@ -69,5 +69,5 @@ export const getTabVisibility = state => ({
69
69
  impact: impactTabVisible(state),
70
70
  parents: parentsTabVisible(state),
71
71
  children: childrenTabVisible(state),
72
- grants: grantsTabVisible(state)
72
+ grants: grantsTabVisible(state),
73
73
  });
@@ -3,6 +3,10 @@ export {
3
3
  structureColumnsSelector,
4
4
  structureRowsSelector,
5
5
  } from "./structureColumnsSelector";
6
+ export { getGrantAvailableFilters } from "./getGrantAvailableFilters";
7
+ export { getGrantSelectedFilters } from "./getGrantSelectedFilters";
8
+ export { getGrantSelectedFilterValues } from "./getGrantSelectedFilterValues";
9
+ export { getGrantSelectedFilterActiveValues } from "./getGrantSelectedFilterActiveValues";
6
10
  export {
7
11
  defaultStructureProperties,
8
12
  getStructureProperties,