@truedat/dd 5.15.2 → 5.16.3
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/package.json +5 -5
- package/src/api.js +6 -0
- package/src/components/GrantRequestApprovalResults.js +40 -0
- package/src/components/GrantRequestBulkActions.js +136 -0
- package/src/components/GrantRequestBulkApprovalForm.js +69 -0
- package/src/components/GrantRequestBulkApprovalPopup.js +43 -0
- package/src/components/GrantRequestBulkRoleSelector.js +41 -0
- package/src/components/GrantRequestRow.js +62 -0
- package/src/components/GrantRequestSearchFilters.js +22 -0
- package/src/components/GrantRequestsFiltersLoader.js +33 -0
- package/src/components/GrantRequestsLabelResults.js +52 -0
- package/src/components/GrantRequestsSearch.js +35 -0
- package/src/components/GrantRequestsSearchLoader.js +47 -0
- package/src/components/GrantRequestsSearchResults.js +156 -0
- package/src/components/GrantRequestsSelectedFilters.js +54 -0
- package/src/components/GrantRequestsTable.js +131 -0
- package/src/components/GrantRoutes.js +34 -16
- package/src/components/Grants.js +1 -0
- package/src/components/__tests__/GrantRequestApprovalResults.spec.js +30 -0
- package/src/components/__tests__/GrantRequestBulkActions.spec.js +31 -0
- package/src/components/__tests__/GrantRequestBulkApprovalForm.spec.js +54 -0
- package/src/components/__tests__/GrantRequestBulkApprovalPopup.spec.js +17 -0
- package/src/components/__tests__/GrantRequestBulkRoleSelector.spec.js +48 -0
- package/src/components/__tests__/GrantRequestFiltersLoader.spec.js +20 -0
- package/src/components/__tests__/GrantRequestRow.spec.js +95 -0
- package/src/components/__tests__/GrantRequestSearchFilters.spec.js +19 -0
- package/src/components/__tests__/GrantRequestsLabelResults.spec.js +45 -0
- package/src/components/__tests__/GrantRequestsSearch.spec.js +23 -0
- package/src/components/__tests__/GrantRequestsSearchLoader.spec.js +15 -0
- package/src/components/__tests__/GrantRequestsSearchResults.spec.js +59 -0
- package/src/components/__tests__/GrantRequestsTable.spec.js +35 -0
- package/src/components/__tests__/__snapshots__/GrantRequestApprovalResults.spec.js.snap +69 -0
- package/src/components/__tests__/__snapshots__/GrantRequestBulkActions.spec.js.snap +51 -0
- package/src/components/__tests__/__snapshots__/GrantRequestBulkApprovalForm.spec.js.snap +41 -0
- package/src/components/__tests__/__snapshots__/GrantRequestBulkApprovalPopup.spec.js.snap +11 -0
- package/src/components/__tests__/__snapshots__/GrantRequestBulkRoleSelector.spec.js.snap +56 -0
- package/src/components/__tests__/__snapshots__/GrantRequestRow.spec.js.snap +55 -0
- package/src/components/__tests__/__snapshots__/GrantRequestSearchFilters.spec.js.snap +47 -0
- package/src/components/__tests__/__snapshots__/GrantRequestsLabelResults.spec.js.snap +36 -0
- package/src/components/__tests__/__snapshots__/GrantRequestsSearch.spec.js.snap +50 -0
- package/src/components/__tests__/__snapshots__/GrantRequestsSearchLoader.spec.js.snap +3 -0
- package/src/components/__tests__/__snapshots__/GrantRequestsSearchResults.spec.js.snap +248 -0
- package/src/components/__tests__/__snapshots__/GrantRequestsTable.spec.js.snap +19 -0
- package/src/components/__tests__/__snapshots__/GrantRoutes.spec.js.snap +0 -4
- package/src/components/index.js +8 -0
- package/src/hooks/useGrantRequest.js +9 -0
- package/src/reducers/__tests__/grantRequestCount.spec.js +38 -0
- package/src/reducers/__tests__/grantRequestPermissions.spec.js +66 -0
- package/src/reducers/__tests__/grantRequestsActiveFilters.spec.js +90 -0
- package/src/reducers/__tests__/grantRequestsFiltersLoading.spec.js +34 -0
- package/src/reducers/__tests__/grantRequestsSearch.spec.js +38 -0
- package/src/reducers/__tests__/grantRequestsSearchLoading.spec.js +36 -0
- package/src/reducers/__tests__/grantRequestsSearchQuery.spec.js +96 -0
- package/src/reducers/__tests__/grantRequestsSelectedFilter.spec.js +72 -0
- package/src/reducers/grantRequestCount.js +23 -0
- package/src/reducers/grantRequestPermissions.js +31 -0
- package/src/reducers/grantRequestSearchQuery.js +55 -0
- package/src/reducers/grantRequestsActiveFilters.js +56 -0
- package/src/reducers/grantRequestsFilters.js +23 -0
- package/src/reducers/grantRequestsFiltersLoading.js +14 -0
- package/src/reducers/grantRequestsSearch.js +19 -0
- package/src/reducers/grantRequestsSearchLoading.js +14 -0
- package/src/reducers/grantRequestsSelectedFilter.js +34 -0
- package/src/reducers/graphLoading.js +2 -0
- package/src/reducers/index.js +22 -0
- package/src/reducers/structureRedirect.js +2 -3
- package/src/routines.js +13 -0
- package/src/sagas/__tests__/createGraph.spec.js +4 -4
- package/src/sagas/__tests__/fetchGrantRequestsFilters.spec.js +91 -0
- package/src/sagas/__tests__/fetchGrantRequestsSearch.spec.js +92 -0
- package/src/sagas/createGraph.js +7 -71
- package/src/sagas/fetchGrantRequestsFilters.js +32 -0
- package/src/sagas/fetchGrantRequestsSearch.js +30 -0
- package/src/sagas/fetchGraph.js +26 -4
- package/src/sagas/graph/polling.js +70 -0
- package/src/sagas/index.js +6 -0
- package/src/selectors/__tests__/getGrantRequestsAvailableFilters.spec.js +15 -0
- package/src/selectors/__tests__/getGrantRequestsFilterTypes.spec.js +19 -0
- package/src/selectors/__tests__/getGrantRequestsSearchColumns.spec.js +30 -0
- package/src/selectors/__tests__/getGrantRequestsSearchQuery.spec.js +24 -0
- package/src/selectors/__tests__/getGrantRequestsSelectedFilterActiveValues.spec.js +15 -0
- package/src/selectors/__tests__/getGrantRequestsSelectedFilterValues.spec.js +15 -0
- package/src/selectors/__tests__/getGrantRequestsSelectedFilters.spec.js +13 -0
- package/src/selectors/getGrantRequestsAvailableFilters.js +17 -0
- package/src/selectors/getGrantRequestsFilterTypes.js +7 -0
- package/src/selectors/getGrantRequestsSearchColumns.js +119 -0
- package/src/selectors/getGrantRequestsSearchQuery.js +19 -0
- package/src/selectors/getGrantRequestsSelectedFilterActiveValues.js +8 -0
- package/src/selectors/getGrantRequestsSelectedFilterValues.js +12 -0
- package/src/selectors/getGrantRequestsSelectedFilters.js +8 -0
- package/src/selectors/index.js +10 -0
- package/src/components/GrantRequestApprovals.js +0 -41
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import React, { useEffect, useState } from "react";
|
|
3
|
+
import { connect } from "react-redux";
|
|
4
|
+
import PropTypes from "prop-types";
|
|
5
|
+
import { Header, Icon, Segment, Dimmer, Loader } from "semantic-ui-react";
|
|
6
|
+
import { FormattedMessage } from "react-intl";
|
|
7
|
+
import { toggleGrantRequestsFilterValue } from "../routines";
|
|
8
|
+
import GrantRequestBulkActions from "./GrantRequestBulkActions";
|
|
9
|
+
import GrantRequestsSearch from "./GrantRequestsSearch";
|
|
10
|
+
import GrantRequestsSelectedFilters from "./GrantRequestsSelectedFilters";
|
|
11
|
+
import GrantRequestsTable from "./GrantRequestsTable";
|
|
12
|
+
import GrantRequestsLabelResults from "./GrantRequestsLabelResults";
|
|
13
|
+
|
|
14
|
+
export const GrantRequestsSearchResults = ({
|
|
15
|
+
grantRequests,
|
|
16
|
+
loading,
|
|
17
|
+
rolesPermission,
|
|
18
|
+
toggleGrantRequestsFilterValue,
|
|
19
|
+
defaultFilters,
|
|
20
|
+
}) => {
|
|
21
|
+
const [selectedGrantRequests, setSelectedGrantRequests] = useState([]);
|
|
22
|
+
const [roleSelected, setSelectedRole] = useState(null);
|
|
23
|
+
|
|
24
|
+
const onChangeRole = (role) => {
|
|
25
|
+
setSelectedRole(role);
|
|
26
|
+
toggleGrantRequestsFilterValue({
|
|
27
|
+
filter: "must_not_approved_by",
|
|
28
|
+
value: [role],
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (_.size(rolesPermission) == 1) {
|
|
34
|
+
onChangeRole(_.first(rolesPermission));
|
|
35
|
+
}
|
|
36
|
+
}, [rolesPermission]);
|
|
37
|
+
|
|
38
|
+
const allChecked = () => {
|
|
39
|
+
const ids = _.map(_.prop("id"))(grantRequests);
|
|
40
|
+
return (
|
|
41
|
+
_.negate(_.isEmpty)(selectedGrantRequests) &&
|
|
42
|
+
_.every((id) => _.includes(id)(selectedGrantRequests))(ids)
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const addAll = (_e, target) => {
|
|
47
|
+
const checkedAll = _.prop("checked")(target);
|
|
48
|
+
const ids = _.map(_.prop("id"))(grantRequests);
|
|
49
|
+
checkedAll
|
|
50
|
+
? setSelectedGrantRequests(
|
|
51
|
+
_.flow(_.concat(ids), _.uniq)(selectedGrantRequests)
|
|
52
|
+
)
|
|
53
|
+
: setSelectedGrantRequests(
|
|
54
|
+
_.flow(
|
|
55
|
+
_.difference(selectedGrantRequests),
|
|
56
|
+
_.uniq
|
|
57
|
+
)(selectedGrantRequests)
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const checkRow = (grantRequest) => {
|
|
62
|
+
const id = _.prop("id")(grantRequest);
|
|
63
|
+
const exists = _.some((selectedId) => _.eq(id, selectedId))(
|
|
64
|
+
selectedGrantRequests
|
|
65
|
+
);
|
|
66
|
+
exists
|
|
67
|
+
? setSelectedGrantRequests(
|
|
68
|
+
_.flow(
|
|
69
|
+
_.remove((selectedId) => _.eq(id, selectedId)),
|
|
70
|
+
_.uniq()
|
|
71
|
+
)(selectedGrantRequests)
|
|
72
|
+
)
|
|
73
|
+
: setSelectedGrantRequests(
|
|
74
|
+
_.flow(_.concat(id), _.uniq)(selectedGrantRequests)
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const isRowChecked = (grantRequest) => {
|
|
79
|
+
const id = _.prop("id")(grantRequest);
|
|
80
|
+
return _.some((selectedId) => _.eq(id, selectedId))(selectedGrantRequests);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const loadingDone =
|
|
84
|
+
_.size(rolesPermission) > 1 || (!loading && !_.isNull(roleSelected));
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<Segment>
|
|
88
|
+
<Header as="h2">
|
|
89
|
+
<Icon circular name="key" />
|
|
90
|
+
<Header.Content>
|
|
91
|
+
<FormattedMessage id={"grantRequests.header.approve"} />
|
|
92
|
+
<Header.Subheader>
|
|
93
|
+
<FormattedMessage id={"grantRequests.subheader.approve"} />
|
|
94
|
+
</Header.Subheader>
|
|
95
|
+
</Header.Content>
|
|
96
|
+
</Header>
|
|
97
|
+
|
|
98
|
+
<Segment attached="bottom">
|
|
99
|
+
<GrantRequestBulkActions
|
|
100
|
+
selectedGrantRequests={selectedGrantRequests}
|
|
101
|
+
rolesPermission={rolesPermission}
|
|
102
|
+
onChangeRole={onChangeRole}
|
|
103
|
+
roleSelected={roleSelected}
|
|
104
|
+
loading={loading}
|
|
105
|
+
cleanSelectedGrantRequests={() => setSelectedGrantRequests([])}
|
|
106
|
+
defaultFilters={defaultFilters}
|
|
107
|
+
zeroResults={_.isEmpty(grantRequests)}
|
|
108
|
+
/>
|
|
109
|
+
|
|
110
|
+
<GrantRequestsSearch />
|
|
111
|
+
<GrantRequestsSelectedFilters />
|
|
112
|
+
<Dimmer.Dimmable dimmed={loadingDone}>
|
|
113
|
+
<Dimmer active={loadingDone} inverted>
|
|
114
|
+
<Loader />
|
|
115
|
+
</Dimmer>
|
|
116
|
+
</Dimmer.Dimmable>
|
|
117
|
+
|
|
118
|
+
{loadingDone ? (
|
|
119
|
+
<>
|
|
120
|
+
<GrantRequestsLabelResults
|
|
121
|
+
roleSelected={roleSelected}
|
|
122
|
+
grantRequestToExecute={_.size(selectedGrantRequests)}
|
|
123
|
+
/>
|
|
124
|
+
<GrantRequestsTable
|
|
125
|
+
addAll={addAll}
|
|
126
|
+
checkedAll={allChecked()}
|
|
127
|
+
checkRow={checkRow}
|
|
128
|
+
isRowChecked={isRowChecked}
|
|
129
|
+
selectedGrantRequests={selectedGrantRequests}
|
|
130
|
+
roleSelected={roleSelected}
|
|
131
|
+
/>
|
|
132
|
+
</>
|
|
133
|
+
) : null}
|
|
134
|
+
</Segment>
|
|
135
|
+
</Segment>
|
|
136
|
+
);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
GrantRequestsSearchResults.propTypes = {
|
|
140
|
+
grantRequests: PropTypes.array,
|
|
141
|
+
loading: PropTypes.bool,
|
|
142
|
+
role: PropTypes.string,
|
|
143
|
+
rolesPermission: PropTypes.array,
|
|
144
|
+
defaultFilters: PropTypes.object,
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const mapStateToProps = (state) => ({
|
|
148
|
+
loading:
|
|
149
|
+
state.grantRequestsSearchLoading || state.grantRequestPermissionsLoading,
|
|
150
|
+
grantRequests: state.grantRequestsSearch,
|
|
151
|
+
rolesPermission: state.grantRequestPermissions,
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
export default connect(mapStateToProps, { toggleGrantRequestsFilterValue })(
|
|
155
|
+
GrantRequestsSearchResults
|
|
156
|
+
);
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
closeGrantRequestsFilter,
|
|
8
|
+
openGrantRequestsFilter,
|
|
9
|
+
removeGrantRequestsFilter,
|
|
10
|
+
resetGrantRequestsFilters,
|
|
11
|
+
toggleGrantRequestsFilterValue,
|
|
12
|
+
} from "../routines";
|
|
13
|
+
import {
|
|
14
|
+
getGrantRequestsSelectedFilterActiveValues,
|
|
15
|
+
getGrantRequestsSelectedFilters,
|
|
16
|
+
getGrantRequestsSelectedFilterValues,
|
|
17
|
+
getGrantRequestsFilterTypes,
|
|
18
|
+
} from "../selectors";
|
|
19
|
+
|
|
20
|
+
export const mapStateToProps = (state) => {
|
|
21
|
+
const {
|
|
22
|
+
grantRequestsFiltersLoading: loading,
|
|
23
|
+
grantRequestsSelectedFilter: selectedFilter,
|
|
24
|
+
} = state;
|
|
25
|
+
|
|
26
|
+
const i18nValues = _.flow(
|
|
27
|
+
getGrantRequestsSelectedFilterValues,
|
|
28
|
+
_.map(makeOption({}, selectedFilter))
|
|
29
|
+
)(state);
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
loading,
|
|
33
|
+
filterTypes: getGrantRequestsFilterTypes(state),
|
|
34
|
+
selectedFilter,
|
|
35
|
+
selectedFilters: getGrantRequestsSelectedFilters(state),
|
|
36
|
+
selectedFilterActiveValues:
|
|
37
|
+
getGrantRequestsSelectedFilterActiveValues(state),
|
|
38
|
+
selectedFilterValues: i18nValues,
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const mapDispatchToProps = (dispatch) =>
|
|
43
|
+
bindActionCreators(
|
|
44
|
+
{
|
|
45
|
+
closeFilter: closeGrantRequestsFilter,
|
|
46
|
+
openFilter: openGrantRequestsFilter,
|
|
47
|
+
removeFilter: removeGrantRequestsFilter,
|
|
48
|
+
resetFilters: resetGrantRequestsFilters,
|
|
49
|
+
toggleFilterValue: toggleGrantRequestsFilterValue,
|
|
50
|
+
},
|
|
51
|
+
dispatch
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
export default connect(mapStateToProps, mapDispatchToProps)(SelectedFilters);
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import React, { useEffect, useState } from "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import { connect } from "react-redux";
|
|
5
|
+
import { useIntl } from "react-intl";
|
|
6
|
+
import { getSortInfo, sortColumn } from "@truedat/core/services/sort";
|
|
7
|
+
import { Checkbox, Table, Header, Icon } from "semantic-ui-react";
|
|
8
|
+
import { sortGrantRequests } from "../routines";
|
|
9
|
+
import { getGrantRequestsSearchColumns } from "../selectors";
|
|
10
|
+
import { GrantRequestRow } from "./GrantRequestRow";
|
|
11
|
+
|
|
12
|
+
export const GrantRequestsTable = ({
|
|
13
|
+
addAll,
|
|
14
|
+
checkedAll,
|
|
15
|
+
checkRow,
|
|
16
|
+
isRowChecked,
|
|
17
|
+
grantRequests,
|
|
18
|
+
grantRequestsSearchLoading,
|
|
19
|
+
columns,
|
|
20
|
+
grantRequestsSort,
|
|
21
|
+
sortGrantRequests,
|
|
22
|
+
roleSelected,
|
|
23
|
+
}) => {
|
|
24
|
+
const { formatMessage } = useIntl();
|
|
25
|
+
|
|
26
|
+
const [sortedColumn, setColumn] = useState(
|
|
27
|
+
_.prop("column")(getSortInfo(grantRequestsSort))
|
|
28
|
+
);
|
|
29
|
+
const [direction, setDirection] = useState(
|
|
30
|
+
_.prop("direction")(getSortInfo(grantRequestsSort))
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
const { column: sortedColumn, direction: direction } =
|
|
35
|
+
getSortInfo(grantRequestsSort);
|
|
36
|
+
setColumn(sortedColumn);
|
|
37
|
+
setDirection(direction);
|
|
38
|
+
}, [grantRequestsSort]);
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<>
|
|
42
|
+
{!_.isEmpty(grantRequests) ? (
|
|
43
|
+
<Table sortable>
|
|
44
|
+
<Table.Header>
|
|
45
|
+
<Table.Row>
|
|
46
|
+
{roleSelected ? (
|
|
47
|
+
<Table.HeaderCell textAlign="center">
|
|
48
|
+
<Checkbox
|
|
49
|
+
id="selectGrantRequest"
|
|
50
|
+
onChange={addAll}
|
|
51
|
+
checked={checkedAll}
|
|
52
|
+
/>
|
|
53
|
+
</Table.HeaderCell>
|
|
54
|
+
) : null}
|
|
55
|
+
{columns.map((column, key) => (
|
|
56
|
+
<Table.HeaderCell
|
|
57
|
+
key={key}
|
|
58
|
+
width={column.width}
|
|
59
|
+
content={formatMessage({
|
|
60
|
+
id: `grantRequest.header.${column.name}`,
|
|
61
|
+
defaultMessage: column.name,
|
|
62
|
+
})}
|
|
63
|
+
sorted={
|
|
64
|
+
_.path("sort.name")(column) === sortedColumn
|
|
65
|
+
? direction
|
|
66
|
+
: null
|
|
67
|
+
}
|
|
68
|
+
className={_.path("sort.name")(column) ? "" : "disabled"}
|
|
69
|
+
onClick={() => {
|
|
70
|
+
sortColumn(
|
|
71
|
+
column,
|
|
72
|
+
sortGrantRequests,
|
|
73
|
+
setDirection,
|
|
74
|
+
setColumn,
|
|
75
|
+
direction,
|
|
76
|
+
sortedColumn
|
|
77
|
+
);
|
|
78
|
+
}}
|
|
79
|
+
/>
|
|
80
|
+
))}
|
|
81
|
+
</Table.Row>
|
|
82
|
+
</Table.Header>
|
|
83
|
+
<Table.Body>
|
|
84
|
+
{grantRequests.map((gr, key) => (
|
|
85
|
+
<GrantRequestRow
|
|
86
|
+
roleSelected={roleSelected}
|
|
87
|
+
key={key}
|
|
88
|
+
checked={isRowChecked && isRowChecked(gr)}
|
|
89
|
+
grantRequest={gr}
|
|
90
|
+
columns={columns}
|
|
91
|
+
onChange={() => checkRow && checkRow(gr)}
|
|
92
|
+
/>
|
|
93
|
+
))}
|
|
94
|
+
</Table.Body>
|
|
95
|
+
</Table>
|
|
96
|
+
) : null}
|
|
97
|
+
{_.isEmpty(grantRequests) && !grantRequestsSearchLoading ? (
|
|
98
|
+
<Header as="h4">
|
|
99
|
+
<Icon name="search" />
|
|
100
|
+
<Header.Content>
|
|
101
|
+
{formatMessage({ id: "grantRequests.empty" })}
|
|
102
|
+
</Header.Content>
|
|
103
|
+
</Header>
|
|
104
|
+
) : null}
|
|
105
|
+
</>
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
GrantRequestsTable.propTypes = {
|
|
110
|
+
addAll: PropTypes.func,
|
|
111
|
+
checkedAll: PropTypes.bool,
|
|
112
|
+
checkRow: PropTypes.func,
|
|
113
|
+
isRowChecked: PropTypes.func,
|
|
114
|
+
grantRequestsSort: PropTypes.array,
|
|
115
|
+
columns: PropTypes.array,
|
|
116
|
+
grantRequests: PropTypes.array,
|
|
117
|
+
sortGrantRequests: PropTypes.func,
|
|
118
|
+
grantRequestsSearchLoading: PropTypes.bool,
|
|
119
|
+
roleSelected: PropTypes.string,
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const mapStateToProps = (state) => ({
|
|
123
|
+
columns: getGrantRequestsSearchColumns(state),
|
|
124
|
+
grantRequests: state.grantRequestsSearch,
|
|
125
|
+
grantRequestsSearchLoading: state.grantRequestsSearchLoading,
|
|
126
|
+
grantRequestsSort: _.path("grantRequestSearchQuery.sort")(state),
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
export default connect(mapStateToProps, { sortGrantRequests })(
|
|
130
|
+
GrantRequestsTable
|
|
131
|
+
);
|
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
GRANT_APPROVAL_RULE,
|
|
8
8
|
GRANT_APPROVAL_RULE_EDIT,
|
|
9
9
|
GRANT_APPROVAL_RULE_NEW,
|
|
10
|
-
GRANT_REQUEST_APPROVALS,
|
|
11
10
|
GRANT_REQUEST,
|
|
12
11
|
GRANT_REQUESTS,
|
|
12
|
+
GRANT_REQUESTS_APPROVALS_RESULT,
|
|
13
13
|
GRANTS_REQUESTS_CHECKOUT,
|
|
14
14
|
GRANTS,
|
|
15
15
|
GRANT,
|
|
@@ -25,9 +25,11 @@ import GrantApprovalRuleNew from "./GrantApprovalRuleNew";
|
|
|
25
25
|
import GrantApprovalRules from "./GrantApprovalRules";
|
|
26
26
|
import GrantFiltersLoader from "./GrantFiltersLoader";
|
|
27
27
|
import GrantRequest from "./GrantRequest";
|
|
28
|
-
import GrantRequestApprovals from "./GrantRequestApprovals";
|
|
29
28
|
import GrantRequestLoader from "./GrantRequestLoader";
|
|
30
29
|
import GrantRequestsLoader from "./GrantRequestsLoader";
|
|
30
|
+
import GrantRequestsSearchResults from "./GrantRequestsSearchResults";
|
|
31
|
+
import GrantRequestApprovalResults from "./GrantRequestApprovalResults";
|
|
32
|
+
import GrantRequestsSearchLoader from "./GrantRequestsSearchLoader";
|
|
31
33
|
import Grants from "./Grants";
|
|
32
34
|
import GrantsLoader from "./GrantsLoader";
|
|
33
35
|
import MyGrantRequests from "./MyGrantRequests";
|
|
@@ -36,6 +38,7 @@ import StructuresGrantRequestView from "./StructuresGrantRequestView";
|
|
|
36
38
|
import StructuresLoader from "./StructuresLoader";
|
|
37
39
|
import StructureFiltersLoader from "./StructureFiltersLoader";
|
|
38
40
|
import UserSearchFiltersLoader from "./UserSearchFiltersLoader";
|
|
41
|
+
import GrantRequestsFiltersLoader from "./GrantRequestsFiltersLoader";
|
|
39
42
|
|
|
40
43
|
const RolesLoader = React.lazy(() =>
|
|
41
44
|
import("@truedat/auth/roles/components/RolesLoader")
|
|
@@ -81,20 +84,7 @@ export const GrantRoutes = ({ grantRequestLoaded }) => {
|
|
|
81
84
|
</>
|
|
82
85
|
)}
|
|
83
86
|
/>
|
|
84
|
-
|
|
85
|
-
path={GRANT_REQUEST_APPROVALS}
|
|
86
|
-
render={() => (
|
|
87
|
-
<>
|
|
88
|
-
<GrantRequestsLoader
|
|
89
|
-
defaultPayload={{
|
|
90
|
-
action: "approve",
|
|
91
|
-
status: "pending",
|
|
92
|
-
}}
|
|
93
|
-
/>
|
|
94
|
-
<GrantRequestApprovals />
|
|
95
|
-
</>
|
|
96
|
-
)}
|
|
97
|
-
/>
|
|
87
|
+
|
|
98
88
|
<Route
|
|
99
89
|
path={MY_GRANT_REQUESTS}
|
|
100
90
|
render={() => (
|
|
@@ -158,6 +148,34 @@ export const GrantRoutes = ({ grantRequestLoaded }) => {
|
|
|
158
148
|
render={() => (
|
|
159
149
|
<>
|
|
160
150
|
<Switch>
|
|
151
|
+
<Route
|
|
152
|
+
exact
|
|
153
|
+
path={GRANT_REQUESTS}
|
|
154
|
+
render={() => {
|
|
155
|
+
const defaultFilters = {
|
|
156
|
+
current_status: ["pending"],
|
|
157
|
+
};
|
|
158
|
+
return (
|
|
159
|
+
<>
|
|
160
|
+
<GrantRequestsSearchLoader
|
|
161
|
+
defaultFilters={defaultFilters}
|
|
162
|
+
/>
|
|
163
|
+
<GrantRequestsFiltersLoader
|
|
164
|
+
defaultFilters={defaultFilters}
|
|
165
|
+
/>
|
|
166
|
+
|
|
167
|
+
<GrantRequestsSearchResults
|
|
168
|
+
defaultFilters={defaultFilters}
|
|
169
|
+
/>
|
|
170
|
+
</>
|
|
171
|
+
);
|
|
172
|
+
}}
|
|
173
|
+
/>
|
|
174
|
+
<Route
|
|
175
|
+
path={GRANT_REQUESTS_APPROVALS_RESULT}
|
|
176
|
+
exact
|
|
177
|
+
render={() => <GrantRequestApprovalResults />}
|
|
178
|
+
/>
|
|
161
179
|
<Route
|
|
162
180
|
path={GRANT_REQUEST}
|
|
163
181
|
render={() => (
|
package/src/components/Grants.js
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import GrantRequestApprovalResults from "../GrantRequestApprovalResults";
|
|
4
|
+
|
|
5
|
+
describe("<GrantRequestApprovalResults />", () => {
|
|
6
|
+
const renderOpts = {
|
|
7
|
+
messages: {
|
|
8
|
+
en: {
|
|
9
|
+
"grantRequests.header.approve": "approve",
|
|
10
|
+
"grantRequests.header.approve.results": "results",
|
|
11
|
+
"grant_request.bulk_approval.content": "content",
|
|
12
|
+
"grant_request.bulk_approval.approved.header": "header",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
it("matches the latest snapshot", () => {
|
|
18
|
+
const { container } = render(<GrantRequestApprovalResults />, renderOpts);
|
|
19
|
+
expect(container).toMatchSnapshot();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("with is rejection ", () => {
|
|
23
|
+
jest.mock("react-router-dom", () => ({
|
|
24
|
+
...jest.requireActual("react-router-dom"),
|
|
25
|
+
useLocation: () => ({ state: [{ is_rejection: true }] }),
|
|
26
|
+
}));
|
|
27
|
+
const { container } = render(<GrantRequestApprovalResults />, renderOpts);
|
|
28
|
+
expect(container).toMatchSnapshot();
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import GrantRequestBulkActions from "../GrantRequestBulkActions";
|
|
4
|
+
|
|
5
|
+
describe("<GrantRequestBulkActions />", () => {
|
|
6
|
+
const cleanSelectedGrantRequests = jest.fn();
|
|
7
|
+
const props = {
|
|
8
|
+
cleanSelectedGrantRequests,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const renderOpts = {
|
|
12
|
+
messages: {
|
|
13
|
+
en: {
|
|
14
|
+
"grantRequestApproval.form.role.select": "select",
|
|
15
|
+
"grantRequest.actions.reject": "reject",
|
|
16
|
+
"grantRequest.actions.approve": "approve_request",
|
|
17
|
+
"grantRequestApproval.form.comment.label": "label",
|
|
18
|
+
"grantRequestApproval.form.comment.placeholder": "placeholder",
|
|
19
|
+
"grantRequestApproval.form.approve": "approve_request",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
it("matches the latest snapshot", () => {
|
|
25
|
+
const { container } = render(
|
|
26
|
+
<GrantRequestBulkActions {...props} />,
|
|
27
|
+
renderOpts
|
|
28
|
+
);
|
|
29
|
+
expect(container).toMatchSnapshot();
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { waitFor } from "@testing-library/react";
|
|
3
|
+
import { render } from "@truedat/test/render";
|
|
4
|
+
import userEvent from "@testing-library/user-event";
|
|
5
|
+
import GrantRequestBulkApprovalForm from "../GrantRequestBulkApprovalForm";
|
|
6
|
+
|
|
7
|
+
describe("<GrantRequestBulkApprovalForm />", () => {
|
|
8
|
+
const renderOpts = {
|
|
9
|
+
messages: {
|
|
10
|
+
en: {
|
|
11
|
+
"grantRequest.actions.reject": "reject",
|
|
12
|
+
"grantRequest.actions.approve": "approve",
|
|
13
|
+
"grantRequestApproval.form.comment.label": "label",
|
|
14
|
+
"grantRequestApproval.form.comment.placeholder": "placeholder",
|
|
15
|
+
"grantRequestApproval.form.approve": "approve",
|
|
16
|
+
"grantRequestApproval.form.reject": "reject",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
it("matches the latest snapshot", () => {
|
|
22
|
+
const props = {
|
|
23
|
+
isRejection: true,
|
|
24
|
+
};
|
|
25
|
+
const { container } = render(
|
|
26
|
+
<GrantRequestBulkApprovalForm {...props} />,
|
|
27
|
+
renderOpts
|
|
28
|
+
);
|
|
29
|
+
expect(container).toMatchSnapshot();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("test approve grant_request functionality", async () => {
|
|
33
|
+
const onSubmit = jest.fn();
|
|
34
|
+
const props = {
|
|
35
|
+
isRejection: true,
|
|
36
|
+
onSubmit,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const { getByRole } = render(
|
|
40
|
+
<GrantRequestBulkApprovalForm {...props} />,
|
|
41
|
+
renderOpts
|
|
42
|
+
);
|
|
43
|
+
await waitFor(() => {
|
|
44
|
+
expect(getByRole("button", { name: "reject" })).toBeEnabled();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// submit
|
|
48
|
+
await waitFor(() => {
|
|
49
|
+
userEvent.click(getByRole("button", { name: "reject" }));
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
await waitFor(() => expect(onSubmit).toBeCalledTimes(1));
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import GrantRequestBulkApprovalPopup from "../GrantRequestBulkApprovalPopup";
|
|
4
|
+
|
|
5
|
+
describe("<GrantRequestBulkApprovalPopup />", () => {
|
|
6
|
+
const onSubmit = jest.fn();
|
|
7
|
+
const props = {
|
|
8
|
+
onSubmit,
|
|
9
|
+
isRejection: false,
|
|
10
|
+
content: "button content",
|
|
11
|
+
primary: true,
|
|
12
|
+
};
|
|
13
|
+
it("matches the latest snapshot", () => {
|
|
14
|
+
const { container } = render(<GrantRequestBulkApprovalPopup {...props} />);
|
|
15
|
+
expect(container).toMatchSnapshot();
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { waitFor } from "@testing-library/react";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
4
|
+
import { render } from "@truedat/test/render";
|
|
5
|
+
|
|
6
|
+
import GrantRequestBulkRoleSelector from "../GrantRequestBulkRoleSelector";
|
|
7
|
+
|
|
8
|
+
describe("<GrantRequestBulkRoleSelector />", () => {
|
|
9
|
+
const onChange = jest.fn();
|
|
10
|
+
const props = {
|
|
11
|
+
roles: ["foo", "bar"],
|
|
12
|
+
disabled: false,
|
|
13
|
+
onChange,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const renderOpts = {
|
|
17
|
+
messages: {
|
|
18
|
+
en: {
|
|
19
|
+
"grantRequestApproval.form.role.select": "select",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
it("matches the latest snapshot", () => {
|
|
25
|
+
const { container } = render(
|
|
26
|
+
<GrantRequestBulkRoleSelector {...props} />,
|
|
27
|
+
renderOpts
|
|
28
|
+
);
|
|
29
|
+
expect(container).toMatchSnapshot();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("test select role", async () => {
|
|
33
|
+
const { getByRole } = render(
|
|
34
|
+
<GrantRequestBulkRoleSelector {...props} />,
|
|
35
|
+
renderOpts
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
await waitFor(() => {
|
|
39
|
+
expect(getByRole("option", { name: /bar/i })).toBeTruthy();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
userEvent.click(getByRole("option", { name: /bar/i }));
|
|
43
|
+
|
|
44
|
+
await waitFor(() => {
|
|
45
|
+
expect(onChange).toHaveBeenCalledWith("bar");
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { makeMapStateToProps } from "../GrantRequestsFiltersLoader";
|
|
2
|
+
|
|
3
|
+
describe("makeMapStateToProps", () => {
|
|
4
|
+
const defaultFilters = { status: ["draft"] };
|
|
5
|
+
const mapStateToProps = makeMapStateToProps({});
|
|
6
|
+
|
|
7
|
+
it("returns a function which selects a combination of active and default filters", () => {
|
|
8
|
+
const state = {
|
|
9
|
+
grantRequestsActiveFilters: { foo: ["bar"] },
|
|
10
|
+
grantRequestsSelectedFilter: "status",
|
|
11
|
+
};
|
|
12
|
+
const props = { defaultFilters };
|
|
13
|
+
|
|
14
|
+
expect(mapStateToProps(state, props)).toEqual({
|
|
15
|
+
filters: { status: ["draft"], foo: ["bar"] },
|
|
16
|
+
selectedFilter: "status",
|
|
17
|
+
defaultFilters,
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
});
|