@truedat/dd 5.16.3 → 5.17.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.
- package/package.json +5 -5
- package/src/components/GrantRequestsSearchResults.js +19 -19
- package/src/components/GrantRoutes.js +1 -10
- package/src/components/StructureGrantCartUserSelector.js +18 -23
- package/src/components/__tests__/StructureGrantCartInformation.spec.js +19 -0
- package/src/components/__tests__/__snapshots__/GrantRequestsSearchResults.spec.js.snap +72 -73
- package/src/reducers/__tests__/grantRequestPermissions.spec.js +1 -1
- package/src/reducers/grantRequestPermissions.js +6 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/dd",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.17.0",
|
|
4
4
|
"description": "Truedat Web Data Dictionary",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"jsnext:main": "src/index.js",
|
|
@@ -88,9 +88,9 @@
|
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
90
|
"@apollo/client": "^3.7.1",
|
|
91
|
-
"@truedat/auth": "5.
|
|
92
|
-
"@truedat/core": "5.
|
|
93
|
-
"@truedat/df": "5.
|
|
91
|
+
"@truedat/auth": "5.17.0",
|
|
92
|
+
"@truedat/core": "5.17.0",
|
|
93
|
+
"@truedat/df": "5.17.0",
|
|
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": "5fbcca7a428b2b92de1c610eb44f2d4a281c1655"
|
|
119
119
|
}
|
|
@@ -109,28 +109,28 @@ export const GrantRequestsSearchResults = ({
|
|
|
109
109
|
|
|
110
110
|
<GrantRequestsSearch />
|
|
111
111
|
<GrantRequestsSelectedFilters />
|
|
112
|
-
<Dimmer.Dimmable dimmed={
|
|
113
|
-
<Dimmer active={
|
|
112
|
+
<Dimmer.Dimmable dimmed={loading}>
|
|
113
|
+
<Dimmer active={loading} inverted>
|
|
114
114
|
<Loader />
|
|
115
115
|
</Dimmer>
|
|
116
|
-
</Dimmer.Dimmable>
|
|
117
116
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
117
|
+
{loadingDone ? (
|
|
118
|
+
<>
|
|
119
|
+
<GrantRequestsLabelResults
|
|
120
|
+
roleSelected={roleSelected}
|
|
121
|
+
grantRequestToExecute={_.size(selectedGrantRequests)}
|
|
122
|
+
/>
|
|
123
|
+
<GrantRequestsTable
|
|
124
|
+
addAll={addAll}
|
|
125
|
+
checkedAll={allChecked()}
|
|
126
|
+
checkRow={checkRow}
|
|
127
|
+
isRowChecked={isRowChecked}
|
|
128
|
+
selectedGrantRequests={selectedGrantRequests}
|
|
129
|
+
roleSelected={roleSelected}
|
|
130
|
+
/>
|
|
131
|
+
</>
|
|
132
|
+
) : null}
|
|
133
|
+
</Dimmer.Dimmable>
|
|
134
134
|
</Segment>
|
|
135
135
|
</Segment>
|
|
136
136
|
);
|
|
@@ -40,10 +40,6 @@ import StructureFiltersLoader from "./StructureFiltersLoader";
|
|
|
40
40
|
import UserSearchFiltersLoader from "./UserSearchFiltersLoader";
|
|
41
41
|
import GrantRequestsFiltersLoader from "./GrantRequestsFiltersLoader";
|
|
42
42
|
|
|
43
|
-
const RolesLoader = React.lazy(() =>
|
|
44
|
-
import("@truedat/auth/roles/components/RolesLoader")
|
|
45
|
-
);
|
|
46
|
-
|
|
47
43
|
const TemplatesLoader = React.lazy(() =>
|
|
48
44
|
import("@truedat/df/templates/components/TemplatesLoader")
|
|
49
45
|
);
|
|
@@ -53,12 +49,7 @@ export const GrantRoutes = ({ grantRequestLoaded }) => {
|
|
|
53
49
|
<>
|
|
54
50
|
<Route
|
|
55
51
|
path={GRANTS_REQUESTS_CHECKOUT}
|
|
56
|
-
render={() =>
|
|
57
|
-
<>
|
|
58
|
-
<RolesLoader />
|
|
59
|
-
<StructureGrantCartCheckout />
|
|
60
|
-
</>
|
|
61
|
-
)}
|
|
52
|
+
render={() => <StructureGrantCartCheckout />}
|
|
62
53
|
/>
|
|
63
54
|
<Switch>
|
|
64
55
|
<Route exact path={GRANT} render={() => <GrantView />} />
|
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
2
|
import React, { useEffect, useState } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
|
-
import {
|
|
5
|
-
Form,
|
|
6
|
-
Dropdown,
|
|
7
|
-
Checkbox,
|
|
8
|
-
Header,
|
|
9
|
-
Label,
|
|
10
|
-
Popup,
|
|
11
|
-
} from "semantic-ui-react";
|
|
4
|
+
import { Form, Checkbox, Header, Label, Popup } from "semantic-ui-react";
|
|
12
5
|
import { connect } from "react-redux";
|
|
13
6
|
import { useIntl } from "react-intl";
|
|
14
7
|
import { lowerDeburrTrim } from "@truedat/core/services/sort";
|
|
15
8
|
import { DomainSelector } from "@truedat/core/components";
|
|
16
9
|
import { RoleSelector } from "@truedat/auth/roles/components";
|
|
10
|
+
import { useRoles } from "@truedat/auth/hooks/useRoles";
|
|
17
11
|
import { updateGrantRequestUser } from "../routines";
|
|
18
12
|
|
|
19
13
|
const UsersSearchLoader = React.lazy(() =>
|
|
@@ -24,14 +18,13 @@ export const StructureGrantCartUserSelector = ({
|
|
|
24
18
|
grantRequestsCart,
|
|
25
19
|
updateGrantRequestUser,
|
|
26
20
|
options,
|
|
27
|
-
rolesRaw,
|
|
28
21
|
}) => {
|
|
29
22
|
const { formatMessage } = useIntl();
|
|
30
23
|
const [usersGroupsQuery, setUsersGroupsQuery] = useState("");
|
|
31
24
|
const [thirdParty, setThirdParty] = useState(false);
|
|
32
25
|
const [domainIds, setDomainIds] = useState([]);
|
|
33
|
-
const [
|
|
34
|
-
const [
|
|
26
|
+
const [selectedRoles, setSelectedRoles] = useState([]);
|
|
27
|
+
const [selectedRoleIds, setSelectedRoleIds] = useState([]);
|
|
35
28
|
|
|
36
29
|
const [userId, setUserId] = useState(_.path("user.id")(grantRequestsCart));
|
|
37
30
|
|
|
@@ -39,6 +32,9 @@ export const StructureGrantCartUserSelector = ({
|
|
|
39
32
|
const updateGrant = !_.isEmpty(modificationGrant);
|
|
40
33
|
|
|
41
34
|
const domainActions = ["publishGrantRequest"];
|
|
35
|
+
|
|
36
|
+
const { data: roles } = useRoles();
|
|
37
|
+
|
|
42
38
|
useEffect(() => {
|
|
43
39
|
updateGrantRequestUser({
|
|
44
40
|
id: userId,
|
|
@@ -66,11 +62,11 @@ export const StructureGrantCartUserSelector = ({
|
|
|
66
62
|
|
|
67
63
|
useEffect(() => {
|
|
68
64
|
_.flow(
|
|
69
|
-
_.filter(({ name }) => _.includes(name)(
|
|
65
|
+
_.filter(({ name }) => _.includes(name)(selectedRoles)),
|
|
70
66
|
_.map(({ id }) => id),
|
|
71
|
-
|
|
72
|
-
)(
|
|
73
|
-
}, [
|
|
67
|
+
setSelectedRoleIds
|
|
68
|
+
)(roles);
|
|
69
|
+
}, [selectedRoles, roles]);
|
|
74
70
|
|
|
75
71
|
const onSearch = (_currentOptions, { searchQuery }) =>
|
|
76
72
|
setUsersGroupsQuery(lowerDeburrTrim(searchQuery));
|
|
@@ -114,8 +110,9 @@ export const StructureGrantCartUserSelector = ({
|
|
|
114
110
|
on="click"
|
|
115
111
|
content={
|
|
116
112
|
<RoleSelector
|
|
117
|
-
onChange={(_e, { value }) =>
|
|
118
|
-
value={
|
|
113
|
+
onChange={(_e, { value }) => setSelectedRoles(value)}
|
|
114
|
+
value={selectedRoles}
|
|
115
|
+
roles={roles}
|
|
119
116
|
labels
|
|
120
117
|
multiple={true}
|
|
121
118
|
/>
|
|
@@ -123,8 +120,8 @@ export const StructureGrantCartUserSelector = ({
|
|
|
123
120
|
trigger={
|
|
124
121
|
<Label as="a">
|
|
125
122
|
{formatMessage({ id: "roles.header" })}
|
|
126
|
-
{
|
|
127
|
-
<Label.Detail>{
|
|
123
|
+
{selectedRoles.length > 0 ? (
|
|
124
|
+
<Label.Detail>{selectedRoles.length}</Label.Detail>
|
|
128
125
|
) : null}
|
|
129
126
|
</Label>
|
|
130
127
|
}
|
|
@@ -146,7 +143,7 @@ export const StructureGrantCartUserSelector = ({
|
|
|
146
143
|
<UsersSearchLoader
|
|
147
144
|
query={usersGroupsQuery}
|
|
148
145
|
domains={domainIds}
|
|
149
|
-
roles={
|
|
146
|
+
roles={selectedRoleIds}
|
|
150
147
|
permission="allow_foreign_grant_request"
|
|
151
148
|
hideLoading
|
|
152
149
|
/>
|
|
@@ -183,17 +180,15 @@ StructureGrantCartUserSelector.propTypes = {
|
|
|
183
180
|
grantRequestsCart: PropTypes.object,
|
|
184
181
|
options: PropTypes.array,
|
|
185
182
|
updateGrantRequestUser: PropTypes.func,
|
|
186
|
-
rolesRaw: PropTypes.array,
|
|
187
183
|
};
|
|
188
184
|
|
|
189
|
-
const mapStateToProps = ({ grantRequestsCart, usersSearch
|
|
185
|
+
const mapStateToProps = ({ grantRequestsCart, usersSearch }) => ({
|
|
190
186
|
grantRequestsCart,
|
|
191
187
|
options: _.map(({ full_name, id }) => ({
|
|
192
188
|
text: full_name,
|
|
193
189
|
value: id,
|
|
194
190
|
icon: "user",
|
|
195
191
|
}))(usersSearch),
|
|
196
|
-
rolesRaw: roles,
|
|
197
192
|
});
|
|
198
193
|
|
|
199
194
|
export default connect(mapStateToProps, { updateGrantRequestUser })(
|
|
@@ -3,6 +3,25 @@ import { render } from "@truedat/test/render";
|
|
|
3
3
|
import { singleTemplateMock } from "@truedat/test/mocks";
|
|
4
4
|
import { StructureGrantCartInformation } from "../StructureGrantCartInformation";
|
|
5
5
|
|
|
6
|
+
jest.mock("@truedat/auth/hooks/useRoles", () => {
|
|
7
|
+
const originalModule = jest.requireActual("@truedat/auth/hooks/useRoles");
|
|
8
|
+
|
|
9
|
+
return {
|
|
10
|
+
__esModule: true,
|
|
11
|
+
...originalModule,
|
|
12
|
+
useRoles: jest.fn(() => ({
|
|
13
|
+
data: {
|
|
14
|
+
data: {
|
|
15
|
+
data: {
|
|
16
|
+
roles: [],
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
loading: false,
|
|
21
|
+
})),
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
|
|
6
25
|
describe("<StructureGrantCartInformation />", () => {
|
|
7
26
|
const selectGrantRequestTemplate = jest.fn();
|
|
8
27
|
const updateGrantRequestTemplateContent = jest.fn();
|
|
@@ -146,11 +146,10 @@ exports[`<GrantRequestsSearchResults /> matches the latest snapshot 1`] = `
|
|
|
146
146
|
class="selectedFilters"
|
|
147
147
|
/>
|
|
148
148
|
<div
|
|
149
|
-
class="
|
|
149
|
+
class="dimmable"
|
|
150
150
|
>
|
|
151
151
|
<div
|
|
152
|
-
class="ui
|
|
153
|
-
style="display: flex;"
|
|
152
|
+
class="ui inverted dimmer"
|
|
154
153
|
>
|
|
155
154
|
<div
|
|
156
155
|
class="content"
|
|
@@ -160,88 +159,88 @@ exports[`<GrantRequestsSearchResults /> matches the latest snapshot 1`] = `
|
|
|
160
159
|
/>
|
|
161
160
|
</div>
|
|
162
161
|
</div>
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
class="ui label grant-requests-bulk-label-results"
|
|
166
|
-
>
|
|
167
|
-
results
|
|
168
|
-
</div>
|
|
169
|
-
<table
|
|
170
|
-
class="ui sortable table"
|
|
171
|
-
>
|
|
172
|
-
<thead
|
|
173
|
-
class=""
|
|
162
|
+
<div
|
|
163
|
+
class="ui label grant-requests-bulk-label-results"
|
|
174
164
|
>
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
class=""
|
|
180
|
-
>
|
|
181
|
-
user
|
|
182
|
-
</th>
|
|
183
|
-
<th
|
|
184
|
-
class=""
|
|
185
|
-
>
|
|
186
|
-
data_structure
|
|
187
|
-
</th>
|
|
188
|
-
<th
|
|
189
|
-
class="ascending sorted disabled"
|
|
190
|
-
>
|
|
191
|
-
path
|
|
192
|
-
</th>
|
|
193
|
-
<th
|
|
194
|
-
class="two wide"
|
|
195
|
-
>
|
|
196
|
-
inserted_at
|
|
197
|
-
</th>
|
|
198
|
-
</tr>
|
|
199
|
-
</thead>
|
|
200
|
-
<tbody
|
|
201
|
-
class=""
|
|
165
|
+
results
|
|
166
|
+
</div>
|
|
167
|
+
<table
|
|
168
|
+
class="ui sortable table"
|
|
202
169
|
>
|
|
203
|
-
<
|
|
170
|
+
<thead
|
|
204
171
|
class=""
|
|
205
172
|
>
|
|
206
|
-
<
|
|
207
|
-
class=""
|
|
208
|
-
>
|
|
209
|
-
null
|
|
210
|
-
</td>
|
|
211
|
-
<td
|
|
212
|
-
class=""
|
|
213
|
-
/>
|
|
214
|
-
<td
|
|
173
|
+
<tr
|
|
215
174
|
class=""
|
|
216
175
|
>
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
176
|
+
<th
|
|
177
|
+
class=""
|
|
178
|
+
>
|
|
179
|
+
user
|
|
180
|
+
</th>
|
|
181
|
+
<th
|
|
182
|
+
class=""
|
|
183
|
+
>
|
|
184
|
+
data_structure
|
|
185
|
+
</th>
|
|
186
|
+
<th
|
|
187
|
+
class="ascending sorted disabled"
|
|
188
|
+
>
|
|
189
|
+
path
|
|
190
|
+
</th>
|
|
191
|
+
<th
|
|
192
|
+
class="two wide"
|
|
193
|
+
>
|
|
194
|
+
inserted_at
|
|
195
|
+
</th>
|
|
196
|
+
</tr>
|
|
197
|
+
</thead>
|
|
198
|
+
<tbody
|
|
224
199
|
class=""
|
|
225
200
|
>
|
|
226
|
-
<
|
|
201
|
+
<tr
|
|
227
202
|
class=""
|
|
228
203
|
>
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
204
|
+
<td
|
|
205
|
+
class=""
|
|
206
|
+
>
|
|
207
|
+
null
|
|
208
|
+
</td>
|
|
209
|
+
<td
|
|
210
|
+
class=""
|
|
211
|
+
/>
|
|
212
|
+
<td
|
|
213
|
+
class=""
|
|
214
|
+
>
|
|
215
|
+
|
|
216
|
+
</td>
|
|
217
|
+
<td
|
|
218
|
+
class="center aligned"
|
|
219
|
+
/>
|
|
220
|
+
</tr>
|
|
221
|
+
<tr
|
|
235
222
|
class=""
|
|
236
223
|
>
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
224
|
+
<td
|
|
225
|
+
class=""
|
|
226
|
+
>
|
|
227
|
+
null
|
|
228
|
+
</td>
|
|
229
|
+
<td
|
|
230
|
+
class=""
|
|
231
|
+
/>
|
|
232
|
+
<td
|
|
233
|
+
class=""
|
|
234
|
+
>
|
|
235
|
+
|
|
236
|
+
</td>
|
|
237
|
+
<td
|
|
238
|
+
class="center aligned"
|
|
239
|
+
/>
|
|
240
|
+
</tr>
|
|
241
|
+
</tbody>
|
|
242
|
+
</table>
|
|
243
|
+
</div>
|
|
245
244
|
</div>
|
|
246
245
|
</div>
|
|
247
246
|
</div>
|
|
@@ -36,7 +36,7 @@ describe("reducers: grantRequestPermissions", () => {
|
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
describe("reducers: grantRequestPermissionsLoading", () => {
|
|
39
|
-
const initialState =
|
|
39
|
+
const initialState = false;
|
|
40
40
|
|
|
41
41
|
it("should provide the initial state", () => {
|
|
42
42
|
expect(grantRequestPermissionsLoading(undefined, {})).toEqual(initialState);
|
|
@@ -17,7 +17,12 @@ const grantRequestPermissions = (state = initialState, { type, payload }) => {
|
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
const
|
|
20
|
+
const initialStateLoading = false;
|
|
21
|
+
|
|
22
|
+
const grantRequestPermissionsLoading = (
|
|
23
|
+
state = initialStateLoading,
|
|
24
|
+
{ type }
|
|
25
|
+
) => {
|
|
21
26
|
switch (type) {
|
|
22
27
|
case fetchGrantRequestsSearch.TRIGGER:
|
|
23
28
|
return true;
|