@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.28.4] 2021-09-15
4
+
5
+ ### Added
6
+
7
+ - [TD-3950] Grants table
8
+
3
9
  ## [4.28.0] 2021-09-10
4
10
 
5
11
  ### Fixed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/dd",
3
- "version": "4.28.1",
3
+ "version": "4.28.5",
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.14.1",
35
35
  "@testing-library/react": "^12.0.0",
36
36
  "@testing-library/user-event": "^13.2.1",
37
- "@truedat/test": "4.28.1",
37
+ "@truedat/test": "4.28.5",
38
38
  "babel-jest": "^27.0.6",
39
39
  "babel-plugin-dynamic-import-node": "^2.3.3",
40
40
  "babel-plugin-lodash": "^3.3.4",
@@ -84,9 +84,9 @@
84
84
  ]
85
85
  },
86
86
  "dependencies": {
87
- "@truedat/auth": "4.28.1",
88
- "@truedat/core": "4.28.1",
89
- "@truedat/df": "4.28.1",
87
+ "@truedat/auth": "4.28.5",
88
+ "@truedat/core": "4.28.5",
89
+ "@truedat/df": "4.28.5",
90
90
  "lodash": "^4.17.21",
91
91
  "path-to-regexp": "^1.7.0",
92
92
  "prop-types": "^15.7.2",
@@ -107,5 +107,5 @@
107
107
  "react-dom": ">= 16.8.6 < 17",
108
108
  "semantic-ui-react": ">= 0.88.2 < 2.1"
109
109
  },
110
- "gitHead": "6ff590df29781cbbbdbd8719a394649d758330c4"
110
+ "gitHead": "e004c6a673d6824a4807e4378b6e5c83e947c992"
111
111
  }
package/src/api.js CHANGED
@@ -4,8 +4,10 @@ const API_DATA_STRUCTURES_CSV = "/api/data_structures/csv";
4
4
  const API_DATA_STRUCTURES_SEARCH = "/api/data_structures/search";
5
5
  const API_DATA_STRUCTURE_FILTERS_SEARCH = "/api/data_structure_filters/search";
6
6
  const API_DATA_STRUCTURE_VERSION = "/api/data_structures/:id/versions/:version";
7
+ const API_GRANT_FILTERS_SEARCH = "/api/grant_filters/search";
7
8
  const API_PROFILE_EXECUTION = "/api/profile_executions/:id";
8
9
  const API_GRANT_REQUEST = "/api/grant_request_groups";
10
+ const API_GRANTS_SEARCH = "/api/grants/search";
9
11
  const API_GRAPH = "/api/graphs/:id";
10
12
  const API_GRAPHS = "/api/graphs";
11
13
  const API_GRAPH_CSV = "/api/graphs/csv";
