@truedat/dd 4.58.0 → 4.58.1
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 +7 -6
- package/src/components/Grant.js +225 -0
- package/src/components/GrantApprovalRuleConditions.js +1 -1
- package/src/components/GrantCrumbs.js +24 -0
- package/src/components/GrantRemoval.js +14 -5
- package/src/components/GrantRoutes.js +108 -100
- package/src/components/__tests__/Grant.spec.js +81 -0
- package/src/components/__tests__/GrantApprovalRuleConditions.spec.js +0 -1
- package/src/components/__tests__/GrantCrumbs.spec.js +10 -0
- package/src/components/__tests__/GrantRemoval.spec.js +25 -4
- package/src/components/__tests__/GrantsTable.spec.js +7 -6
- package/src/components/__tests__/StructureGrants.spec.js +6 -0
- package/src/components/__tests__/StructureLoader.spec.js +1 -1
- package/src/components/__tests__/__snapshots__/Grant.spec.js.snap +468 -0
- package/src/components/__tests__/__snapshots__/GrantCrumbs.spec.js.snap +102 -0
- package/src/components/__tests__/__snapshots__/GrantRoutes.spec.js.snap +12 -4
- package/src/components/__tests__/__snapshots__/GrantsTable.spec.js.snap +41 -15
- package/src/components/__tests__/__snapshots__/StructureGrants.spec.js.snap +19 -0
- package/src/hooks/useGrant.js +18 -0
- package/src/messages/en.js +9 -2
- package/src/messages/es.js +9 -2
- package/src/sagas/__tests__/fetchStructure.spec.js +1 -1
- package/src/selectors/__tests__/__snapshots__/getGrantsColumns.spec.js.snap +10 -0
- package/src/selectors/__tests__/getGrantsColumns.spec.js +9 -0
- package/src/selectors/getGrantsColumns.js +20 -0
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/dd",
|
|
3
|
-
"version": "4.58.
|
|
3
|
+
"version": "4.58.1",
|
|
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": "4.58.
|
|
37
|
+
"@truedat/test": "4.58.1",
|
|
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",
|
|
@@ -87,9 +87,9 @@
|
|
|
87
87
|
},
|
|
88
88
|
"dependencies": {
|
|
89
89
|
"@apollo/client": "^3.7.1",
|
|
90
|
-
"@truedat/auth": "4.58.
|
|
91
|
-
"@truedat/core": "4.58.
|
|
92
|
-
"@truedat/df": "4.58.
|
|
90
|
+
"@truedat/auth": "4.58.1",
|
|
91
|
+
"@truedat/core": "4.58.1",
|
|
92
|
+
"@truedat/df": "4.58.1",
|
|
93
93
|
"lodash": "^4.17.21",
|
|
94
94
|
"moment": "^2.29.4",
|
|
95
95
|
"path-to-regexp": "^1.7.0",
|
|
@@ -105,6 +105,7 @@
|
|
|
105
105
|
"reselect": "^4.1.7",
|
|
106
106
|
"semantic-ui-react": "^2.1.4",
|
|
107
107
|
"svg-pan-zoom": "^3.6.1",
|
|
108
|
+
"swr": "^2.0.0",
|
|
108
109
|
"uuid": "^8.3.2"
|
|
109
110
|
},
|
|
110
111
|
"peerDependencies": {
|
|
@@ -113,5 +114,5 @@
|
|
|
113
114
|
"react-dom": ">= 16.8.6 < 17",
|
|
114
115
|
"semantic-ui-react": ">= 2.0.3 < 2.2"
|
|
115
116
|
},
|
|
116
|
-
"gitHead": "
|
|
117
|
+
"gitHead": "f1d6fab3f573f3f3ee9e0e6060d2761d452ca804"
|
|
117
118
|
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import { useIntl } from "react-intl";
|
|
5
|
+
import { Link, useParams } from "react-router-dom";
|
|
6
|
+
|
|
7
|
+
import Moment from "react-moment";
|
|
8
|
+
import { Grid, Segment, Header, Icon, List, Button } from "semantic-ui-react";
|
|
9
|
+
|
|
10
|
+
import { linkTo } from "@truedat/core/routes";
|
|
11
|
+
import { useGrant, useGrantRemoval } from "../hooks/useGrant";
|
|
12
|
+
import GrantCrumbs from "./GrantCrumbs";
|
|
13
|
+
import GrantRemoval from "./GrantRemoval";
|
|
14
|
+
const DynamicFieldValue = React.lazy(() =>
|
|
15
|
+
import("@truedat/df/components/DynamicFieldValue")
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
const GrantView = () => {
|
|
19
|
+
const { id } = useParams();
|
|
20
|
+
const { data, loading } = useGrant(id);
|
|
21
|
+
const { trigger } = useGrantRemoval(id);
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<Grant
|
|
25
|
+
grant={data?.data}
|
|
26
|
+
actions={data?._actions}
|
|
27
|
+
loading={loading}
|
|
28
|
+
onStatusChange={trigger}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const GrantHeader = ({ grant, title, actions, onStatusChange }) => {
|
|
34
|
+
const { formatMessage } = useIntl();
|
|
35
|
+
return (
|
|
36
|
+
<Grid>
|
|
37
|
+
<Grid.Row>
|
|
38
|
+
<Grid.Column width={12}>
|
|
39
|
+
<Header as="h2">
|
|
40
|
+
<Icon circular name="key" />
|
|
41
|
+
<Header.Content>
|
|
42
|
+
{`${formatMessage({
|
|
43
|
+
id: "grant.header",
|
|
44
|
+
})} ${title}`}
|
|
45
|
+
</Header.Content>
|
|
46
|
+
</Header>
|
|
47
|
+
</Grid.Column>
|
|
48
|
+
<Grid.Column width={4} textAlign="right">
|
|
49
|
+
{actions?.request_removal ? (
|
|
50
|
+
<GrantRemoval grant={grant} onConfirm={onStatusChange}>
|
|
51
|
+
<Button
|
|
52
|
+
className="button icon group-actions"
|
|
53
|
+
color="red"
|
|
54
|
+
content={formatMessage({
|
|
55
|
+
id: "grant.actions.request_removal.button",
|
|
56
|
+
})}
|
|
57
|
+
/>
|
|
58
|
+
</GrantRemoval>
|
|
59
|
+
) : null}
|
|
60
|
+
{actions?.cancel_removal ? (
|
|
61
|
+
<GrantRemoval grant={grant} onConfirm={onStatusChange}>
|
|
62
|
+
<Button
|
|
63
|
+
className="button icon group-actions"
|
|
64
|
+
color="olive"
|
|
65
|
+
content={formatMessage({
|
|
66
|
+
id: "grant.actions.cancel_removal.button",
|
|
67
|
+
})}
|
|
68
|
+
/>
|
|
69
|
+
</GrantRemoval>
|
|
70
|
+
) : null}
|
|
71
|
+
</Grid.Column>
|
|
72
|
+
</Grid.Row>
|
|
73
|
+
</Grid>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
GrantHeader.propTypes = {
|
|
78
|
+
title: PropTypes.string,
|
|
79
|
+
actions: PropTypes.object,
|
|
80
|
+
grant: PropTypes.object,
|
|
81
|
+
onStatusChange: PropTypes.func,
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const Grant = ({ grant, actions, loading, onStatusChange }) => {
|
|
85
|
+
const { formatMessage } = useIntl();
|
|
86
|
+
|
|
87
|
+
const data_structure_version = _.pathOr(
|
|
88
|
+
undefined,
|
|
89
|
+
"data_structure_version"
|
|
90
|
+
)(grant);
|
|
91
|
+
const data_structure = _.pathOr(undefined, "data_structure")(grant);
|
|
92
|
+
|
|
93
|
+
const getTitle = ({ user, data_structure_version } = grant) => {
|
|
94
|
+
return `${user?.user_name ? `(${user?.user_name})` : ""} -> ${
|
|
95
|
+
data_structure_version?.name
|
|
96
|
+
}`;
|
|
97
|
+
};
|
|
98
|
+
const path = _.flow(
|
|
99
|
+
_.map("name"),
|
|
100
|
+
(names) => [...names, data_structure_version?.name],
|
|
101
|
+
_.join(" › ")
|
|
102
|
+
)(data_structure_version?.path);
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<>
|
|
106
|
+
{loading ? null : <GrantCrumbs title={getTitle(grant)} />}
|
|
107
|
+
<Segment loading={loading}>
|
|
108
|
+
{loading ? null : (
|
|
109
|
+
<Grid>
|
|
110
|
+
<Grid.Row>
|
|
111
|
+
<Grid.Column width={16}>
|
|
112
|
+
<GrantHeader
|
|
113
|
+
title={getTitle(grant)}
|
|
114
|
+
actions={actions}
|
|
115
|
+
grant={grant}
|
|
116
|
+
onStatusChange={onStatusChange}
|
|
117
|
+
/>
|
|
118
|
+
<List size="big" relaxed="very">
|
|
119
|
+
{data_structure_version && (
|
|
120
|
+
<List.Item>
|
|
121
|
+
<List.Content>
|
|
122
|
+
<List.Header>
|
|
123
|
+
{formatMessage({
|
|
124
|
+
id: "grant.header.data_structure",
|
|
125
|
+
})}
|
|
126
|
+
</List.Header>
|
|
127
|
+
<List.Description>
|
|
128
|
+
<Link to={linkTo.STRUCTURE_GRANTS(data_structure)}>
|
|
129
|
+
{path}
|
|
130
|
+
</Link>
|
|
131
|
+
</List.Description>
|
|
132
|
+
</List.Content>
|
|
133
|
+
</List.Item>
|
|
134
|
+
)}
|
|
135
|
+
{grant?.user && (
|
|
136
|
+
<List.Item>
|
|
137
|
+
<List.Header>
|
|
138
|
+
{formatMessage({ id: "grant.header.user" })}
|
|
139
|
+
</List.Header>
|
|
140
|
+
<List.Description>
|
|
141
|
+
<Header as="h4">
|
|
142
|
+
<Header.Content>
|
|
143
|
+
{grant?.user?.full_name}
|
|
144
|
+
<Header.Subheader>
|
|
145
|
+
{grant?.user?.email}
|
|
146
|
+
</Header.Subheader>
|
|
147
|
+
</Header.Content>
|
|
148
|
+
</Header>
|
|
149
|
+
</List.Description>
|
|
150
|
+
</List.Item>
|
|
151
|
+
)}
|
|
152
|
+
<List.Item>
|
|
153
|
+
<List.Header>
|
|
154
|
+
{formatMessage({ id: "grant.header.created_at" })}
|
|
155
|
+
</List.Header>
|
|
156
|
+
<List.Description>
|
|
157
|
+
<Moment
|
|
158
|
+
locale="es"
|
|
159
|
+
date={grant?.inserted_at}
|
|
160
|
+
format="YYYY-MM-DD HH:mm"
|
|
161
|
+
/>
|
|
162
|
+
</List.Description>
|
|
163
|
+
</List.Item>
|
|
164
|
+
<List.Item>
|
|
165
|
+
<List.Header>
|
|
166
|
+
{formatMessage({ id: "grant.header.start_date" })}
|
|
167
|
+
</List.Header>
|
|
168
|
+
<List.Description>
|
|
169
|
+
<Moment
|
|
170
|
+
locale="es"
|
|
171
|
+
date={grant?.start_date}
|
|
172
|
+
format="YYYY-MM-DD"
|
|
173
|
+
/>
|
|
174
|
+
</List.Description>
|
|
175
|
+
</List.Item>
|
|
176
|
+
<List.Item>
|
|
177
|
+
<List.Header>
|
|
178
|
+
{formatMessage({ id: "grant.header.end_date" })}
|
|
179
|
+
</List.Header>
|
|
180
|
+
<List.Description>
|
|
181
|
+
<Moment
|
|
182
|
+
locale="es"
|
|
183
|
+
date={grant?.end_date}
|
|
184
|
+
format="YYYY-MM-DD"
|
|
185
|
+
/>
|
|
186
|
+
</List.Description>
|
|
187
|
+
</List.Item>
|
|
188
|
+
{_.isEmpty(grant?.detail) ? null : (
|
|
189
|
+
<List.Item>
|
|
190
|
+
<List.Header>
|
|
191
|
+
{formatMessage({ id: "grant.header.details" })}
|
|
192
|
+
</List.Header>
|
|
193
|
+
<List.Description>
|
|
194
|
+
<List>
|
|
195
|
+
{Object.entries(grant?.detail).map(
|
|
196
|
+
([field, value], i) => (
|
|
197
|
+
<DynamicFieldValue
|
|
198
|
+
key={i}
|
|
199
|
+
label={field}
|
|
200
|
+
value={value}
|
|
201
|
+
/>
|
|
202
|
+
)
|
|
203
|
+
)}
|
|
204
|
+
</List>
|
|
205
|
+
</List.Description>
|
|
206
|
+
</List.Item>
|
|
207
|
+
)}
|
|
208
|
+
</List>
|
|
209
|
+
</Grid.Column>
|
|
210
|
+
</Grid.Row>
|
|
211
|
+
</Grid>
|
|
212
|
+
)}
|
|
213
|
+
</Segment>
|
|
214
|
+
</>
|
|
215
|
+
);
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
Grant.propTypes = {
|
|
219
|
+
grant: PropTypes.object.isRequired,
|
|
220
|
+
actions: PropTypes.object,
|
|
221
|
+
loading: PropTypes.bool,
|
|
222
|
+
onStatusChange: PropTypes.func,
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
export default GrantView;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import { Breadcrumb } from "semantic-ui-react";
|
|
4
|
+
import { Link } from "react-router-dom";
|
|
5
|
+
import { FormattedMessage } from "react-intl";
|
|
6
|
+
import { GRANTS } from "@truedat/core/routes";
|
|
7
|
+
|
|
8
|
+
export const GrantCrumbs = ({ title }) => (
|
|
9
|
+
<Breadcrumb>
|
|
10
|
+
<Breadcrumb.Section as={Link} to={GRANTS} active={false}>
|
|
11
|
+
<FormattedMessage id="grants.header" />
|
|
12
|
+
</Breadcrumb.Section>
|
|
13
|
+
<Breadcrumb.Divider icon="right angle" />
|
|
14
|
+
<Breadcrumb.Section active>
|
|
15
|
+
<FormattedMessage id={title} defaultMessage={title} />
|
|
16
|
+
</Breadcrumb.Section>
|
|
17
|
+
</Breadcrumb>
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
GrantCrumbs.propTypes = {
|
|
21
|
+
title: PropTypes.string.isRequired,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default GrantCrumbs;
|
|
@@ -3,9 +3,15 @@ import PropTypes from "prop-types";
|
|
|
3
3
|
import { connect } from "react-redux";
|
|
4
4
|
import { useIntl } from "react-intl";
|
|
5
5
|
import { ConfirmModal } from "@truedat/core/components";
|
|
6
|
+
import _ from "lodash";
|
|
6
7
|
import { requestGrantRemoval } from "../routines";
|
|
7
8
|
|
|
8
|
-
export const GrantRemoval = ({
|
|
9
|
+
export const GrantRemoval = ({
|
|
10
|
+
grant,
|
|
11
|
+
requestGrantRemoval,
|
|
12
|
+
children,
|
|
13
|
+
onConfirm,
|
|
14
|
+
}) => {
|
|
9
15
|
const { formatMessage } = useIntl();
|
|
10
16
|
|
|
11
17
|
if (!grant) return;
|
|
@@ -21,14 +27,16 @@ export const GrantRemoval = ({ grant, requestGrantRemoval, children }) => {
|
|
|
21
27
|
content={formatMessage({
|
|
22
28
|
id: `grant.actions.${action}.confirmation.content`,
|
|
23
29
|
})}
|
|
24
|
-
onConfirm={() =>
|
|
25
|
-
|
|
30
|
+
onConfirm={() => {
|
|
31
|
+
const onConfirmPayload = {
|
|
26
32
|
id: grant.id,
|
|
27
33
|
action,
|
|
28
34
|
data_structure_id: grant.data_structure.id,
|
|
29
35
|
version: grant.data_structure_version.id,
|
|
30
|
-
}
|
|
31
|
-
|
|
36
|
+
};
|
|
37
|
+
if (_.isFunction(onConfirm)) onConfirm(onConfirmPayload);
|
|
38
|
+
else requestGrantRemoval(onConfirmPayload);
|
|
39
|
+
}}
|
|
32
40
|
onOpen={(e) => e.stopPropagation()}
|
|
33
41
|
onClose={(e) => e.stopPropagation()}
|
|
34
42
|
/>
|
|
@@ -39,6 +47,7 @@ GrantRemoval.propTypes = {
|
|
|
39
47
|
grant: PropTypes.object,
|
|
40
48
|
requestGrantRemoval: PropTypes.func,
|
|
41
49
|
children: PropTypes.node,
|
|
50
|
+
onConfirm: PropTypes.func,
|
|
42
51
|
};
|
|
43
52
|
|
|
44
53
|
export default connect(null, { requestGrantRemoval })(GrantRemoval);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import PropTypes from "prop-types";
|
|
4
|
-
import { Route, Switch } from "react-router-dom";
|
|
5
2
|
import { connect } from "react-redux";
|
|
3
|
+
import { Route, Switch } from "react-router-dom";
|
|
4
|
+
import PropTypes from "prop-types";
|
|
5
|
+
import React from "react";
|
|
6
6
|
import {
|
|
7
7
|
GRANT_APPROVAL_RULE,
|
|
8
8
|
GRANT_APPROVAL_RULE_EDIT,
|
|
@@ -12,125 +12,133 @@ import {
|
|
|
12
12
|
GRANT_REQUESTS,
|
|
13
13
|
GRANTS_REQUESTS_CHECKOUT,
|
|
14
14
|
GRANTS,
|
|
15
|
+
GRANT,
|
|
15
16
|
GRANT_APPROVAL_RULES,
|
|
16
17
|
MY_GRANT_REQUESTS,
|
|
17
18
|
MY_GRANTS,
|
|
18
19
|
} from "@truedat/core/routes";
|
|
19
|
-
import
|
|
20
|
+
import GrantView from "./Grant";
|
|
21
|
+
import GrantApprovalRule from "./GrantApprovalRule";
|
|
20
22
|
import GrantApprovalRuleEdit from "./GrantApprovalRuleEdit";
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
+
import GrantApprovalRuleNew from "./GrantApprovalRuleNew";
|
|
24
|
+
import GrantApprovalRules from "./GrantApprovalRules";
|
|
23
25
|
import GrantFiltersLoader from "./GrantFiltersLoader";
|
|
24
|
-
import
|
|
26
|
+
import GrantRequest from "./GrantRequest";
|
|
27
|
+
import GrantRequestApprovals from "./GrantRequestApprovals";
|
|
25
28
|
import GrantRequestLoader from "./GrantRequestLoader";
|
|
26
|
-
import
|
|
29
|
+
import GrantRequestsLoader from "./GrantRequestsLoader";
|
|
27
30
|
import Grants from "./Grants";
|
|
28
|
-
import
|
|
29
|
-
import GrantApprovalRules from "./GrantApprovalRules";
|
|
31
|
+
import GrantsLoader from "./GrantsLoader";
|
|
30
32
|
import MyGrantRequests from "./MyGrantRequests";
|
|
31
|
-
import
|
|
33
|
+
import StructureGrantCartCheckout from "./StructureGrantCartCheckout";
|
|
32
34
|
|
|
33
35
|
const TemplatesLoader = React.lazy(() =>
|
|
34
36
|
import("@truedat/df/templates/components/TemplatesLoader")
|
|
35
37
|
);
|
|
36
38
|
|
|
37
|
-
export const GrantRoutes = ({ grantRequestLoaded }) =>
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
path={GRANTS_REQUESTS_CHECKOUT}
|
|
41
|
-
render={() => <StructureGrantCartCheckout />}
|
|
42
|
-
/>
|
|
43
|
-
<Route
|
|
44
|
-
path={GRANTS}
|
|
45
|
-
render={() => (
|
|
46
|
-
<>
|
|
47
|
-
<GrantsLoader />
|
|
48
|
-
<GrantFiltersLoader />
|
|
49
|
-
<Grants />
|
|
50
|
-
</>
|
|
51
|
-
)}
|
|
52
|
-
/>
|
|
53
|
-
<Route
|
|
54
|
-
path={MY_GRANTS}
|
|
55
|
-
render={() => (
|
|
56
|
-
<>
|
|
57
|
-
<GrantsLoader onlyMyGrants />
|
|
58
|
-
<GrantFiltersLoader onlyMyGrants />
|
|
59
|
-
<Grants onlyMyGrants />
|
|
60
|
-
</>
|
|
61
|
-
)}
|
|
62
|
-
/>
|
|
63
|
-
<Route
|
|
64
|
-
path={GRANT_REQUEST_APPROVALS}
|
|
65
|
-
render={() => (
|
|
66
|
-
<>
|
|
67
|
-
<GrantRequestsLoader
|
|
68
|
-
defaultPayload={{
|
|
69
|
-
action: "approve",
|
|
70
|
-
status: "pending",
|
|
71
|
-
}}
|
|
72
|
-
/>
|
|
73
|
-
<GrantRequestApprovals />
|
|
74
|
-
</>
|
|
75
|
-
)}
|
|
76
|
-
/>
|
|
77
|
-
<Route
|
|
78
|
-
path={MY_GRANT_REQUESTS}
|
|
79
|
-
render={() => (
|
|
80
|
-
<>
|
|
81
|
-
<GrantRequestsLoader
|
|
82
|
-
defaultPayload={{
|
|
83
|
-
user: "me",
|
|
84
|
-
status: "pending,approved,rejected,processing",
|
|
85
|
-
}}
|
|
86
|
-
/>
|
|
87
|
-
<MyGrantRequests />
|
|
88
|
-
</>
|
|
89
|
-
)}
|
|
90
|
-
/>
|
|
91
|
-
<Switch>
|
|
39
|
+
export const GrantRoutes = ({ grantRequestLoaded }) => {
|
|
40
|
+
return (
|
|
41
|
+
<>
|
|
92
42
|
<Route
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
render={() => <GrantApprovalRuleNew />}
|
|
43
|
+
path={GRANTS_REQUESTS_CHECKOUT}
|
|
44
|
+
render={() => <StructureGrantCartCheckout />}
|
|
96
45
|
/>
|
|
46
|
+
<Switch>
|
|
47
|
+
<Route exact path={GRANT} render={() => <GrantView />} />
|
|
48
|
+
<Route
|
|
49
|
+
exact
|
|
50
|
+
path={GRANTS}
|
|
51
|
+
render={() => (
|
|
52
|
+
<>
|
|
53
|
+
<GrantsLoader />
|
|
54
|
+
<GrantFiltersLoader />
|
|
55
|
+
<Grants />
|
|
56
|
+
</>
|
|
57
|
+
)}
|
|
58
|
+
/>
|
|
59
|
+
</Switch>
|
|
97
60
|
<Route
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
61
|
+
path={MY_GRANTS}
|
|
62
|
+
render={() => (
|
|
63
|
+
<>
|
|
64
|
+
<GrantsLoader onlyMyGrants />
|
|
65
|
+
<GrantFiltersLoader onlyMyGrants />
|
|
66
|
+
<Grants onlyMyGrants />
|
|
67
|
+
</>
|
|
68
|
+
)}
|
|
101
69
|
/>
|
|
102
70
|
<Route
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
71
|
+
path={GRANT_REQUEST_APPROVALS}
|
|
72
|
+
render={() => (
|
|
73
|
+
<>
|
|
74
|
+
<GrantRequestsLoader
|
|
75
|
+
defaultPayload={{
|
|
76
|
+
action: "approve",
|
|
77
|
+
status: "pending",
|
|
78
|
+
}}
|
|
79
|
+
/>
|
|
80
|
+
<GrantRequestApprovals />
|
|
81
|
+
</>
|
|
82
|
+
)}
|
|
106
83
|
/>
|
|
107
84
|
<Route
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
<>
|
|
117
|
-
<Switch>
|
|
118
|
-
<Route
|
|
119
|
-
path={GRANT_REQUEST}
|
|
120
|
-
render={() => (
|
|
121
|
-
<>
|
|
122
|
-
<GrantRequestLoader />
|
|
123
|
-
<TemplatesLoader scope="gr" />
|
|
124
|
-
{grantRequestLoaded && <GrantRequest />}
|
|
125
|
-
</>
|
|
126
|
-
)}
|
|
85
|
+
path={MY_GRANT_REQUESTS}
|
|
86
|
+
render={() => (
|
|
87
|
+
<>
|
|
88
|
+
<GrantRequestsLoader
|
|
89
|
+
defaultPayload={{
|
|
90
|
+
user: "me",
|
|
91
|
+
status: "pending,approved,rejected,processing",
|
|
92
|
+
}}
|
|
127
93
|
/>
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
94
|
+
<MyGrantRequests />
|
|
95
|
+
</>
|
|
96
|
+
)}
|
|
97
|
+
/>
|
|
98
|
+
<Switch>
|
|
99
|
+
<Route
|
|
100
|
+
exact
|
|
101
|
+
path={GRANT_APPROVAL_RULE_NEW}
|
|
102
|
+
render={() => <GrantApprovalRuleNew />}
|
|
103
|
+
/>
|
|
104
|
+
<Route
|
|
105
|
+
exact
|
|
106
|
+
path={GRANT_APPROVAL_RULE_EDIT}
|
|
107
|
+
render={() => <GrantApprovalRuleEdit />}
|
|
108
|
+
/>
|
|
109
|
+
<Route
|
|
110
|
+
exact
|
|
111
|
+
path={GRANT_APPROVAL_RULE}
|
|
112
|
+
render={() => <GrantApprovalRule />}
|
|
113
|
+
/>
|
|
114
|
+
<Route
|
|
115
|
+
exact
|
|
116
|
+
path={GRANT_APPROVAL_RULES}
|
|
117
|
+
render={() => <GrantApprovalRules />}
|
|
118
|
+
/>
|
|
119
|
+
</Switch>
|
|
120
|
+
<Route
|
|
121
|
+
path={GRANT_REQUESTS}
|
|
122
|
+
render={() => (
|
|
123
|
+
<>
|
|
124
|
+
<Switch>
|
|
125
|
+
<Route
|
|
126
|
+
path={GRANT_REQUEST}
|
|
127
|
+
render={() => (
|
|
128
|
+
<>
|
|
129
|
+
<GrantRequestLoader />
|
|
130
|
+
<TemplatesLoader scope="gr" />
|
|
131
|
+
{grantRequestLoaded && <GrantRequest />}
|
|
132
|
+
</>
|
|
133
|
+
)}
|
|
134
|
+
/>
|
|
135
|
+
</Switch>
|
|
136
|
+
</>
|
|
137
|
+
)}
|
|
138
|
+
/>
|
|
139
|
+
</>
|
|
140
|
+
);
|
|
141
|
+
};
|
|
134
142
|
|
|
135
143
|
const mapStateToProps = (state) => ({
|
|
136
144
|
grantRequestLoaded: !_.isEmpty(state.grantRequest),
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import userEvent from "@testing-library/user-event";
|
|
3
|
+
import { render } from "@truedat/test/render";
|
|
4
|
+
import { Grant } from "../Grant";
|
|
5
|
+
import en from "../../messages/en";
|
|
6
|
+
|
|
7
|
+
describe("<Grant />", () => {
|
|
8
|
+
const grant = {
|
|
9
|
+
data_structure: {
|
|
10
|
+
id: 2,
|
|
11
|
+
},
|
|
12
|
+
id: 1,
|
|
13
|
+
data_structure_version: {
|
|
14
|
+
name: "foo",
|
|
15
|
+
},
|
|
16
|
+
detail: {
|
|
17
|
+
foo: [1, 2, 3, 4],
|
|
18
|
+
bar: "baz",
|
|
19
|
+
},
|
|
20
|
+
start_date: "2018-12-01",
|
|
21
|
+
end_date: "2019-12-31",
|
|
22
|
+
inserted_at: "2022-12-12T12:49:09.789722Z",
|
|
23
|
+
pending_removal: false,
|
|
24
|
+
user: {
|
|
25
|
+
email: "foo@gmail.com",
|
|
26
|
+
full_name: "foo user",
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
const actions = {
|
|
30
|
+
request_removal: {},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const defaultProps = {
|
|
34
|
+
grant,
|
|
35
|
+
actions,
|
|
36
|
+
loading: false,
|
|
37
|
+
onStatusChange: jest.fn(),
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const renderOpts = {
|
|
41
|
+
messages: {
|
|
42
|
+
en: {
|
|
43
|
+
...en,
|
|
44
|
+
"confirmation.yes": "yes",
|
|
45
|
+
"confirmation.no": "no",
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
fallback: "lazy",
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
it("matches the latest snapshot", () => {
|
|
52
|
+
const { container } = render(<Grant {...defaultProps} />, renderOpts);
|
|
53
|
+
expect(container).toMatchSnapshot();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("matches the latest snapshot with cancel_removal action", () => {
|
|
57
|
+
const props = {
|
|
58
|
+
...defaultProps,
|
|
59
|
+
actions: {
|
|
60
|
+
cancel_removal: {},
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
const { container } = render(<Grant {...props} />, renderOpts);
|
|
64
|
+
expect(container).toMatchSnapshot();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("on click removal onStatusChange is called", async () => {
|
|
68
|
+
const { findByText } = render(<Grant {...defaultProps} />, renderOpts);
|
|
69
|
+
|
|
70
|
+
userEvent.click(await findByText("Remove"));
|
|
71
|
+
expect(await findByText("Request grant removal")).toBeInTheDocument();
|
|
72
|
+
|
|
73
|
+
userEvent.click(await findByText("yes"));
|
|
74
|
+
|
|
75
|
+
expect(defaultProps.onStatusChange).toHaveBeenLastCalledWith({
|
|
76
|
+
action: "request_removal",
|
|
77
|
+
data_structure_id: 2,
|
|
78
|
+
id: 1,
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
});
|
|
@@ -89,7 +89,6 @@ describe("<GrantApprovalRuleConditions />", () => {
|
|
|
89
89
|
userEvent.click(within(getByRole("combobox")).getByText("Add"));
|
|
90
90
|
|
|
91
91
|
await waitFor(() => {
|
|
92
|
-
console.log(onChange.mock.calls.length);
|
|
93
92
|
expect(onChange.mock.calls.length).toBe(4);
|
|
94
93
|
});
|
|
95
94
|
expect(onChange.mock.calls).toMatchObject([
|