@truedat/dd 7.5.14 → 7.6.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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/dd",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.6.0",
|
|
4
4
|
"description": "Truedat Web Data Dictionary",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@testing-library/jest-dom": "^6.6.3",
|
|
49
49
|
"@testing-library/react": "^16.3.0",
|
|
50
50
|
"@testing-library/user-event": "^14.6.1",
|
|
51
|
-
"@truedat/test": "7.
|
|
51
|
+
"@truedat/test": "7.6.0",
|
|
52
52
|
"identity-obj-proxy": "^3.0.0",
|
|
53
53
|
"jest": "^29.7.0",
|
|
54
54
|
"redux-saga-test-plan": "^4.0.6"
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"svg-pan-zoom": "^3.6.2",
|
|
84
84
|
"swr": "^2.3.3"
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "0d9c5ee7b864fe3dc87def2be0f68191c04dee57"
|
|
87
87
|
}
|
|
@@ -18,7 +18,10 @@ import {
|
|
|
18
18
|
} from "semantic-ui-react";
|
|
19
19
|
import { Loading } from "@truedat/core/components";
|
|
20
20
|
import { useOperators } from "@truedat/core/hooks";
|
|
21
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
GRANTS_REQUESTS_CHECKOUT,
|
|
23
|
+
STRUCTURES_GRANT_REQUEST,
|
|
24
|
+
} from "@truedat/core/routes";
|
|
22
25
|
import { FiltersGrid } from "@truedat/dq/components/ruleImplementationForm/FiltersGrid";
|
|
23
26
|
import {
|
|
24
27
|
removeGrantRequestFromCart,
|
|
@@ -46,7 +49,8 @@ export const StructureGrantCart = ({
|
|
|
46
49
|
const structures = _.pathOr([], "structures")(grantRequestsCart);
|
|
47
50
|
|
|
48
51
|
useEffect(() => {
|
|
49
|
-
if (_.isEmpty(structures) && !allowEmptyCart)
|
|
52
|
+
if (_.isEmpty(structures) && !allowEmptyCart)
|
|
53
|
+
navigate(STRUCTURES_GRANT_REQUEST);
|
|
50
54
|
}, [history, structures, allowEmptyCart]);
|
|
51
55
|
|
|
52
56
|
const removeRequest = (structure) => () =>
|
|
@@ -8,16 +8,12 @@ import { lowerDeburrTrim } from "@truedat/core/services/sort";
|
|
|
8
8
|
import { DomainSelector } from "@truedat/core/components";
|
|
9
9
|
import { RoleSelector } from "@truedat/auth/roles/components";
|
|
10
10
|
import { useRoles } from "@truedat/auth/hooks/useRoles";
|
|
11
|
+
import { useGrantRequestableUsers } from "@truedat/auth/hooks/useUsers";
|
|
11
12
|
import { updateGrantRequestUser } from "../routines";
|
|
12
13
|
|
|
13
|
-
const UsersSearchLoader = lazy(
|
|
14
|
-
() => import("@truedat/auth/users/components/UsersSearchLoader")
|
|
15
|
-
);
|
|
16
|
-
|
|
17
14
|
export const StructureGrantCartUserSelector = ({
|
|
18
15
|
grantRequestsCart,
|
|
19
16
|
updateGrantRequestUser,
|
|
20
|
-
options,
|
|
21
17
|
}) => {
|
|
22
18
|
const { formatMessage } = useIntl();
|
|
23
19
|
const [usersGroupsQuery, setUsersGroupsQuery] = useState("");
|
|
@@ -26,10 +22,17 @@ export const StructureGrantCartUserSelector = ({
|
|
|
26
22
|
const [selectedRoles, setSelectedRoles] = useState([]);
|
|
27
23
|
const [selectedRoleIds, setSelectedRoleIds] = useState([]);
|
|
28
24
|
const [userId, setUserId] = useState(null);
|
|
25
|
+
const { users, trigger } = useGrantRequestableUsers();
|
|
29
26
|
|
|
30
27
|
const { modificationGrant } = grantRequestsCart;
|
|
31
28
|
const updateGrant = !_.isEmpty(modificationGrant);
|
|
32
29
|
const domainActions = ["publishGrantRequest"];
|
|
30
|
+
const options = _.map(({ full_name, id }) => ({
|
|
31
|
+
key: id,
|
|
32
|
+
text: full_name,
|
|
33
|
+
value: id,
|
|
34
|
+
icon: "user",
|
|
35
|
+
}))(users);
|
|
33
36
|
|
|
34
37
|
const { data: roles } = useRoles();
|
|
35
38
|
|
|
@@ -61,6 +64,26 @@ export const StructureGrantCartUserSelector = ({
|
|
|
61
64
|
)(roles);
|
|
62
65
|
}, [selectedRoles, roles]);
|
|
63
66
|
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
const structuresDomains = _.flatMap(({ domain_ids }) => domain_ids)(
|
|
69
|
+
grantRequestsCart.structures
|
|
70
|
+
);
|
|
71
|
+
const filters = {
|
|
72
|
+
structures_domains: structuresDomains,
|
|
73
|
+
query: usersGroupsQuery,
|
|
74
|
+
filter_domains: domainIds,
|
|
75
|
+
roles: selectedRoleIds,
|
|
76
|
+
};
|
|
77
|
+
const payload = _.omitBy(_.isEmpty)(filters);
|
|
78
|
+
trigger(payload);
|
|
79
|
+
}, [
|
|
80
|
+
grantRequestsCart.structures,
|
|
81
|
+
usersGroupsQuery,
|
|
82
|
+
domainIds,
|
|
83
|
+
selectedRoleIds,
|
|
84
|
+
trigger,
|
|
85
|
+
]);
|
|
86
|
+
|
|
64
87
|
const onSearch = (_currentOptions, { searchQuery }) =>
|
|
65
88
|
setUsersGroupsQuery(lowerDeburrTrim(searchQuery));
|
|
66
89
|
|
|
@@ -131,12 +154,6 @@ export const StructureGrantCartUserSelector = ({
|
|
|
131
154
|
</Header>
|
|
132
155
|
) : (
|
|
133
156
|
<>
|
|
134
|
-
<UsersSearchLoader
|
|
135
|
-
query={usersGroupsQuery}
|
|
136
|
-
domains={domainIds}
|
|
137
|
-
roles={selectedRoleIds}
|
|
138
|
-
permission="allow_foreign_grant_request"
|
|
139
|
-
/>
|
|
140
157
|
<Form.Dropdown
|
|
141
158
|
placeholder={formatMessage({
|
|
142
159
|
id: "grantRequestCart.user.placeholder",
|
|
@@ -168,17 +185,11 @@ export const StructureGrantCartUserSelector = ({
|
|
|
168
185
|
|
|
169
186
|
StructureGrantCartUserSelector.propTypes = {
|
|
170
187
|
grantRequestsCart: PropTypes.object,
|
|
171
|
-
options: PropTypes.array,
|
|
172
188
|
updateGrantRequestUser: PropTypes.func,
|
|
173
189
|
};
|
|
174
190
|
|
|
175
|
-
const mapStateToProps = ({ grantRequestsCart
|
|
191
|
+
const mapStateToProps = ({ grantRequestsCart }) => ({
|
|
176
192
|
grantRequestsCart,
|
|
177
|
-
options: _.map(({ full_name, id }) => ({
|
|
178
|
-
text: full_name,
|
|
179
|
-
value: id,
|
|
180
|
-
icon: "user",
|
|
181
|
-
}))(usersSearch),
|
|
182
193
|
});
|
|
183
194
|
|
|
184
195
|
export default connect(mapStateToProps, { updateGrantRequestUser })(
|
|
@@ -1,10 +1,33 @@
|
|
|
1
1
|
import { render, waitForLoad } from "@truedat/test/render";
|
|
2
|
+
import { useGrantRequestableUsers } from "@truedat/auth/hooks/useUsers";
|
|
2
3
|
import StructureGrantCartUserSelector from "../StructureGrantCartUserSelector";
|
|
3
4
|
|
|
5
|
+
jest.mock("@truedat/auth/hooks/useUsers", () => ({
|
|
6
|
+
useGrantRequestableUsers: jest.fn(() => ({
|
|
7
|
+
users: [
|
|
8
|
+
{
|
|
9
|
+
id: 1,
|
|
10
|
+
full_name: "name",
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
trigger: jest.fn(() =>
|
|
14
|
+
Promise.resolve({
|
|
15
|
+
data: {
|
|
16
|
+
data: [
|
|
17
|
+
{
|
|
18
|
+
id: 1,
|
|
19
|
+
full_name: "name",
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
})
|
|
24
|
+
),
|
|
25
|
+
})),
|
|
26
|
+
}));
|
|
27
|
+
|
|
4
28
|
const defaultRenderOpts = {
|
|
5
29
|
state: {
|
|
6
30
|
grantRequestsCart: { user: { id: 5 } },
|
|
7
|
-
usersSearch: [{ full_name: "name", id: 1 }],
|
|
8
31
|
},
|
|
9
32
|
};
|
|
10
33
|
|
|
@@ -19,6 +42,16 @@ describe("<StructureGrantCartUserSelector />", () => {
|
|
|
19
42
|
});
|
|
20
43
|
|
|
21
44
|
it("matches the latest snapshot on update grant", async () => {
|
|
45
|
+
useGrantRequestableUsers.mockImplementationOnce(() => ({
|
|
46
|
+
users: [],
|
|
47
|
+
trigger: jest.fn(() =>
|
|
48
|
+
Promise.resolve({
|
|
49
|
+
data: {
|
|
50
|
+
data: [],
|
|
51
|
+
},
|
|
52
|
+
})
|
|
53
|
+
),
|
|
54
|
+
}));
|
|
22
55
|
const renderOpts = {
|
|
23
56
|
...defaultRenderOpts,
|
|
24
57
|
state: {
|