@truedat/dd 4.51.3 → 4.51.4
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/CHANGELOG.md +6 -0
- package/package.json +6 -6
- package/src/components/GrantRequest.js +12 -0
- package/src/components/GrantRequests.js +24 -15
- package/src/components/StructureGrantCartCheckout.js +7 -6
- package/src/components/{StructureGrantCartTemplate.js → StructureGrantCartInformation.js} +15 -5
- package/src/components/StructureGrantCartUserSelector.js +93 -0
- package/src/components/StructureGrantDropdown.js +45 -18
- package/src/components/StructureGrantRequestAddCart.js +26 -0
- package/src/components/__tests__/MyGrantRequests.spec.js +14 -2
- package/src/components/__tests__/{StructureGrantCartTemplate.spec.js → StructureGrantCartInformation.spec.js} +3 -3
- package/src/components/__tests__/StructureGrantCartUserSelector.js +21 -0
- package/src/components/__tests__/__snapshots__/MyGrantRequests.spec.js.snap +1 -1
- package/src/components/__tests__/__snapshots__/{StructureGrantCartTemplate.spec.js.snap → StructureGrantCartInformation.spec.js.snap} +2 -2
- package/src/components/__tests__/__snapshots__/StructureGrantCartUserSelector.js.snap +74 -0
- package/src/messages/en.js +3 -1
- package/src/messages/es.js +3 -0
- package/src/reducers/grantRequestsCart.js +10 -0
- package/src/routines.js +1 -0
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/dd",
|
|
3
|
-
"version": "4.51.
|
|
3
|
+
"version": "4.51.4",
|
|
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.4",
|
|
35
35
|
"@testing-library/react": "^12.0.0",
|
|
36
36
|
"@testing-library/user-event": "^13.2.1",
|
|
37
|
-
"@truedat/test": "4.51.
|
|
37
|
+
"@truedat/test": "4.51.4",
|
|
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.6.4",
|
|
91
|
-
"@truedat/auth": "4.51.
|
|
92
|
-
"@truedat/core": "4.51.
|
|
93
|
-
"@truedat/df": "4.51.
|
|
91
|
+
"@truedat/auth": "4.51.4",
|
|
92
|
+
"@truedat/core": "4.51.4",
|
|
93
|
+
"@truedat/df": "4.51.4",
|
|
94
94
|
"lodash": "^4.17.21",
|
|
95
95
|
"path-to-regexp": "^1.7.0",
|
|
96
96
|
"prop-types": "^15.8.1",
|
|
@@ -112,5 +112,5 @@
|
|
|
112
112
|
"react-dom": ">= 16.8.6 < 17",
|
|
113
113
|
"semantic-ui-react": ">= 0.88.2 < 2.1"
|
|
114
114
|
},
|
|
115
|
-
"gitHead": "
|
|
115
|
+
"gitHead": "d3e3af905c2330f5e4aaeeefc3549acaa19575f7"
|
|
116
116
|
}
|
|
@@ -30,6 +30,8 @@ export const GrantRequest = ({ grantRequest, template }) => {
|
|
|
30
30
|
)(data_structure?.path);
|
|
31
31
|
const rows = grantRequest?.filters?.rows;
|
|
32
32
|
const user = grantRequest?._embedded?.group?._embedded?.user?.user_name;
|
|
33
|
+
const createdBy =
|
|
34
|
+
grantRequest?._embedded?.group?._embedded?.created_by?.user_name;
|
|
33
35
|
return (
|
|
34
36
|
<>
|
|
35
37
|
<GrantRequestCrumbs
|
|
@@ -75,6 +77,16 @@ export const GrantRequest = ({ grantRequest, template }) => {
|
|
|
75
77
|
</List.Description>
|
|
76
78
|
</List.Item>
|
|
77
79
|
)}
|
|
80
|
+
{createdBy && createdBy !== user && (
|
|
81
|
+
<List.Item>
|
|
82
|
+
<List.Header>
|
|
83
|
+
{formatMessage({ id: "grantRequest.header.createdBy" })}
|
|
84
|
+
</List.Header>
|
|
85
|
+
<List.Description>
|
|
86
|
+
<Label>{createdBy}</Label>
|
|
87
|
+
</List.Description>
|
|
88
|
+
</List.Item>
|
|
89
|
+
)}
|
|
78
90
|
<List.Item>
|
|
79
91
|
<List.Header>
|
|
80
92
|
{formatMessage({ id: "grantRequest.header.status" })}
|
|
@@ -15,6 +15,7 @@ export const GrantRequests = ({
|
|
|
15
15
|
}) => {
|
|
16
16
|
const { formatMessage } = useIntl();
|
|
17
17
|
const history = useHistory();
|
|
18
|
+
|
|
18
19
|
return (
|
|
19
20
|
<Segment attached="bottom">
|
|
20
21
|
{!_.isEmpty(grantRequests) && (
|
|
@@ -36,21 +37,29 @@ export const GrantRequests = ({
|
|
|
36
37
|
</Table.Row>
|
|
37
38
|
</Table.Header>
|
|
38
39
|
<Table.Body>
|
|
39
|
-
{grantRequests.map((grantRequest, i) =>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
40
|
+
{grantRequests.map((grantRequest, i) => {
|
|
41
|
+
const createdById = _.path("_embedded.group.created_by_id")(
|
|
42
|
+
grantRequest
|
|
43
|
+
);
|
|
44
|
+
const userId = _.path("_embedded.group._embedded.user.id")(
|
|
45
|
+
grantRequest
|
|
46
|
+
);
|
|
47
|
+
return (
|
|
48
|
+
<Table.Row key={i} warning={createdById !== userId}>
|
|
49
|
+
{columns &&
|
|
50
|
+
columns.map((column, key) => (
|
|
51
|
+
<Table.Cell
|
|
52
|
+
key={key}
|
|
53
|
+
textAlign={column.textAlign}
|
|
54
|
+
onClick={() =>
|
|
55
|
+
history.push(linkTo.GRANT_REQUEST(grantRequest))
|
|
56
|
+
}
|
|
57
|
+
content={columnDecoratorComponent(column)(grantRequest)}
|
|
58
|
+
/>
|
|
59
|
+
))}
|
|
60
|
+
</Table.Row>
|
|
61
|
+
);
|
|
62
|
+
})}
|
|
54
63
|
</Table.Body>
|
|
55
64
|
</Table>
|
|
56
65
|
)}
|
|
@@ -8,7 +8,7 @@ import { HistoryBackButton } from "@truedat/core/components";
|
|
|
8
8
|
import { useIntl, FormattedMessage } from "react-intl";
|
|
9
9
|
import { checkoutGrantRequest } from "../routines";
|
|
10
10
|
import StructureGrantCart from "./StructureGrantCart";
|
|
11
|
-
import
|
|
11
|
+
import StructureGrantCartInformation from "./StructureGrantCartInformation";
|
|
12
12
|
|
|
13
13
|
export const StructureGrantCartCheckout = ({
|
|
14
14
|
grantRequestsCart,
|
|
@@ -16,7 +16,7 @@ export const StructureGrantCartCheckout = ({
|
|
|
16
16
|
}) => {
|
|
17
17
|
const { formatMessage } = useIntl();
|
|
18
18
|
|
|
19
|
-
const { template, templateContent, modificationGrant, validCart } =
|
|
19
|
+
const { template, templateContent, modificationGrant, validCart, user } =
|
|
20
20
|
grantRequestsCart;
|
|
21
21
|
|
|
22
22
|
const checkout = () => {
|
|
@@ -30,11 +30,12 @@ export const StructureGrantCartCheckout = ({
|
|
|
30
30
|
};
|
|
31
31
|
})(grantRequestsCart.structures);
|
|
32
32
|
const payload = {
|
|
33
|
-
grant_request_group: {
|
|
33
|
+
grant_request_group: _.omitBy(_.isNil)({
|
|
34
34
|
requests,
|
|
35
35
|
type: template,
|
|
36
36
|
modification_grant_id: modificationGrant ? modificationGrant.id : null,
|
|
37
|
-
|
|
37
|
+
user_id: user?.id,
|
|
38
|
+
}),
|
|
38
39
|
};
|
|
39
40
|
checkoutGrantRequest(payload);
|
|
40
41
|
};
|
|
@@ -61,14 +62,14 @@ export const StructureGrantCartCheckout = ({
|
|
|
61
62
|
<Button
|
|
62
63
|
primary
|
|
63
64
|
onClick={checkout}
|
|
64
|
-
disabled={!validCart}
|
|
65
|
+
disabled={!validCart || !user.valid}
|
|
65
66
|
content={formatMessage({ id: "actions.save" })}
|
|
66
67
|
/>
|
|
67
68
|
</GridColumn>
|
|
68
69
|
</Grid.Row>
|
|
69
70
|
<Grid.Row>
|
|
70
71
|
<Grid.Column width={5}>
|
|
71
|
-
<
|
|
72
|
+
<StructureGrantCartInformation />
|
|
72
73
|
</Grid.Column>
|
|
73
74
|
<Grid.Column width={11}>
|
|
74
75
|
<StructureGrantCart />
|
|
@@ -1,29 +1,36 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
2
|
import React from "react";
|
|
3
|
+
import { useQuery } from "@apollo/client";
|
|
3
4
|
import PropTypes from "prop-types";
|
|
4
5
|
import { Segment, Divider, Form, Header } from "semantic-ui-react";
|
|
5
6
|
import { connect } from "react-redux";
|
|
6
7
|
import { useIntl } from "react-intl";
|
|
8
|
+
import { DOMAINS_QUERY } from "@truedat/core/api/queries";
|
|
7
9
|
import {
|
|
8
10
|
selectGrantRequestTemplate,
|
|
9
11
|
updateGrantRequestTemplateContent,
|
|
10
12
|
} from "../routines";
|
|
13
|
+
import StructureGrantCartUserSelector from "./StructureGrantCartUserSelector";
|
|
11
14
|
|
|
12
15
|
const SelectableDynamicForm = React.lazy(() =>
|
|
13
16
|
import("@truedat/df/components/SelectableDynamicForm")
|
|
14
17
|
);
|
|
15
18
|
|
|
16
|
-
export const
|
|
19
|
+
export const StructureGrantCartInformation = ({
|
|
17
20
|
grantRequestsCart,
|
|
18
21
|
selectGrantRequestTemplate,
|
|
19
22
|
updateGrantRequestTemplateContent,
|
|
20
23
|
}) => {
|
|
21
24
|
const { formatMessage } = useIntl();
|
|
22
|
-
|
|
23
25
|
const templateContent = _.pathOr({}, "templateContent")(grantRequestsCart);
|
|
24
26
|
|
|
27
|
+
const { loading, data } = useQuery(DOMAINS_QUERY, {
|
|
28
|
+
fetchPolicy: "cache-and-network",
|
|
29
|
+
variables: { action: "createForeignGrantRequest" },
|
|
30
|
+
});
|
|
31
|
+
|
|
25
32
|
return (
|
|
26
|
-
<Segment>
|
|
33
|
+
<Segment loading={loading}>
|
|
27
34
|
<Header
|
|
28
35
|
title={`${formatMessage({ id: `structure.grant.cart.template` })}`}
|
|
29
36
|
>
|
|
@@ -31,6 +38,9 @@ export const StructureGrantCartTemplate = ({
|
|
|
31
38
|
</Header>
|
|
32
39
|
<Divider />
|
|
33
40
|
<Form>
|
|
41
|
+
{!loading && !_.isEmpty(data?.domains) ? (
|
|
42
|
+
<StructureGrantCartUserSelector />
|
|
43
|
+
) : null}
|
|
34
44
|
<SelectableDynamicForm
|
|
35
45
|
scope="gr"
|
|
36
46
|
required
|
|
@@ -47,7 +57,7 @@ export const StructureGrantCartTemplate = ({
|
|
|
47
57
|
);
|
|
48
58
|
};
|
|
49
59
|
|
|
50
|
-
|
|
60
|
+
StructureGrantCartInformation.propTypes = {
|
|
51
61
|
grantRequestsCart: PropTypes.object,
|
|
52
62
|
selectGrantRequestTemplate: PropTypes.func,
|
|
53
63
|
updateGrantRequestTemplateContent: PropTypes.func,
|
|
@@ -58,4 +68,4 @@ const mapStateToProps = ({ grantRequestsCart }) => ({ grantRequestsCart });
|
|
|
58
68
|
export default connect(mapStateToProps, {
|
|
59
69
|
selectGrantRequestTemplate,
|
|
60
70
|
updateGrantRequestTemplateContent,
|
|
61
|
-
})(
|
|
71
|
+
})(StructureGrantCartInformation);
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import React, { useEffect, useState } from "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import { Form, Checkbox } from "semantic-ui-react";
|
|
5
|
+
import { connect } from "react-redux";
|
|
6
|
+
import { useIntl } from "react-intl";
|
|
7
|
+
import { lowerDeburrTrim } from "@truedat/core/services/sort";
|
|
8
|
+
import { updateGrantRequestUser } from "../routines";
|
|
9
|
+
|
|
10
|
+
const UsersSearchLoader = React.lazy(() =>
|
|
11
|
+
import("@truedat/auth/users/components/UsersSearchLoader")
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
export const StructureGrantCartUserSelector = ({
|
|
15
|
+
grantRequestsCart,
|
|
16
|
+
updateGrantRequestUser,
|
|
17
|
+
options,
|
|
18
|
+
}) => {
|
|
19
|
+
const { formatMessage } = useIntl();
|
|
20
|
+
const [usersGroupsQuery, setUsersGroupsQuery] = useState("");
|
|
21
|
+
const [thirdParty, setThirdParty] = useState(false);
|
|
22
|
+
const [userId, setUserId] = useState(_.path("user.id")(grantRequestsCart));
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
updateGrantRequestUser({
|
|
26
|
+
id: userId,
|
|
27
|
+
valid:
|
|
28
|
+
!thirdParty || (thirdParty && !(_.isNil(userId) && _.isEmpty(userId))),
|
|
29
|
+
});
|
|
30
|
+
}, [userId, thirdParty]);
|
|
31
|
+
|
|
32
|
+
const onSearch = (_currentOptions, { searchQuery }) =>
|
|
33
|
+
setUsersGroupsQuery(lowerDeburrTrim(searchQuery));
|
|
34
|
+
|
|
35
|
+
const selectUser = (userId) => {
|
|
36
|
+
setUserId(userId);
|
|
37
|
+
if (!_.isNil(userId)) setThirdParty(true);
|
|
38
|
+
if (userId === "") setThirdParty(false);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<>
|
|
43
|
+
<UsersSearchLoader
|
|
44
|
+
query={usersGroupsQuery}
|
|
45
|
+
permission="allow_foreign_grant_request"
|
|
46
|
+
hideLoading
|
|
47
|
+
/>
|
|
48
|
+
<Form.Dropdown
|
|
49
|
+
placeholder={formatMessage({
|
|
50
|
+
id: "grantRequestCart.user.placeholder",
|
|
51
|
+
})}
|
|
52
|
+
clearable
|
|
53
|
+
onChange={(_e, { value }) => selectUser(value)}
|
|
54
|
+
deburr
|
|
55
|
+
onSearchChange={onSearch}
|
|
56
|
+
search={_.identity}
|
|
57
|
+
selection
|
|
58
|
+
required={thirdParty}
|
|
59
|
+
label={
|
|
60
|
+
<Checkbox
|
|
61
|
+
label={formatMessage({ id: "grantRequestCart.user.label" })}
|
|
62
|
+
onChange={(e, data) => {
|
|
63
|
+
setThirdParty(data.checked);
|
|
64
|
+
selectUser(null);
|
|
65
|
+
}}
|
|
66
|
+
checked={thirdParty}
|
|
67
|
+
/>
|
|
68
|
+
}
|
|
69
|
+
options={options}
|
|
70
|
+
value={userId}
|
|
71
|
+
/>
|
|
72
|
+
</>
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
StructureGrantCartUserSelector.propTypes = {
|
|
77
|
+
grantRequestsCart: PropTypes.object,
|
|
78
|
+
options: PropTypes.array,
|
|
79
|
+
updateGrantRequestUser: PropTypes.func,
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const mapStateToProps = ({ grantRequestsCart, usersSearch }) => ({
|
|
83
|
+
grantRequestsCart,
|
|
84
|
+
options: _.map(({ full_name, id }) => ({
|
|
85
|
+
text: full_name,
|
|
86
|
+
value: id,
|
|
87
|
+
icon: "user",
|
|
88
|
+
}))(usersSearch),
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
export default connect(mapStateToProps, { updateGrantRequestUser })(
|
|
92
|
+
StructureGrantCartUserSelector
|
|
93
|
+
);
|
|
@@ -11,12 +11,15 @@ import { Date } from "@truedat/core/components";
|
|
|
11
11
|
import GrantChangeRequest from "./GrantChangeRequest";
|
|
12
12
|
import GrantRemoval from "./GrantRemoval";
|
|
13
13
|
import GrantRequestCancel from "./GrantRequestCancel";
|
|
14
|
+
import StructureGrantRequestAddCart from "./StructureGrantRequestAddCart";
|
|
14
15
|
|
|
15
16
|
const isNilOrEmpty = (value) => _.isEmpty(value) || _.isNil(value);
|
|
16
17
|
export const StructureGrantDropdown = ({
|
|
17
18
|
grantRequest,
|
|
18
19
|
structure,
|
|
19
20
|
structureGrantPopup,
|
|
21
|
+
authorized,
|
|
22
|
+
requested,
|
|
20
23
|
}) => {
|
|
21
24
|
const history = useHistory();
|
|
22
25
|
const { formatMessage } = useIntl();
|
|
@@ -32,8 +35,19 @@ export const StructureGrantDropdown = ({
|
|
|
32
35
|
const isModification = _.prop("group.grant")(grantRequest);
|
|
33
36
|
|
|
34
37
|
const actions = {
|
|
38
|
+
addToCart: (
|
|
39
|
+
<StructureGrantRequestAddCart structure={structure} key="addToCart">
|
|
40
|
+
<Dropdown.Item
|
|
41
|
+
icon="cart"
|
|
42
|
+
text={formatMessage({
|
|
43
|
+
id: "structure.grant.request_grant",
|
|
44
|
+
})}
|
|
45
|
+
/>
|
|
46
|
+
</StructureGrantRequestAddCart>
|
|
47
|
+
),
|
|
35
48
|
viewRequest: (
|
|
36
49
|
<Dropdown.Item
|
|
50
|
+
key="viewRequest"
|
|
37
51
|
onClick={() =>
|
|
38
52
|
history.push(linkTo.GRANT_REQUEST({ id: grantRequest.id }))
|
|
39
53
|
}
|
|
@@ -44,7 +58,7 @@ export const StructureGrantDropdown = ({
|
|
|
44
58
|
/>
|
|
45
59
|
),
|
|
46
60
|
requestRemoval: (
|
|
47
|
-
<GrantRemoval grant={grant}>
|
|
61
|
+
<GrantRemoval grant={grant} key="requestRemoval">
|
|
48
62
|
<Dropdown.Item
|
|
49
63
|
icon="delete"
|
|
50
64
|
text={formatMessage({
|
|
@@ -54,7 +68,7 @@ export const StructureGrantDropdown = ({
|
|
|
54
68
|
</GrantRemoval>
|
|
55
69
|
),
|
|
56
70
|
cancelRemoval: (
|
|
57
|
-
<GrantRemoval grant={grant}>
|
|
71
|
+
<GrantRemoval grant={grant} key="cancelRemoval">
|
|
58
72
|
<Dropdown.Item
|
|
59
73
|
icon="delete"
|
|
60
74
|
text={formatMessage({
|
|
@@ -64,7 +78,11 @@ export const StructureGrantDropdown = ({
|
|
|
64
78
|
</GrantRemoval>
|
|
65
79
|
),
|
|
66
80
|
requestChange: (
|
|
67
|
-
<GrantChangeRequest
|
|
81
|
+
<GrantChangeRequest
|
|
82
|
+
structure={structure}
|
|
83
|
+
grant={grant}
|
|
84
|
+
key="requestChange"
|
|
85
|
+
>
|
|
68
86
|
<Dropdown.Item
|
|
69
87
|
icon="edit"
|
|
70
88
|
text={formatMessage({
|
|
@@ -75,6 +93,7 @@ export const StructureGrantDropdown = ({
|
|
|
75
93
|
),
|
|
76
94
|
cancelRequest: (
|
|
77
95
|
<GrantRequestCancel
|
|
96
|
+
key="cancelRequest"
|
|
78
97
|
structureId={structure.id}
|
|
79
98
|
grantRequest={grantRequest}
|
|
80
99
|
>
|
|
@@ -91,36 +110,27 @@ export const StructureGrantDropdown = ({
|
|
|
91
110
|
const dropdownStates = {
|
|
92
111
|
pendingRequest: {
|
|
93
112
|
color: "yellow",
|
|
94
|
-
options:
|
|
95
|
-
|
|
96
|
-
{actions["viewRequest"]}
|
|
97
|
-
{actions["cancelRequest"]}
|
|
98
|
-
</>
|
|
99
|
-
),
|
|
113
|
+
options: [actions["viewRequest"], actions["cancelRequest"]],
|
|
114
|
+
|
|
100
115
|
header: isModification
|
|
101
116
|
? "structure.grant.requested_modification"
|
|
102
117
|
: "structure.grant.requested_access",
|
|
103
118
|
},
|
|
104
119
|
processingRequest: {
|
|
105
120
|
color: "grey",
|
|
106
|
-
options: actions["viewRequest"],
|
|
121
|
+
options: [actions["viewRequest"]],
|
|
107
122
|
header: isModification
|
|
108
123
|
? "structure.grant.modification.attended"
|
|
109
124
|
: "structure.grant.access.attended",
|
|
110
125
|
},
|
|
111
126
|
pendingRemovalGrant: {
|
|
112
127
|
color: "red",
|
|
113
|
-
options: actions["cancelRemoval"],
|
|
128
|
+
options: [actions["cancelRemoval"]],
|
|
114
129
|
header: "structure.grant.has_grant_pending_removal",
|
|
115
130
|
},
|
|
116
131
|
activeGrant: {
|
|
117
132
|
color: "green",
|
|
118
|
-
options:
|
|
119
|
-
<>
|
|
120
|
-
{actions["requestChange"]}
|
|
121
|
-
{actions["requestRemoval"]}
|
|
122
|
-
</>
|
|
123
|
-
),
|
|
133
|
+
options: [actions["requestChange"], actions["requestRemoval"]],
|
|
124
134
|
header: "structure.grant.has_grant",
|
|
125
135
|
},
|
|
126
136
|
};
|
|
@@ -160,6 +170,11 @@ export const StructureGrantDropdown = ({
|
|
|
160
170
|
</>
|
|
161
171
|
);
|
|
162
172
|
|
|
173
|
+
const optionsWithCart =
|
|
174
|
+
authorized && !requested
|
|
175
|
+
? [actions["addToCart"], ...stateProps.options]
|
|
176
|
+
: stateProps.options;
|
|
177
|
+
|
|
163
178
|
const trigger = (
|
|
164
179
|
<Dropdown
|
|
165
180
|
icon={null}
|
|
@@ -173,7 +188,9 @@ export const StructureGrantDropdown = ({
|
|
|
173
188
|
/>
|
|
174
189
|
}
|
|
175
190
|
>
|
|
176
|
-
<Dropdown.Menu>
|
|
191
|
+
<Dropdown.Menu>
|
|
192
|
+
<>{optionsWithCart}</>
|
|
193
|
+
</Dropdown.Menu>
|
|
177
194
|
</Dropdown>
|
|
178
195
|
);
|
|
179
196
|
return <Popup content={popupContent} trigger={trigger} />;
|
|
@@ -183,12 +200,16 @@ StructureGrantDropdown.propTypes = {
|
|
|
183
200
|
grantRequest: PropTypes.object,
|
|
184
201
|
structure: PropTypes.object,
|
|
185
202
|
structureGrantPopup: PropTypes.array,
|
|
203
|
+
authorized: PropTypes.bool,
|
|
204
|
+
requested: PropTypes.bool,
|
|
186
205
|
};
|
|
187
206
|
|
|
188
207
|
const mapStateToProps = ({
|
|
189
208
|
structure,
|
|
190
209
|
structureFields,
|
|
191
210
|
structureGrantPopup,
|
|
211
|
+
userPermissions,
|
|
212
|
+
grantRequestsCart,
|
|
192
213
|
}) => ({
|
|
193
214
|
structure: {
|
|
194
215
|
...structure,
|
|
@@ -196,6 +217,12 @@ const mapStateToProps = ({
|
|
|
196
217
|
structureFields,
|
|
197
218
|
},
|
|
198
219
|
structureGrantPopup,
|
|
220
|
+
requested: _.flow(
|
|
221
|
+
_.pathOr([], "structures"),
|
|
222
|
+
_.find({ id: structure.id }),
|
|
223
|
+
_.negate(_.isUndefined)
|
|
224
|
+
)(grantRequestsCart),
|
|
225
|
+
authorized: _.pathOr(false, "create_foreign_grant_request")(userPermissions),
|
|
199
226
|
});
|
|
200
227
|
|
|
201
228
|
export default connect(mapStateToProps)(StructureGrantDropdown);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import { connect } from "react-redux";
|
|
4
|
+
import { addGrantRequestToCart } from "../routines";
|
|
5
|
+
|
|
6
|
+
export const StructureGrantRequestAddCart = ({
|
|
7
|
+
structure,
|
|
8
|
+
addGrantRequestToCart,
|
|
9
|
+
children,
|
|
10
|
+
}) => {
|
|
11
|
+
if (!structure) return;
|
|
12
|
+
|
|
13
|
+
return React.cloneElement(children, {
|
|
14
|
+
onClick: () => addGrantRequestToCart(structure),
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
StructureGrantRequestAddCart.propTypes = {
|
|
19
|
+
structure: PropTypes.object,
|
|
20
|
+
addGrantRequestToCart: PropTypes.func,
|
|
21
|
+
children: PropTypes.node,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default connect(null, { addGrantRequestToCart })(
|
|
25
|
+
StructureGrantRequestAddCart
|
|
26
|
+
);
|
|
@@ -24,7 +24,13 @@ describe("<MyGrantRequests />", () => {
|
|
|
24
24
|
};
|
|
25
25
|
it("matches the latest snapshot", async () => {
|
|
26
26
|
const grantRequests = [
|
|
27
|
-
{
|
|
27
|
+
{
|
|
28
|
+
data_structure: "foo > bar",
|
|
29
|
+
status: "processed",
|
|
30
|
+
_embedded: {
|
|
31
|
+
group: { created_by_id: 3, _embedded: { user: { id: 4 } } },
|
|
32
|
+
},
|
|
33
|
+
},
|
|
28
34
|
];
|
|
29
35
|
const columns = [{ name: "data_structure" }, { name: "status" }];
|
|
30
36
|
const setGrantRequestsQuery = jest.fn();
|
|
@@ -45,7 +51,13 @@ describe("<MyGrantRequests />", () => {
|
|
|
45
51
|
|
|
46
52
|
it("deselects and selects filters", async () => {
|
|
47
53
|
const grantRequests = [
|
|
48
|
-
{
|
|
54
|
+
{
|
|
55
|
+
data_structure: "foo > bar",
|
|
56
|
+
status: "processed",
|
|
57
|
+
_embedded: {
|
|
58
|
+
group: { created_by_id: 3, _embedded: { user: { id: 3 } } },
|
|
59
|
+
},
|
|
60
|
+
},
|
|
49
61
|
];
|
|
50
62
|
const columns = [{ name: "data_structure" }, { name: "status" }];
|
|
51
63
|
const setGrantRequestsQuery = jest.fn();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { Suspense } from "react";
|
|
2
2
|
import { render } from "@truedat/test/render";
|
|
3
3
|
import { singleTemplateMock } from "@truedat/test/mocks";
|
|
4
|
-
import {
|
|
4
|
+
import { StructureGrantCartInformation } from "../StructureGrantCartInformation";
|
|
5
5
|
|
|
6
|
-
describe("<
|
|
6
|
+
describe("<StructureGrantCartInformation />", () => {
|
|
7
7
|
const selectGrantRequestTemplate = jest.fn();
|
|
8
8
|
const updateGrantRequestTemplateContent = jest.fn();
|
|
9
9
|
|
|
@@ -36,7 +36,7 @@ describe("<StructureGrantCartTemplate />", () => {
|
|
|
36
36
|
it("matches the latest snapshot", () => {
|
|
37
37
|
const { container } = render(
|
|
38
38
|
<Suspense fallback={null}>
|
|
39
|
-
<
|
|
39
|
+
<StructureGrantCartInformation {...props} />
|
|
40
40
|
</Suspense>,
|
|
41
41
|
renderOpts
|
|
42
42
|
);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import StructureGrantCartUserSelector from "../StructureGrantCartUserSelector";
|
|
4
|
+
|
|
5
|
+
const renderOpts = {
|
|
6
|
+
state: {
|
|
7
|
+
grantRequestsCart: { user: { id: 5 } },
|
|
8
|
+
usersSearch: [{ full_name: "name", id: 1 }],
|
|
9
|
+
},
|
|
10
|
+
fallback: "lazy",
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
describe("<StructureGrantCartUserSelector />", () => {
|
|
14
|
+
it("matches the latest snapshot", () => {
|
|
15
|
+
const { container } = render(
|
|
16
|
+
<StructureGrantCartUserSelector query="abc" />,
|
|
17
|
+
renderOpts
|
|
18
|
+
);
|
|
19
|
+
expect(container).toMatchSnapshot();
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`<
|
|
3
|
+
exports[`<StructureGrantCartInformation /> matches the latest snapshot 1`] = `
|
|
4
4
|
<div>
|
|
5
5
|
<div
|
|
6
|
-
class="ui segment"
|
|
6
|
+
class="ui loading segment"
|
|
7
7
|
style="display: none;"
|
|
8
8
|
>
|
|
9
9
|
<div
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`<StructureGrantCartUserSelector /> matches the latest snapshot 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<div
|
|
6
|
+
class="field"
|
|
7
|
+
style="display: none;"
|
|
8
|
+
>
|
|
9
|
+
<div
|
|
10
|
+
class="ui checkbox"
|
|
11
|
+
>
|
|
12
|
+
<input
|
|
13
|
+
class="hidden"
|
|
14
|
+
readonly=""
|
|
15
|
+
tabindex="0"
|
|
16
|
+
type="checkbox"
|
|
17
|
+
value=""
|
|
18
|
+
/>
|
|
19
|
+
<label>
|
|
20
|
+
Request for:
|
|
21
|
+
</label>
|
|
22
|
+
</div>
|
|
23
|
+
<div
|
|
24
|
+
aria-expanded="false"
|
|
25
|
+
class="ui search selection dropdown"
|
|
26
|
+
role="combobox"
|
|
27
|
+
>
|
|
28
|
+
<input
|
|
29
|
+
aria-autocomplete="list"
|
|
30
|
+
autocomplete="off"
|
|
31
|
+
class="search"
|
|
32
|
+
tabindex="0"
|
|
33
|
+
type="text"
|
|
34
|
+
value=""
|
|
35
|
+
/>
|
|
36
|
+
<div
|
|
37
|
+
aria-atomic="true"
|
|
38
|
+
aria-live="polite"
|
|
39
|
+
class="divider text"
|
|
40
|
+
role="alert"
|
|
41
|
+
>
|
|
42
|
+
Select user
|
|
43
|
+
</div>
|
|
44
|
+
<i
|
|
45
|
+
aria-hidden="true"
|
|
46
|
+
class="dropdown icon clear"
|
|
47
|
+
/>
|
|
48
|
+
<div
|
|
49
|
+
class="menu transition"
|
|
50
|
+
role="listbox"
|
|
51
|
+
>
|
|
52
|
+
<div
|
|
53
|
+
aria-checked="false"
|
|
54
|
+
aria-selected="true"
|
|
55
|
+
class="selected item"
|
|
56
|
+
role="option"
|
|
57
|
+
style="pointer-events: all;"
|
|
58
|
+
>
|
|
59
|
+
<i
|
|
60
|
+
aria-hidden="true"
|
|
61
|
+
class="user icon"
|
|
62
|
+
/>
|
|
63
|
+
<span
|
|
64
|
+
class="text"
|
|
65
|
+
>
|
|
66
|
+
name
|
|
67
|
+
</span>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
lazy
|
|
73
|
+
</div>
|
|
74
|
+
`;
|
package/src/messages/en.js
CHANGED
|
@@ -76,11 +76,13 @@ export default {
|
|
|
76
76
|
"grantRequest.header.status": "Status",
|
|
77
77
|
"grantRequest.header.updated_at": "Updated",
|
|
78
78
|
"grantRequest.header.user": "User",
|
|
79
|
-
|
|
79
|
+
"grantRequest.header.createdBy": "Created by",
|
|
80
80
|
"grantRequest.header.create": "Create grant request",
|
|
81
81
|
"grantRequest.header.update": "Request grant change",
|
|
82
82
|
"grantRequest.summary.emptyApprovals": "No approves",
|
|
83
83
|
"grantRequest.summary.pendingRoles": "Pending roles",
|
|
84
|
+
"grantRequestCart.user.label": "Request for:",
|
|
85
|
+
"grantRequestCart.user.placeholder": "Select user",
|
|
84
86
|
"grantRequestApproval.content.approved": "Approved",
|
|
85
87
|
"grantRequestApproval.content.comment": "Comment",
|
|
86
88
|
"grantRequestApproval.content.inserted_at": "Date",
|
package/src/messages/es.js
CHANGED
|
@@ -80,10 +80,13 @@ export default {
|
|
|
80
80
|
"grantRequest.header.status": "Estado",
|
|
81
81
|
"grantRequest.header.updated_at": "Actualizado",
|
|
82
82
|
"grantRequest.header.user": "Usuario",
|
|
83
|
+
"grantRequest.header.createdBy": "Creado por",
|
|
83
84
|
"grantRequest.header.create": "Crear petición de acceso",
|
|
84
85
|
"grantRequest.header.update": "Petición de modificación de acceso",
|
|
85
86
|
"grantRequest.summary.emptyApprovals": "Sin aprobaciones",
|
|
86
87
|
"grantRequest.summary.pendingRoles": "Roles pendientes",
|
|
88
|
+
"grantRequestCart.user.label": "Solicitud para:",
|
|
89
|
+
"grantRequestCart.user.placeholder": "Seleccionar usuario",
|
|
87
90
|
"grantRequestApproval.content.approved": "Aprobada",
|
|
88
91
|
"grantRequestApproval.content.comment": "Comentario",
|
|
89
92
|
"grantRequestApproval.content.inserted_at": "Fecha",
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
setGrantChangeRequestCart,
|
|
9
9
|
updateGrantRequestFilter,
|
|
10
10
|
updateGrantRequestTemplateContent,
|
|
11
|
+
updateGrantRequestUser,
|
|
11
12
|
} from "../routines";
|
|
12
13
|
|
|
13
14
|
const initialState = {
|
|
@@ -15,6 +16,7 @@ const initialState = {
|
|
|
15
16
|
template: null,
|
|
16
17
|
templateContent: {},
|
|
17
18
|
modificationGrant: null,
|
|
19
|
+
userId: { id: null, valid: true },
|
|
18
20
|
};
|
|
19
21
|
const mapPayload = (payload) =>
|
|
20
22
|
payload?.class === "field" ? { ...payload, filters: [] } : payload;
|
|
@@ -62,6 +64,14 @@ const grantRequestsCart = (state = initialState, { type, payload }) => {
|
|
|
62
64
|
templateContent: content,
|
|
63
65
|
validCart: state.template && _.size(valid) === 0,
|
|
64
66
|
};
|
|
67
|
+
case updateGrantRequestUser.TRIGGER:
|
|
68
|
+
return {
|
|
69
|
+
...state,
|
|
70
|
+
user: {
|
|
71
|
+
id: payload.id,
|
|
72
|
+
valid: payload.valid,
|
|
73
|
+
},
|
|
74
|
+
};
|
|
65
75
|
case setGrantChangeRequestCart.TRIGGER:
|
|
66
76
|
const { structure, grant } = payload;
|
|
67
77
|
return {
|
package/src/routines.js
CHANGED
|
@@ -118,6 +118,7 @@ export const toggleStructureFilterValue = createRoutine("TOGGLE_STRUCTURE_FILTER
|
|
|
118
118
|
export const updateGrant = createRoutine("UPDATE_GRANT");
|
|
119
119
|
export const updateGrantRequestFilter = createRoutine("UPDATE_GRANT_REQUEST_FILTER_SAGA");
|
|
120
120
|
export const updateGrantRequestTemplateContent = createRoutine("UPDATE_GRANT_REQUEST_TEMPLATE_CONTENT");
|
|
121
|
+
export const updateGrantRequestUser = createRoutine("UPDATE_GRANT_REQUEST_USER");
|
|
121
122
|
export const updateReferenceDataset = createRoutine("UPDATE_REFERENCE_DATASET");
|
|
122
123
|
export const updateStructure = createRoutine("UPDATE_STRUCTURE");
|
|
123
124
|
export const updateStructureType = createRoutine("UPDATE_STRUCTURE_TYPE");
|