@truedat/dd 6.6.3 → 6.6.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.
- package/package.json +6 -6
- package/src/components/GrantRequest.js +0 -12
- package/src/components/GrantRequestBulkActions.js +6 -3
- package/src/components/GrantRequestPagination.js +18 -0
- package/src/components/GrantRequestRow.js +4 -2
- package/src/components/GrantRequestSearchFilters.js +1 -0
- package/src/components/GrantRequestsSearchLoader.js +1 -1
- package/src/components/GrantRequestsSearchResults.js +47 -13
- package/src/components/GrantRequestsSelectedFilters.js +1 -0
- package/src/components/GrantRequestsTable.js +10 -7
- package/src/components/GrantRoutes.js +2 -3
- package/src/components/__tests__/GrantRequestBulkActions.spec.js +14 -0
- package/src/components/__tests__/GrantRequestRow.spec.js +17 -0
- package/src/components/__tests__/GrantRequestsSearchResults.spec.js +4 -3
- package/src/components/__tests__/GrantRequestsTable.spec.js +1 -0
- package/src/components/__tests__/__snapshots__/GrantRequestRow.spec.js.snap +34 -0
- package/src/components/__tests__/__snapshots__/GrantRequestsSearchResults.spec.js.snap +42 -1
- package/src/components/index.js +2 -0
- package/src/reducers/__tests__/grantRequestPageSize.spec.js +36 -0
- package/src/reducers/__tests__/grantRequestsSearchQuery.spec.js +1 -1
- package/src/reducers/grantRequestPageSize.js +15 -0
- package/src/reducers/grantRequestSearchQuery.js +7 -2
- package/src/reducers/grantRequestsActiveFilters.js +3 -1
- package/src/reducers/index.js +3 -0
- package/src/routines.js +2 -0
- package/src/selectors/getGrantRequestsSearchColumns.js +13 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/dd",
|
|
3
|
-
"version": "6.6.
|
|
3
|
+
"version": "6.6.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.16.5",
|
|
35
35
|
"@testing-library/react": "^12.0.0",
|
|
36
36
|
"@testing-library/user-event": "^13.2.1",
|
|
37
|
-
"@truedat/test": "6.6.
|
|
37
|
+
"@truedat/test": "6.6.5",
|
|
38
38
|
"babel-jest": "^28.1.0",
|
|
39
39
|
"babel-plugin-dynamic-import-node": "^2.3.3",
|
|
40
40
|
"babel-plugin-lodash": "^3.3.4",
|
|
@@ -88,9 +88,9 @@
|
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
90
|
"@apollo/client": "^3.7.1",
|
|
91
|
-
"@truedat/auth": "6.6.
|
|
92
|
-
"@truedat/core": "6.6.
|
|
93
|
-
"@truedat/df": "6.6.
|
|
91
|
+
"@truedat/auth": "6.6.5",
|
|
92
|
+
"@truedat/core": "6.6.5",
|
|
93
|
+
"@truedat/df": "6.6.5",
|
|
94
94
|
"lodash": "^4.17.21",
|
|
95
95
|
"moment": "^2.29.4",
|
|
96
96
|
"path-to-regexp": "^1.7.0",
|
|
@@ -115,5 +115,5 @@
|
|
|
115
115
|
"react-dom": ">= 16.8.6 < 17",
|
|
116
116
|
"semantic-ui-react": ">= 2.0.3 < 2.2"
|
|
117
117
|
},
|
|
118
|
-
"gitHead": "
|
|
118
|
+
"gitHead": "875dcb0716cc64d30974106dc64c861d4306fcd6"
|
|
119
119
|
}
|
|
@@ -19,7 +19,6 @@ const ConditionSummary = React.lazy(() =>
|
|
|
19
19
|
import("@truedat/dq/components/ConditionSummary")
|
|
20
20
|
);
|
|
21
21
|
|
|
22
|
-
|
|
23
22
|
export const GrantRequest = ({ grantRequest, template }) => {
|
|
24
23
|
const { formatMessage } = useIntl();
|
|
25
24
|
const metadata = grantRequest?.metadata;
|
|
@@ -100,17 +99,6 @@ export const GrantRequest = ({ grantRequest, template }) => {
|
|
|
100
99
|
})}
|
|
101
100
|
</Label>
|
|
102
101
|
</List.Description>
|
|
103
|
-
{grantRequest?.status_reason && (
|
|
104
|
-
<span
|
|
105
|
-
style={{
|
|
106
|
-
color: "red",
|
|
107
|
-
fontSize: "12px",
|
|
108
|
-
marginLeft: "10px",
|
|
109
|
-
}}
|
|
110
|
-
>
|
|
111
|
-
{grantRequest?.status_reason}
|
|
112
|
-
</span>
|
|
113
|
-
)}
|
|
114
102
|
</List.Item>
|
|
115
103
|
</List>
|
|
116
104
|
{metadata && template && (
|
|
@@ -29,6 +29,7 @@ export const GrantRequestBulkActions = ({
|
|
|
29
29
|
query,
|
|
30
30
|
cleanSelectedGrantRequests,
|
|
31
31
|
zeroResults,
|
|
32
|
+
canApprove,
|
|
32
33
|
}) => {
|
|
33
34
|
const history = useHistory();
|
|
34
35
|
const [saving, setSaving] = useState();
|
|
@@ -70,7 +71,7 @@ export const GrantRequestBulkActions = ({
|
|
|
70
71
|
<Grid.Column width={4} textAlign="right">
|
|
71
72
|
<GrantRequestBulkRoleSelector
|
|
72
73
|
roles={rolesPermission}
|
|
73
|
-
disabled={_.size(rolesPermission) == 1}
|
|
74
|
+
disabled={_.size(rolesPermission) == 1 || !canApprove}
|
|
74
75
|
selectedRole={roleSelected}
|
|
75
76
|
onChange={onChangeRole}
|
|
76
77
|
/>
|
|
@@ -82,7 +83,8 @@ export const GrantRequestBulkActions = ({
|
|
|
82
83
|
_.isNull(roleSelected) ||
|
|
83
84
|
loading ||
|
|
84
85
|
zeroResults ||
|
|
85
|
-
_.size(selectedGrantRequests) == 0
|
|
86
|
+
_.size(selectedGrantRequests) == 0 ||
|
|
87
|
+
!canApprove
|
|
86
88
|
}
|
|
87
89
|
loading={saving}
|
|
88
90
|
primary
|
|
@@ -95,7 +97,8 @@ export const GrantRequestBulkActions = ({
|
|
|
95
97
|
_.isNull(roleSelected) ||
|
|
96
98
|
loading ||
|
|
97
99
|
zeroResults ||
|
|
98
|
-
_.size(selectedGrantRequests) == 0
|
|
100
|
+
_.size(selectedGrantRequests) == 0 ||
|
|
101
|
+
!canApprove
|
|
99
102
|
}
|
|
100
103
|
loading={saving}
|
|
101
104
|
secondary
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { connect } from "react-redux";
|
|
2
|
+
import { bindActionCreators } from "redux";
|
|
3
|
+
import { Pagination } from "@truedat/core/components";
|
|
4
|
+
import { selectGrantRequestPage } from "../routines";
|
|
5
|
+
|
|
6
|
+
const mapDispatchToProps = (dispatch) =>
|
|
7
|
+
bindActionCreators({ selectPage: selectGrantRequestPage }, dispatch);
|
|
8
|
+
|
|
9
|
+
const mapStateToProps = ({
|
|
10
|
+
grantRequestsQuery,
|
|
11
|
+
grantRequestCount,
|
|
12
|
+
grantRequestPageSize,
|
|
13
|
+
}) => ({
|
|
14
|
+
activePage: grantRequestsQuery?.page,
|
|
15
|
+
totalPages: Math.ceil(grantRequestCount / grantRequestPageSize),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export default connect(mapStateToProps, mapDispatchToProps)(Pagination);
|
|
@@ -15,6 +15,7 @@ export const GrantRequestRow = ({
|
|
|
15
15
|
onChange,
|
|
16
16
|
grantRequest,
|
|
17
17
|
roleSelected,
|
|
18
|
+
canApprove,
|
|
18
19
|
}) => {
|
|
19
20
|
const history = useHistory();
|
|
20
21
|
const createdById = _.path("created_by_id")(grantRequest);
|
|
@@ -27,7 +28,7 @@ export const GrantRequestRow = ({
|
|
|
27
28
|
onClick={() => onClick && onClick(grantRequest)}
|
|
28
29
|
warning={createdById !== userId}
|
|
29
30
|
>
|
|
30
|
-
{roleSelected ? (
|
|
31
|
+
{roleSelected && canApprove ? (
|
|
31
32
|
<Table.Cell collapsing width="1" textAlign="center">
|
|
32
33
|
<Checkbox
|
|
33
34
|
id={grantRequest.id}
|
|
@@ -57,13 +58,14 @@ export const GrantRequestRow = ({
|
|
|
57
58
|
|
|
58
59
|
GrantRequestRow.propTypes = {
|
|
59
60
|
active: PropTypes.bool,
|
|
61
|
+
canApprove: PropTypes.bool,
|
|
60
62
|
checked: PropTypes.bool,
|
|
61
63
|
disabled: PropTypes.bool,
|
|
62
64
|
grantRequest: PropTypes.object,
|
|
65
|
+
roleSelected: PropTypes.string,
|
|
63
66
|
columns: PropTypes.array,
|
|
64
67
|
onChange: PropTypes.func,
|
|
65
68
|
onClick: PropTypes.func,
|
|
66
|
-
roleSelected: PropTypes.string,
|
|
67
69
|
};
|
|
68
70
|
|
|
69
71
|
export default GrantRequestRow;
|
|
@@ -36,7 +36,7 @@ const makeMapStateToProps = () => {
|
|
|
36
36
|
);
|
|
37
37
|
|
|
38
38
|
const mapStateToProps = (state, props) => ({
|
|
39
|
-
query: searchQuerySelector(state, { ...props, pageSize:
|
|
39
|
+
query: searchQuerySelector(state, { ...props, pageSize: 20 }),
|
|
40
40
|
});
|
|
41
41
|
return mapStateToProps;
|
|
42
42
|
};
|
|
@@ -4,37 +4,63 @@ import { connect } from "react-redux";
|
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
5
|
import { Header, Icon, Segment, Dimmer, Loader } from "semantic-ui-react";
|
|
6
6
|
import { FormattedMessage } from "react-intl";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
toggleGrantRequestsFilterValue,
|
|
9
|
+
removeGrantRequestsFilter,
|
|
10
|
+
} from "../routines";
|
|
8
11
|
import GrantRequestBulkActions from "./GrantRequestBulkActions";
|
|
9
12
|
import GrantRequestsSearch from "./GrantRequestsSearch";
|
|
10
13
|
import GrantRequestsSelectedFilters from "./GrantRequestsSelectedFilters";
|
|
11
14
|
import GrantRequestsTable from "./GrantRequestsTable";
|
|
12
15
|
import GrantRequestsLabelResults from "./GrantRequestsLabelResults";
|
|
16
|
+
import GrantRequestPagination from "./GrantRequestPagination";
|
|
13
17
|
|
|
14
18
|
export const GrantRequestsSearchResults = ({
|
|
15
19
|
grantRequests,
|
|
16
20
|
loading,
|
|
17
21
|
rolesPermission,
|
|
18
|
-
toggleGrantRequestsFilterValue,
|
|
19
22
|
defaultFilters,
|
|
23
|
+
activeFilters,
|
|
24
|
+
toggleGrantRequestsFilterValue,
|
|
25
|
+
removeGrantRequestsFilter,
|
|
20
26
|
}) => {
|
|
21
27
|
const [selectedGrantRequests, setSelectedGrantRequests] = useState([]);
|
|
22
28
|
const [roleSelected, setSelectedRole] = useState(null);
|
|
29
|
+
const [canApprove, setCanApprove] = useState(false);
|
|
23
30
|
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
toggleGrantRequestsFilterValue({
|
|
27
|
-
filter: "must_not_approved_by",
|
|
28
|
-
value: [role],
|
|
29
|
-
});
|
|
31
|
+
const isOnlyPending = (status) => {
|
|
32
|
+
return _.size(_.uniq(status)) === 1 && _.includes("pending", status);
|
|
30
33
|
};
|
|
31
34
|
|
|
32
35
|
useEffect(() => {
|
|
33
36
|
if (_.size(rolesPermission) == 1) {
|
|
34
|
-
|
|
37
|
+
setSelectedRole(_.first(rolesPermission));
|
|
35
38
|
}
|
|
36
39
|
}, [rolesPermission]);
|
|
37
40
|
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (canApprove && roleSelected) {
|
|
43
|
+
toggleGrantRequestsFilterValue({
|
|
44
|
+
filter: "must_not_approved_by",
|
|
45
|
+
value: [roleSelected],
|
|
46
|
+
});
|
|
47
|
+
} else {
|
|
48
|
+
removeGrantRequestsFilter({ filter: "must_not_approved_by" });
|
|
49
|
+
}
|
|
50
|
+
}, [canApprove, roleSelected]);
|
|
51
|
+
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
const canApprove = _.flow(
|
|
54
|
+
_.propOr([], "current_status"),
|
|
55
|
+
_.cond([
|
|
56
|
+
[_.isEmpty, _.negate(_.stubTrue)],
|
|
57
|
+
[isOnlyPending, _.stubTrue],
|
|
58
|
+
[_.stubTrue, _.negate(_.stubTrue)],
|
|
59
|
+
])
|
|
60
|
+
)(activeFilters);
|
|
61
|
+
setCanApprove(canApprove);
|
|
62
|
+
}, [activeFilters]);
|
|
63
|
+
|
|
38
64
|
const allChecked = () => {
|
|
39
65
|
const ids = _.map(_.prop("id"))(grantRequests);
|
|
40
66
|
return (
|
|
@@ -99,12 +125,13 @@ export const GrantRequestsSearchResults = ({
|
|
|
99
125
|
<GrantRequestBulkActions
|
|
100
126
|
selectedGrantRequests={selectedGrantRequests}
|
|
101
127
|
rolesPermission={rolesPermission}
|
|
102
|
-
onChangeRole={
|
|
128
|
+
onChangeRole={setSelectedRole}
|
|
103
129
|
roleSelected={roleSelected}
|
|
104
130
|
loading={loading}
|
|
105
131
|
cleanSelectedGrantRequests={() => setSelectedGrantRequests([])}
|
|
106
132
|
defaultFilters={defaultFilters}
|
|
107
133
|
zeroResults={_.isEmpty(grantRequests)}
|
|
134
|
+
canApprove={canApprove}
|
|
108
135
|
/>
|
|
109
136
|
|
|
110
137
|
<GrantRequestsSearch />
|
|
@@ -122,6 +149,7 @@ export const GrantRequestsSearchResults = ({
|
|
|
122
149
|
/>
|
|
123
150
|
<GrantRequestsTable
|
|
124
151
|
addAll={addAll}
|
|
152
|
+
canApprove={canApprove}
|
|
125
153
|
checkedAll={allChecked()}
|
|
126
154
|
checkRow={checkRow}
|
|
127
155
|
isRowChecked={isRowChecked}
|
|
@@ -130,6 +158,7 @@ export const GrantRequestsSearchResults = ({
|
|
|
130
158
|
/>
|
|
131
159
|
</>
|
|
132
160
|
) : null}
|
|
161
|
+
<GrantRequestPagination />
|
|
133
162
|
</Dimmer.Dimmable>
|
|
134
163
|
</Segment>
|
|
135
164
|
</Segment>
|
|
@@ -142,6 +171,9 @@ GrantRequestsSearchResults.propTypes = {
|
|
|
142
171
|
role: PropTypes.string,
|
|
143
172
|
rolesPermission: PropTypes.array,
|
|
144
173
|
defaultFilters: PropTypes.object,
|
|
174
|
+
activeFilters: PropTypes.object,
|
|
175
|
+
toggleGrantRequestsFilterValue: PropTypes.func,
|
|
176
|
+
removeGrantRequestsFilter: PropTypes.func,
|
|
145
177
|
};
|
|
146
178
|
|
|
147
179
|
const mapStateToProps = (state) => ({
|
|
@@ -149,8 +181,10 @@ const mapStateToProps = (state) => ({
|
|
|
149
181
|
state.grantRequestsSearchLoading || state.grantRequestPermissionsLoading,
|
|
150
182
|
grantRequests: state.grantRequestsSearch,
|
|
151
183
|
rolesPermission: state.grantRequestPermissions,
|
|
184
|
+
activeFilters: state.grantRequestsActiveFilters,
|
|
152
185
|
});
|
|
153
186
|
|
|
154
|
-
export default connect(mapStateToProps, {
|
|
155
|
-
|
|
156
|
-
|
|
187
|
+
export default connect(mapStateToProps, {
|
|
188
|
+
toggleGrantRequestsFilterValue,
|
|
189
|
+
removeGrantRequestsFilter,
|
|
190
|
+
})(GrantRequestsSearchResults);
|
|
@@ -20,6 +20,7 @@ export const GrantRequestsTable = ({
|
|
|
20
20
|
grantRequestsSort,
|
|
21
21
|
sortGrantRequests,
|
|
22
22
|
roleSelected,
|
|
23
|
+
canApprove,
|
|
23
24
|
}) => {
|
|
24
25
|
const { formatMessage } = useIntl();
|
|
25
26
|
|
|
@@ -43,7 +44,7 @@ export const GrantRequestsTable = ({
|
|
|
43
44
|
<Table sortable selectable>
|
|
44
45
|
<Table.Header>
|
|
45
46
|
<Table.Row>
|
|
46
|
-
{roleSelected ? (
|
|
47
|
+
{roleSelected && canApprove ? (
|
|
47
48
|
<Table.HeaderCell textAlign="center">
|
|
48
49
|
<Checkbox
|
|
49
50
|
id="selectGrantRequest"
|
|
@@ -88,6 +89,7 @@ export const GrantRequestsTable = ({
|
|
|
88
89
|
checked={isRowChecked && isRowChecked(gr)}
|
|
89
90
|
grantRequest={gr}
|
|
90
91
|
columns={columns}
|
|
92
|
+
canApprove={canApprove}
|
|
91
93
|
onChange={() => checkRow && checkRow(gr)}
|
|
92
94
|
/>
|
|
93
95
|
))}
|
|
@@ -107,16 +109,17 @@ export const GrantRequestsTable = ({
|
|
|
107
109
|
};
|
|
108
110
|
|
|
109
111
|
GrantRequestsTable.propTypes = {
|
|
110
|
-
|
|
112
|
+
columns: PropTypes.array,
|
|
113
|
+
grantRequests: PropTypes.array,
|
|
114
|
+
grantRequestsSort: PropTypes.array,
|
|
115
|
+
roleSelected: PropTypes.string,
|
|
116
|
+
canApprove: PropTypes.bool,
|
|
111
117
|
checkedAll: PropTypes.bool,
|
|
118
|
+
grantRequestsSearchLoading: PropTypes.bool,
|
|
119
|
+
addAll: PropTypes.func,
|
|
112
120
|
checkRow: PropTypes.func,
|
|
113
121
|
isRowChecked: PropTypes.func,
|
|
114
|
-
grantRequestsSort: PropTypes.array,
|
|
115
|
-
columns: PropTypes.array,
|
|
116
|
-
grantRequests: PropTypes.array,
|
|
117
122
|
sortGrantRequests: PropTypes.func,
|
|
118
|
-
grantRequestsSearchLoading: PropTypes.bool,
|
|
119
|
-
roleSelected: PropTypes.string,
|
|
120
123
|
};
|
|
121
124
|
|
|
122
125
|
const mapStateToProps = (state) => ({
|
|
@@ -150,14 +150,13 @@ export const GrantRoutes = ({ grantRequestLoaded }) => {
|
|
|
150
150
|
exact
|
|
151
151
|
path={GRANT_REQUESTS}
|
|
152
152
|
render={() => {
|
|
153
|
-
const defaultFilters = {
|
|
154
|
-
current_status: ["pending"],
|
|
155
|
-
};
|
|
153
|
+
const defaultFilters = {};
|
|
156
154
|
return (
|
|
157
155
|
<>
|
|
158
156
|
<GrantRequestsSearchLoader
|
|
159
157
|
defaultFilters={defaultFilters}
|
|
160
158
|
/>
|
|
159
|
+
|
|
161
160
|
<GrantRequestsFiltersLoader
|
|
162
161
|
defaultFilters={defaultFilters}
|
|
163
162
|
/>
|
|
@@ -6,6 +6,7 @@ describe("<GrantRequestBulkActions />", () => {
|
|
|
6
6
|
const cleanSelectedGrantRequests = jest.fn();
|
|
7
7
|
const props = {
|
|
8
8
|
cleanSelectedGrantRequests,
|
|
9
|
+
canApprove: true,
|
|
9
10
|
};
|
|
10
11
|
|
|
11
12
|
const renderOpts = {
|
|
@@ -28,4 +29,17 @@ describe("<GrantRequestBulkActions />", () => {
|
|
|
28
29
|
);
|
|
29
30
|
expect(container).toMatchSnapshot();
|
|
30
31
|
});
|
|
32
|
+
|
|
33
|
+
it("disable acctions when canApprove is false", () => {
|
|
34
|
+
const newProps = {
|
|
35
|
+
...props,
|
|
36
|
+
canApprove: false,
|
|
37
|
+
};
|
|
38
|
+
const { getByRole } = render(
|
|
39
|
+
<GrantRequestBulkActions {...newProps} />,
|
|
40
|
+
renderOpts
|
|
41
|
+
);
|
|
42
|
+
expect(getByRole("button", { name: /approve_request/i })).toBeDisabled();
|
|
43
|
+
expect(getByRole("button", { name: /reject/i })).toBeDisabled();
|
|
44
|
+
});
|
|
31
45
|
});
|
|
@@ -29,6 +29,7 @@ const grantRequest = {
|
|
|
29
29
|
path: ["DBO", "SWAPS"],
|
|
30
30
|
inserted_at: "2023-10-17T14:26:34.645189Z",
|
|
31
31
|
user: "blah",
|
|
32
|
+
current_status: "pending",
|
|
32
33
|
};
|
|
33
34
|
|
|
34
35
|
describe("<GrantRequestRow />", () => {
|
|
@@ -44,6 +45,7 @@ describe("<GrantRequestRow />", () => {
|
|
|
44
45
|
onChange,
|
|
45
46
|
grantRequest,
|
|
46
47
|
roleSelected: "foo",
|
|
48
|
+
canApprove: true,
|
|
47
49
|
};
|
|
48
50
|
|
|
49
51
|
it("matches the latest snapshot", () => {
|
|
@@ -57,6 +59,21 @@ describe("<GrantRequestRow />", () => {
|
|
|
57
59
|
expect(container).toMatchSnapshot();
|
|
58
60
|
});
|
|
59
61
|
|
|
62
|
+
it("disable checkbox when can not Approve", () => {
|
|
63
|
+
const newProps = {
|
|
64
|
+
...props,
|
|
65
|
+
canApprove: false,
|
|
66
|
+
};
|
|
67
|
+
const { container } = render(
|
|
68
|
+
<table>
|
|
69
|
+
<tbody>
|
|
70
|
+
<GrantRequestRow {...newProps} />
|
|
71
|
+
</tbody>
|
|
72
|
+
</table>
|
|
73
|
+
);
|
|
74
|
+
expect(container).toMatchSnapshot();
|
|
75
|
+
});
|
|
76
|
+
|
|
60
77
|
it("click on checkbox element", async () => {
|
|
61
78
|
const { getByText, getByRole } = render(
|
|
62
79
|
<table>
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { waitFor } from "@testing-library/react";
|
|
3
2
|
import userEvent from "@testing-library/user-event";
|
|
4
3
|
import { render } from "@truedat/test/render";
|
|
5
4
|
import GrantRequestsSearchResults from "../GrantRequestsSearchResults";
|
|
@@ -8,13 +7,14 @@ describe("<GrantRequestsSearchResults />", () => {
|
|
|
8
7
|
const grantRequests = [{ id: 1 }, { id: 2 }];
|
|
9
8
|
const toggleGrantRequestsFilterValue = jest.fn();
|
|
10
9
|
const rolesPermission = ["foo", "bar"];
|
|
11
|
-
const
|
|
10
|
+
const activeFilters = { current_status: ["pending"] };
|
|
12
11
|
|
|
13
12
|
const state = {
|
|
14
13
|
grantRequests,
|
|
15
14
|
grantRequestsSearch: grantRequests,
|
|
16
15
|
rolesPermission,
|
|
17
16
|
grantRequestPermissions: rolesPermission,
|
|
17
|
+
grantRequestsActiveFilters: activeFilters,
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
const renderOpts = (state) => ({
|
|
@@ -28,6 +28,8 @@ describe("<GrantRequestsSearchResults />", () => {
|
|
|
28
28
|
"grantRequests.header.approve": "header approve",
|
|
29
29
|
"grantRequests.bulk.selected": "selected",
|
|
30
30
|
"grantRequests.retrieved.results": "results",
|
|
31
|
+
"search.applied_filters": "Filters:",
|
|
32
|
+
"search.clear_filters": "Clear filters",
|
|
31
33
|
},
|
|
32
34
|
},
|
|
33
35
|
state: state,
|
|
@@ -37,7 +39,6 @@ describe("<GrantRequestsSearchResults />", () => {
|
|
|
37
39
|
loading: false,
|
|
38
40
|
rolesPermission,
|
|
39
41
|
toggleGrantRequestsFilterValue,
|
|
40
|
-
defaultFilters,
|
|
41
42
|
grantRequests,
|
|
42
43
|
};
|
|
43
44
|
|
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
+
exports[`<GrantRequestRow /> disable checkbox when can not Approve 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<table>
|
|
6
|
+
<tbody>
|
|
7
|
+
<tr
|
|
8
|
+
class="active warning"
|
|
9
|
+
>
|
|
10
|
+
<td
|
|
11
|
+
class=""
|
|
12
|
+
>
|
|
13
|
+
blah
|
|
14
|
+
</td>
|
|
15
|
+
<td
|
|
16
|
+
class=""
|
|
17
|
+
>
|
|
18
|
+
DBO
|
|
19
|
+
</td>
|
|
20
|
+
<td
|
|
21
|
+
class=""
|
|
22
|
+
>
|
|
23
|
+
DBO
|
|
24
|
+
SWAPS
|
|
25
|
+
</td>
|
|
26
|
+
<td
|
|
27
|
+
class=""
|
|
28
|
+
>
|
|
29
|
+
2023-10-17T14:26:34.645189Z
|
|
30
|
+
</td>
|
|
31
|
+
</tr>
|
|
32
|
+
</tbody>
|
|
33
|
+
</table>
|
|
34
|
+
</div>
|
|
35
|
+
`;
|
|
36
|
+
|
|
3
37
|
exports[`<GrantRequestRow /> matches the latest snapshot 1`] = `
|
|
4
38
|
<div>
|
|
5
39
|
<table>
|
|
@@ -144,7 +144,37 @@ exports[`<GrantRequestsSearchResults /> matches the latest snapshot 1`] = `
|
|
|
144
144
|
</div>
|
|
145
145
|
<div
|
|
146
146
|
class="selectedFilters"
|
|
147
|
-
|
|
147
|
+
>
|
|
148
|
+
<div
|
|
149
|
+
class="appliedFilters"
|
|
150
|
+
>
|
|
151
|
+
Filters:
|
|
152
|
+
</div>
|
|
153
|
+
<div
|
|
154
|
+
aria-expanded="false"
|
|
155
|
+
class="ui floating item scrolling dropdown"
|
|
156
|
+
role="listbox"
|
|
157
|
+
tabindex="0"
|
|
158
|
+
>
|
|
159
|
+
<div
|
|
160
|
+
class="ui label"
|
|
161
|
+
>
|
|
162
|
+
current_status
|
|
163
|
+
<i
|
|
164
|
+
aria-hidden="true"
|
|
165
|
+
class="delete icon"
|
|
166
|
+
/>
|
|
167
|
+
</div>
|
|
168
|
+
<div
|
|
169
|
+
class="menu transition dimmable"
|
|
170
|
+
/>
|
|
171
|
+
</div>
|
|
172
|
+
<a
|
|
173
|
+
class="resetFilters"
|
|
174
|
+
>
|
|
175
|
+
Clear filters
|
|
176
|
+
</a>
|
|
177
|
+
</div>
|
|
148
178
|
<div
|
|
149
179
|
class="dimmable"
|
|
150
180
|
>
|
|
@@ -188,6 +218,11 @@ exports[`<GrantRequestsSearchResults /> matches the latest snapshot 1`] = `
|
|
|
188
218
|
>
|
|
189
219
|
path
|
|
190
220
|
</th>
|
|
221
|
+
<th
|
|
222
|
+
class="two wide"
|
|
223
|
+
>
|
|
224
|
+
current_status
|
|
225
|
+
</th>
|
|
191
226
|
<th
|
|
192
227
|
class="two wide"
|
|
193
228
|
>
|
|
@@ -214,6 +249,9 @@ exports[`<GrantRequestsSearchResults /> matches the latest snapshot 1`] = `
|
|
|
214
249
|
>
|
|
215
250
|
|
|
216
251
|
</td>
|
|
252
|
+
<td
|
|
253
|
+
class=""
|
|
254
|
+
/>
|
|
217
255
|
<td
|
|
218
256
|
class="center aligned"
|
|
219
257
|
/>
|
|
@@ -234,6 +272,9 @@ exports[`<GrantRequestsSearchResults /> matches the latest snapshot 1`] = `
|
|
|
234
272
|
>
|
|
235
273
|
|
|
236
274
|
</td>
|
|
275
|
+
<td
|
|
276
|
+
class=""
|
|
277
|
+
/>
|
|
237
278
|
<td
|
|
238
279
|
class="center aligned"
|
|
239
280
|
/>
|
package/src/components/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import GrantRoutes from "./GrantRoutes";
|
|
|
5
5
|
import GrantRequestBulkActions from "./GrantRequestBulkActions";
|
|
6
6
|
import GrantRequestsTable from "./GrantRequestsTable";
|
|
7
7
|
import GrantRequestRow from "./GrantRequestRow";
|
|
8
|
+
import GrantRequestPagination from "./GrantRequestPagination";
|
|
8
9
|
import GrantSelectedFilters from "./GrantSelectedFilters";
|
|
9
10
|
import GrantRequestsSelectedFilters from "./GrantRequestsSelectedFilters";
|
|
10
11
|
import GrantsTable from "./GrantsTable";
|
|
@@ -60,6 +61,7 @@ export {
|
|
|
60
61
|
GrantRequestsTable,
|
|
61
62
|
GrantRequestRow,
|
|
62
63
|
GrantRequestsSelectedFilters,
|
|
64
|
+
GrantRequestPagination,
|
|
63
65
|
GrantRoutes,
|
|
64
66
|
GrantSelectedFilters,
|
|
65
67
|
GrantsTable,
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { fetchGrantRequestsSearch } from "../../routines";
|
|
2
|
+
import { grantRequestPageSize } from "..";
|
|
3
|
+
|
|
4
|
+
const fooState = { foo: "bar" };
|
|
5
|
+
const initialState = 20;
|
|
6
|
+
|
|
7
|
+
describe("reducers: grantRequestPageSize", () => {
|
|
8
|
+
it("should provide the initial state", () => {
|
|
9
|
+
expect(grantRequestPageSize(undefined, {})).toEqual(initialState);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
describe("action: fetchGrantRequestsSearch.TRIGGER", () => {
|
|
13
|
+
describe("with an empty payload", () => {
|
|
14
|
+
it("should return the passed state if no size is specified", () => {
|
|
15
|
+
const payload = {};
|
|
16
|
+
expect(
|
|
17
|
+
grantRequestPageSize(fooState, {
|
|
18
|
+
type: fetchGrantRequestsSearch.TRIGGER,
|
|
19
|
+
payload,
|
|
20
|
+
})
|
|
21
|
+
).toEqual(fooState);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("should set size value if specified", () => {
|
|
26
|
+
const size = 1234;
|
|
27
|
+
|
|
28
|
+
expect(
|
|
29
|
+
grantRequestPageSize(fooState, {
|
|
30
|
+
type: fetchGrantRequestsSearch.TRIGGER,
|
|
31
|
+
payload: { size },
|
|
32
|
+
})
|
|
33
|
+
).toBe(1234);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { fetchGrantRequestsSearch } from "../routines";
|
|
2
|
+
|
|
3
|
+
const defaultPageSize = 20;
|
|
4
|
+
|
|
5
|
+
const grantRequestPageSize = (state = defaultPageSize, { type, payload }) => {
|
|
6
|
+
switch (type) {
|
|
7
|
+
case fetchGrantRequestsSearch.TRIGGER:
|
|
8
|
+
const { size } = payload;
|
|
9
|
+
return size || state;
|
|
10
|
+
default:
|
|
11
|
+
return state;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { grantRequestPageSize };
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
2
|
import {
|
|
3
3
|
clearGrantRequestsFilters,
|
|
4
|
+
clearGrantRequestsSort,
|
|
4
5
|
removeGrantRequestsFilter,
|
|
5
6
|
searchGrantRequests,
|
|
6
7
|
sortGrantRequests,
|
|
7
8
|
toggleGrantRequestsFilterValue,
|
|
8
|
-
|
|
9
|
+
selectGrantRequestPage,
|
|
9
10
|
} from "../routines";
|
|
10
11
|
|
|
11
12
|
const defaultPage = 1;
|
|
12
|
-
const defaultSize =
|
|
13
|
+
const defaultSize = 20;
|
|
13
14
|
const defaultSearchSort = [{ _score: "desc" }, { inserted_at: "asc" }];
|
|
14
15
|
const byInsertedSort = [{ inserted_at: "asc" }];
|
|
15
16
|
|
|
@@ -42,6 +43,10 @@ export const grantRequestSearchQuery = (
|
|
|
42
43
|
const sort = query != "" ? defaultSearchSort : byInsertedSort;
|
|
43
44
|
return { ...state, query, page, sort };
|
|
44
45
|
}
|
|
46
|
+
case selectGrantRequestPage.TRIGGER: {
|
|
47
|
+
const { activePage } = payload;
|
|
48
|
+
return { ...state, page: activePage };
|
|
49
|
+
}
|
|
45
50
|
case sortGrantRequests.TRIGGER: {
|
|
46
51
|
const sort = payload;
|
|
47
52
|
return { ...state, sort, page: defaultPage };
|
package/src/reducers/index.js
CHANGED
|
@@ -30,6 +30,8 @@ import { grantRequestsSelectedFilter } from "./grantRequestsSelectedFilter";
|
|
|
30
30
|
import { grants } from "./grants";
|
|
31
31
|
import { grantSelectedFilter } from "./grantSelectedFilter";
|
|
32
32
|
import { grantsPageSize } from "./grantsPageSize";
|
|
33
|
+
import { grantRequestPageSize } from "./grantRequestPageSize";
|
|
34
|
+
|
|
33
35
|
import { graph } from "./graph";
|
|
34
36
|
import { graphLoading } from "./graphLoading";
|
|
35
37
|
import { graphRedirect } from "./graphRedirect";
|
|
@@ -126,6 +128,7 @@ export {
|
|
|
126
128
|
grants,
|
|
127
129
|
grantSelectedFilter,
|
|
128
130
|
grantsPageSize,
|
|
131
|
+
grantRequestPageSize,
|
|
129
132
|
graph,
|
|
130
133
|
graphLoading,
|
|
131
134
|
graphRedirect,
|
package/src/routines.js
CHANGED
|
@@ -163,6 +163,8 @@ export const searchGrantRequests = createRoutine("SEARCH_GRANT_REQUESTS");
|
|
|
163
163
|
export const searchGrants = createRoutine("SEARCH_GRANTS");
|
|
164
164
|
export const searchStructures = createRoutine("SEARCH_STRUCTURES");
|
|
165
165
|
export const selectGrantPage = createRoutine("SELECT_GRANT_PAGE");
|
|
166
|
+
export const selectGrantRequestPage = createRoutine("SELECT_GRANT_REQUEST_PAGE");
|
|
167
|
+
|
|
166
168
|
export const selectGrantRequestTemplate = createRoutine(
|
|
167
169
|
"SELECT_GRANT_REQUEST_TEMPLATE"
|
|
168
170
|
);
|
|
@@ -67,15 +67,17 @@ DateDecorator.propTypes = {
|
|
|
67
67
|
date: PropTypes.string,
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
const StatusDecorator = ({
|
|
70
|
+
const StatusDecorator = ({ current_status }) => {
|
|
71
71
|
const { formatMessage } = useIntl();
|
|
72
|
-
return
|
|
73
|
-
<>
|
|
72
|
+
return current_status ? (
|
|
73
|
+
<>
|
|
74
|
+
{formatMessage({ id: `grantRequest.current_status.${current_status}` })}
|
|
75
|
+
</>
|
|
74
76
|
) : null;
|
|
75
77
|
};
|
|
76
78
|
|
|
77
79
|
StatusDecorator.propTypes = {
|
|
78
|
-
|
|
80
|
+
current_status: PropTypes.string,
|
|
79
81
|
};
|
|
80
82
|
|
|
81
83
|
export const defaultGrantRequestsSearchTableColumns = [
|
|
@@ -102,6 +104,13 @@ export const defaultGrantRequestsSearchTableColumns = [
|
|
|
102
104
|
}),
|
|
103
105
|
fieldDecorator: PathDecorator,
|
|
104
106
|
},
|
|
107
|
+
{
|
|
108
|
+
name: "current_status",
|
|
109
|
+
sort: { name: "current_status" },
|
|
110
|
+
fieldSelector: (grantRequest) => grantRequest,
|
|
111
|
+
fieldDecorator: StatusDecorator,
|
|
112
|
+
width: 2,
|
|
113
|
+
},
|
|
105
114
|
{
|
|
106
115
|
name: "inserted_at",
|
|
107
116
|
sort: { name: "inserted_at" },
|