@@ -40,7 +42,9 @@ export {
40
42
  API_DATA_STRUCTURE_FILTERS_SEARCH,
41
43
  API_DATA_STRUCTURE_VERSION,
42
44
  API_PROFILE_EXECUTION,
45
+ API_GRANT_FILTERS_SEARCH,
43
46
  API_GRANT_REQUEST,
47
+ API_GRANTS_SEARCH,
44
48
  API_GRAPH,
45
49
  API_GRAPHS,
46
50
  API_GRAPH_CSV,
@@ -27,6 +27,7 @@ export const EditDomainForm = ({ title, updateStructure, structure }) => {
27
27
  <Container style={{ width: "400px" }}>
28
28
  <Header as="h2" content={title} />
29
29
  <DomainDropdownSelector
30
+ clearable={false}
30
31
  onChange={handleDomainSelected}
31
32
  name="domain"
32
33
  value={domainId || structure?.domain_id}
@@ -0,0 +1,30 @@
1
+ import React from "react";
2
+ import { propOr } from "lodash/fp";
3
+ import PropTypes from "prop-types";
4
+ import { FormattedMessage } from "react-intl";
5
+ import { connect } from "react-redux";
6
+ import DateRangeFilter from "@truedat/core/components/DateRangeFilter";
7
+ import { applyGrantDateFilter } from "../routines";
8
+
9
+ export const GrantDateFilter = ({ active, applyGrantDateFilter, ...props }) =>
10
+ active ? (
11
+ <>
12
+ <DateRangeFilter
13
+ label={<FormattedMessage id="grant.start_date" />}
14
+ name="start_date,end_date"
15
+ onChange={applyGrantDateFilter}
16
+ defaultValues={props}
17
+ />
18
+ </>
19
+ ) : null;
20
+
21
+ GrantDateFilter.propTypes = {
22
+ active: PropTypes.bool,
23
+ applyGrantDateFilter: PropTypes.func,
24
+ };
25
+
26
+ export const mapStateToProps = propOr({}, "grantDateFilter");
27
+
28
+ export default connect(mapStateToProps, { applyGrantDateFilter })(
29
+ GrantDateFilter
30
+ );
@@ -0,0 +1,28 @@
1
+ import React from "react";
2
+ import { connect } from "react-redux";
3
+ import { bindActionCreators } from "redux";
4
+ import { addGrantFilter, resetGrantFilters } from "../routines";
5
+ import { getGrantAvailableFilters } from "../selectors";
6
+
7
+ const AvailableFilters = React.lazy(() =>
8
+ import("@truedat/core/components/AvailableFilters")
9
+ );
10
+
11
+ const mapStateToProps = (state) => {
12
+ return {
13
+ filters: getGrantAvailableFilters(state),
14
+ disabled: state.grantFiltersLoading,
15
+ loading: state.grantFiltersLoading,
16
+ };
17
+ };
18
+
19
+ const mapDispatchToProps = (dispatch) =>
20
+ bindActionCreators(
21
+ {
22
+ addFilter: addGrantFilter,
23
+ resetFilters: resetGrantFilters,
24
+ },
25
+ dispatch
26
+ );
27
+
28
+ export default connect(mapStateToProps, mapDispatchToProps)(AvailableFilters);
@@ -0,0 +1,24 @@
1
+ import { connect } from "react-redux";
2
+ import { bindActionCreators } from "redux";
3
+ import { FiltersLoader } from "@truedat/core/components";
4
+ import { makeActiveFiltersSelector } from "@truedat/core/selectors";
5
+ import { clearGrantFilters, fetchGrantFilters } from "../routines";
6
+
7
+ const mapDispatchToProps = (dispatch) =>
8
+ bindActionCreators(
9
+ { clearFilters: clearGrantFilters, fetchFilters: fetchGrantFilters },
10
+ dispatch
11
+ );
12
+
13
+ const makeMapStateToProps = () => {
14
+ const activeFiltersSelector = makeActiveFiltersSelector("grantActiveFilters");
15
+ const mapStateToProps = (state, props) => {
16
+ return {
17
+ selectedFilter: state.grantSelectedFilter,
18
+ filters: activeFiltersSelector(state, props),
19
+ };
20
+ };
21
+ return mapStateToProps;
22
+ };
23
+
24
+ export default connect(makeMapStateToProps, mapDispatchToProps)(FiltersLoader);
@@ -0,0 +1,63 @@
1
+ import _ from "lodash/fp";
2
+ import { bindActionCreators } from "redux";
3
+ import { connect } from "react-redux";
4
+ import { makeOption } from "@truedat/core/services/i18n";
5
+ import { SelectedFilters } from "@truedat/core/components";
6
+ import {
7
+ closeGrantFilter,
8
+ openGrantFilter,
9
+ removeGrantFilter,
10
+ resetGrantFilters,
11
+ toggleGrantFilterValue,
12
+ } from "../routines";
13
+ import {
14
+ getGrantSelectedFilterActiveValues,
15
+ getGrantSelectedFilters,
16
+ getGrantSelectedFilterValues,
17
+ } from "../selectors";
18
+
19
+ const translations = (formatMessage) => ({
20
+ "active.raw": (v) =>
21
+ formatMessage({ id: `filters.active.raw.${v}`, defaultMessage: v }),
22
+ "execution_result_info.result_text": (v) => formatMessage({ id: v }),
23
+ });
24
+
25
+ export const mapStateToProps = (state, ownProps) => {
26
+ const formatMessage = _.pathOr(_.prop("id"), "intl.formatMessage")(ownProps);
27
+ const { grantSelectedFilter: selectedFilter } = state;
28
+
29
+ const i18nValues = _.flow(
30
+ getGrantSelectedFilterValues,
31
+ _.map(makeOption(translations(formatMessage), selectedFilter))
32
+ )(state);
33
+
34
+ // const values = _.flow(
35
+ // getGrantSelectedFilterValues,
36
+ // _.map((v) => ({ text: v, value: v }))
37
+ // )(state);
38
+
39
+ // _.map(
40
+ // makeOption(translations(formatMessage, structureTypes), selectedFilter)
41
+ // )(selectedFilterValues),
42
+
43
+ return {
44
+ selectedFilter,
45
+ selectedFilters: getGrantSelectedFilters(state),
46
+ selectedFilterActiveValues: getGrantSelectedFilterActiveValues(state),
47
+ selectedFilterValues: i18nValues,
48
+ };
49
+ };
50
+
51
+ const mapDispatchToProps = (dispatch) =>
52
+ bindActionCreators(
53
+ {
54
+ closeFilter: closeGrantFilter,
55
+ openFilter: openGrantFilter,
56
+ removeFilter: removeGrantFilter,
57
+ resetFilters: resetGrantFilters,
58
+ toggleFilterValue: toggleGrantFilterValue,
59
+ },
60
+ dispatch
61
+ );
62
+
63
+ export default connect(mapStateToProps, mapDispatchToProps)(SelectedFilters);
@@ -0,0 +1,49 @@
1
+ import React from "react";
2
+ import PropTypes from "prop-types";
3
+ import { connect } from "react-redux";
4
+ import { Header, Icon, Segment, Dimmer, Loader } from "semantic-ui-react";
5
+ import { FormattedMessage } from "react-intl";
6
+
7
+ import GrantDateFilter from "./GrantDateFilter";
8
+ import GrantsSearch from "./GrantsSearch";
9
+ import GrantsTable from "./GrantsTable";
10
+ //import JobsLabelResults from "./JobsLabelResults";
11
+ import GrantsLabelResults from "./GrantsLabelResults";
12
+
13
+ import GrantSelectedFilters from "./GrantSelectedFilters";
14
+ import GrantsPagination from "./GrantsPagination";
15
+
16
+ export const Grants = ({ grantsLoading }) => (
17
+ <Segment>
18
+ <Header as="h2">
19
+ <Icon circular name="cogs" />
20
+ <Header.Content>
21
+ <FormattedMessage id="grants.header" />
22
+ <Header.Subheader>
23
+ <FormattedMessage id="grants.subheader" />
24
+ </Header.Subheader>
25
+ </Header.Content>
26
+ </Header>
27
+ <Segment attached="bottom">
28
+ <GrantsSearch />
29
+ <GrantSelectedFilters />
30
+ <GrantDateFilter />
31
+ <Dimmer.Dimmable dimmed={grantsLoading}>
32
+ <Dimmer active={grantsLoading} inverted>
33
+ <Loader />
34
+ </Dimmer>
35
+ </Dimmer.Dimmable>
36
+ <GrantsLabelResults />
37
+ <GrantsTable />
38
+ <GrantsPagination />
39
+ </Segment>
40
+ </Segment>
41
+ );
42
+
43
+ Grants.propTypes = {
44
+ grantsLoading: PropTypes.bool,
45
+ };
46
+
47
+ const mapStateToProps = ({ grantsLoading }) => ({ grantsLoading });
48
+
49
+ export default connect(mapStateToProps)(Grants);
@@ -0,0 +1,32 @@
1
+ import React from "react";
2
+ import PropTypes from "prop-types";
3
+ import { connect } from "react-redux";
4
+ import { FormattedMessage } from "react-intl";
5
+ import { Label } from "semantic-ui-react";
6
+
7
+ export const GrantsLabelResults = ({ grantCount, grantsLoading }) => {
8
+ return (
9
+ <Label className="grants-label-results">
10
+ {grantsLoading ? (
11
+ <FormattedMessage id="grants.searching" />
12
+ ) : (
13
+ <FormattedMessage
14
+ id="grants.retrieved.results"
15
+ values={{ count: grantCount }}
16
+ />
17
+ )}
18
+ </Label>
19
+ );
20
+ };
21
+
22
+ GrantsLabelResults.propTypes = {
23
+ grantCount: PropTypes.number,
24
+ grantsLoading: PropTypes.bool,
25
+ };
26
+
27
+ const mapStateToProps = ({ grantCount, grantsLoading }) => ({
28
+ grantCount,
29
+ grantsLoading,
30
+ });
31
+
32
+ export default connect(mapStateToProps)(GrantsLabelResults);
@@ -0,0 +1,41 @@
1
+ import { useEffect } from "react";
2
+ import PropTypes from "prop-types";
3
+ import { connect } from "react-redux";
4
+ import { makeSearchQuerySelector } from "@truedat/core/selectors";
5
+ import { clearGrants, fetchGrants } from "../routines";
6
+
7
+ export const GrantsLoader = ({ clearGrants, fetchGrants, payload }) => {
8
+ useEffect(() => {
9
+ return () => {
10
+ clearGrants();
11
+ };
12
+ }, [clearGrants]);
13
+ useEffect(() => {
14
+ fetchGrants(payload);
15
+ }, [payload, fetchGrants]);
16
+ return null;
17
+ };
18
+
19
+ GrantsLoader.propTypes = {
20
+ clearGrants: PropTypes.func,
21
+ fetchGrants: PropTypes.func,
22
+ payload: PropTypes.object,
23
+ };
24
+
25
+ const makeMapStateToProps = () => {
26
+ const searchQuerySelector = makeSearchQuerySelector(
27
+ "grantQuery",
28
+ "grantActiveFilters",
29
+ "grantDateFilter"
30
+ );
31
+ const mapStateToProps = (state, props) => {
32
+ return {
33
+ payload: searchQuerySelector(state, props),
34
+ };
35
+ };
36
+ return mapStateToProps;
37
+ };
38
+
39
+ export default connect(makeMapStateToProps, { clearGrants, fetchGrants })(
40
+ GrantsLoader
41
+ );
@@ -0,0 +1,14 @@
1
+ import { connect } from "react-redux";
2
+ import { bindActionCreators } from "redux";
3
+ import { Pagination } from "@truedat/core/components";
4
+ import { selectGrantPage } from "../routines";
5
+
6
+ const mapDispatchToProps = (dispatch) =>
7
+ bindActionCreators({ selectPage: selectGrantPage }, dispatch);
8
+
9
+ const mapStateToProps = ({ grantQuery, grantCount, grantsPageSize }) => ({
10
+ activePage: grantQuery?.page,
11
+ totalPages: Math.ceil(grantCount / grantsPageSize),
12
+ });
13
+
14
+ export default connect(mapStateToProps, mapDispatchToProps)(Pagination);
@@ -0,0 +1,33 @@
1
+ import React from "react";
2
+ import { Route } from "react-router-dom";
3
+ import { Unauthorized } from "@truedat/core/components";
4
+ import { useAuthorized } from "@truedat/core/hooks";
5
+ import { GRANTS } from "@truedat/core/routes";
6
+ import GrantsTable from "./GrantsTable";
7
+ import GrantFiltersLoader from "./GrantFiltersLoader";
8
+ import GrantsLoader from "./GrantsLoader";
9
+ import StructureGrants from "./StructureGrants";
10
+ import GrantFilters from "./GrantFilters";
11
+ import Grants from "./Grants";
12
+
13
+ export const GrantsRoutes = () => {
14
+ const authorized = true; //useAuthorized("grants");
15
+ return (
16
+ <Route
17
+ path={GRANTS}
18
+ render={() =>
19
+ authorized ? (
20
+ <>
21
+ <GrantsLoader />
22
+ <GrantFiltersLoader />
23
+ <Grants />
24
+ </>
25
+ ) : (
26
+ <Unauthorized />
27
+ )
28
+ }
29
+ />
30
+ );
31
+ };
32
+
33
+ export default GrantsRoutes;
@@ -0,0 +1,51 @@
1
+ import React from "react";
2
+ import PropTypes from "prop-types";
3
+ import { connect } from "react-redux";
4
+ import { Button, Icon, Input } from "semantic-ui-react";
5
+ import { useIntl } from "react-intl";
6
+ import { searchGrants, toggleGrantDateFilter } from "../routines";
7
+ import GrantFilters from "./GrantFilters";
8
+
9
+ export const GrantsSearch = ({
10
+ query,
11
+ searchGrants,
12
+ grantDateFilter,
13
+ toggleGrantDateFilter,
14
+ }) => {
15
+ const { formatMessage } = useIntl();
16
+
17
+ return (
18
+ <Input
19
+ value={query}
20
+ onChange={(_e, data) => searchGrants({ query: data.value })}
21
+ iconPosition="left"
22
+ action
23
+ placeholder={formatMessage({ id: "structures.search.placeholder" })}
24
+ >
25
+ <Icon name="search" link />
26
+ <input />
27
+ <Button
28
+ icon="calendar alternate outline"
29
+ active={grantDateFilter?.active}
30
+ onClick={() => toggleGrantDateFilter()}
31
+ />
32
+ <GrantFilters />
33
+ </Input>
34
+ );
35
+ };
36
+
37
+ GrantsSearch.propTypes = {
38
+ query: PropTypes.string,
39
+ searchGrants: PropTypes.func,
40
+ grantDateFilter: PropTypes.object,
41
+ toggleGrantDateFilter: PropTypes.func,
42
+ };
43
+
44
+ const mapStateToProps = ({ grantQuery }) => ({
45
+ query: grantQuery?.query,
46
+ });
47
+
48
+ export default connect(mapStateToProps, {
49
+ searchGrants,
50
+ toggleGrantDateFilter,
51
+ })(GrantsSearch);