@truedat/dd 4.54.12 → 4.56.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/CHANGELOG.md +6 -0
- package/package.json +6 -6
- package/src/api/mutations.js +28 -0
- package/src/api/queries.js +36 -0
- package/src/components/GrantApprovalRule.js +149 -0
- package/src/components/GrantApprovalRuleConditions.js +134 -0
- package/src/components/GrantApprovalRuleDeleteButton.js +44 -0
- package/src/components/GrantApprovalRuleEdit.js +38 -0
- package/src/components/GrantApprovalRuleForm.js +264 -0
- package/src/components/GrantApprovalRuleNew.js +15 -0
- package/src/components/GrantApprovalRules.js +113 -0
- package/src/components/GrantRequest.js +4 -3
- package/src/components/GrantRoutes.js +30 -0
- package/src/components/__tests__/GrantApprovalRule.spec.js +69 -0
- package/src/components/__tests__/GrantApprovalRuleConditions.spec.js +120 -0
- package/src/components/__tests__/GrantApprovalRuleDeleteButton.spec.js +56 -0
- package/src/components/__tests__/GrantApprovalRuleEdit.spec.js +76 -0
- package/src/components/__tests__/GrantApprovalRuleForm.spec.js +135 -0
- package/src/components/__tests__/GrantApprovalRuleNew.spec.js +40 -0
- package/src/components/__tests__/GrantApprovalRules.spec.js +107 -0
- package/src/components/__tests__/StructureGrantDropdown.spec.js +1 -1
- package/src/components/__tests__/__snapshots__/GrantApprovalRule.spec.js.snap +239 -0
- package/src/components/__tests__/__snapshots__/GrantApprovalRuleConditions.spec.js.snap +819 -0
- package/src/components/__tests__/__snapshots__/GrantApprovalRuleDeleteButton.spec.js.snap +11 -0
- package/src/components/__tests__/__snapshots__/GrantApprovalRuleEdit.spec.js.snap +487 -0
- package/src/components/__tests__/__snapshots__/GrantApprovalRuleForm.spec.js.snap +1036 -0
- package/src/components/__tests__/__snapshots__/GrantApprovalRuleNew.spec.js.snap +464 -0
- package/src/components/__tests__/__snapshots__/GrantApprovalRules.spec.js.snap +266 -0
- package/src/components/__tests__/__snapshots__/GrantRoutes.spec.js.snap +27 -5
- package/src/messages/en.js +40 -0
- package/src/messages/es.js +41 -0
- package/src/reducers/structureRedirect.js +23 -3
- package/src/routines.js +3 -0
- package/src/sagas/__tests__/createGrantApprovalRule.spec.js +96 -0
- package/src/sagas/__tests__/deleteGrantApprovalRule.spec.js +85 -0
- package/src/sagas/__tests__/updateGrantApprovalRule.spec.js +96 -0
- package/src/sagas/createGrantApprovalRule.js +26 -0
- package/src/sagas/deleteGrantApprovalRule.js +32 -0
- package/src/sagas/index.js +9 -0
- package/src/sagas/updateGrantApprovalRule.js +26 -0
- package/src/selectors/__tests__/getGrantsColumns.spec.js +4 -0
- package/src/components/GrantRequestCrumbs.js +0 -25
- package/src/components/__tests__/GrantRequestCrumbs.spec.js +0 -18
- package/src/components/__tests__/__snapshots__/GrantRequestCrumbs.spec.js.snap +0 -100
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
exports[`<GrantRoutes /> matches the latest snapshot 1`] = `
|
|
4
4
|
<Fragment>
|
|
5
5
|
<Route
|
|
6
|
-
path="/
|
|
6
|
+
path="/grantsRequests/checkout"
|
|
7
7
|
render={[Function]}
|
|
8
8
|
/>
|
|
9
9
|
<Route
|
|
@@ -11,19 +11,41 @@ exports[`<GrantRoutes /> matches the latest snapshot 1`] = `
|
|
|
11
11
|
render={[Function]}
|
|
12
12
|
/>
|
|
13
13
|
<Route
|
|
14
|
-
path="/
|
|
14
|
+
path="/myGrants"
|
|
15
15
|
render={[Function]}
|
|
16
16
|
/>
|
|
17
17
|
<Route
|
|
18
|
-
path="/
|
|
18
|
+
path="/grantRequestApprovals"
|
|
19
19
|
render={[Function]}
|
|
20
20
|
/>
|
|
21
21
|
<Route
|
|
22
|
-
path="/
|
|
22
|
+
path="/myGrantRequests"
|
|
23
23
|
render={[Function]}
|
|
24
24
|
/>
|
|
25
|
+
<Switch>
|
|
26
|
+
<Route
|
|
27
|
+
exact={true}
|
|
28
|
+
path="/grantApproveRules/new"
|
|
29
|
+
render={[Function]}
|
|
30
|
+
/>
|
|
31
|
+
<Route
|
|
32
|
+
exact={true}
|
|
33
|
+
path="/grantApproveRules/:id/edit"
|
|
34
|
+
render={[Function]}
|
|
35
|
+
/>
|
|
36
|
+
<Route
|
|
37
|
+
exact={true}
|
|
38
|
+
path="/grantApproveRules/:id"
|
|
39
|
+
render={[Function]}
|
|
40
|
+
/>
|
|
41
|
+
<Route
|
|
42
|
+
exact={true}
|
|
43
|
+
path="/grantApprovalRules"
|
|
44
|
+
render={[Function]}
|
|
45
|
+
/>
|
|
46
|
+
</Switch>
|
|
25
47
|
<Route
|
|
26
|
-
path="/
|
|
48
|
+
path="/grantRequests"
|
|
27
49
|
render={[Function]}
|
|
28
50
|
/>
|
|
29
51
|
</Fragment>
|
package/src/messages/en.js
CHANGED
|
@@ -55,6 +55,46 @@ export default {
|
|
|
55
55
|
"grant.header.end_date": "Expires",
|
|
56
56
|
"grant.header.start_date": "Access granted",
|
|
57
57
|
"grant.updated_at": "Last changed",
|
|
58
|
+
"grantApprovalRule.action": "Action",
|
|
59
|
+
"grantApprovalRule.action.approve": "Approve",
|
|
60
|
+
"grantApprovalRule.action.reject": "Reject",
|
|
61
|
+
"grantApprovalRule.action.placeholder": "Action",
|
|
62
|
+
"grantApprovalRule.actions.delete.confirmation.header":
|
|
63
|
+
"¿Delete approval rule?",
|
|
64
|
+
"grantApprovalRule.actions.delete.confirmation.content":
|
|
65
|
+
"¿Are you sure to delete this grant request approval rule?",
|
|
66
|
+
"grantApprovalRule.comment": "Comment",
|
|
67
|
+
"grantApprovalRule.comment.placeholder": "Comment",
|
|
68
|
+
"grantApprovalRule.conditions": "Conditions",
|
|
69
|
+
"grantApprovalRule.conditions.addCondition": "Add condition",
|
|
70
|
+
"grantApprovalRule.conditions.error.invalid_conditions":
|
|
71
|
+
"Conditions are not valid",
|
|
72
|
+
"grantApprovalRule.conditions.field_name": "Field",
|
|
73
|
+
"grantApprovalRule.conditions.operator": "Operator",
|
|
74
|
+
"grantApprovalRule.conditions.operator.eq": "Is equal",
|
|
75
|
+
"grantApprovalRule.conditions.operator.neq": "Is not equal",
|
|
76
|
+
"grantApprovalRule.conditions.operator.placeholder": "Operator",
|
|
77
|
+
"grantApprovalRule.conditions.value": "Value",
|
|
78
|
+
"grantApprovalRule.conditions.field_prefix": "Context",
|
|
79
|
+
"grantApprovalRule.conditions.field_prefix.request": "Request metadata",
|
|
80
|
+
"grantApprovalRule.conditions.field_prefix.note": "Structure note",
|
|
81
|
+
"grantApprovalRule.conditions.field_prefix.null": "-",
|
|
82
|
+
"grantApprovalRule.conditions.field_prefix.metadata": "Structure metadata",
|
|
83
|
+
"grantApprovalRule.conditions.field_prefix.placeholder": "Context",
|
|
84
|
+
"grantApprovalRule.domain": "Domain",
|
|
85
|
+
"grantApprovalRule.subheader": "Grant approval rule",
|
|
86
|
+
"grantApprovalRules.header": "Approval rules",
|
|
87
|
+
"grantApprovalRules.subheader":
|
|
88
|
+
"Rules for automatically accept or reject grant requests",
|
|
89
|
+
"grantApprovalRules.empty": "No rules found",
|
|
90
|
+
"grantApprovalRule.name": "Name",
|
|
91
|
+
"grantApprovalRule.name.placeholder": "Name",
|
|
92
|
+
"grantApprovalRules.delete": "Delete",
|
|
93
|
+
"grantApprovalRules.edit": "Edit",
|
|
94
|
+
"grantApprovalRules.new": "New rule",
|
|
95
|
+
"grantApprovalRule.role": "Role",
|
|
96
|
+
"grantApprovalRule.role.placeholder": "Role",
|
|
97
|
+
|
|
58
98
|
"grantRequest.actions.cancel.confirmation.content": "Are you sure?",
|
|
59
99
|
"grantRequest.actions.cancel.confirmation.header": "Cancel request",
|
|
60
100
|
"grantRequest.actions.approve": "Approve",
|
package/src/messages/es.js
CHANGED
|
@@ -59,6 +59,47 @@ export default {
|
|
|
59
59
|
"grant.header.start_date": "Acceso desde",
|
|
60
60
|
"grant.header.user": "Cuenta",
|
|
61
61
|
"grant.updated_at": "Actualizada",
|
|
62
|
+
"grantApprovalRules.header": "Reglas de aprobación",
|
|
63
|
+
"grantApprovalRules.subheader":
|
|
64
|
+
"Reglas para aprobar o rechazar peticiones de datos automáticamente",
|
|
65
|
+
"grantApprovalRules.empty": "No se han encontrado reglas",
|
|
66
|
+
"grantApprovalRule.action": "Acción",
|
|
67
|
+
"grantApprovalRule.action.approve": "Aprobar",
|
|
68
|
+
"grantApprovalRule.action.reject": "Rechazar",
|
|
69
|
+
"grantApprovalRule.action.placeholder": "Acción",
|
|
70
|
+
"grantApprovalRule.actions.delete.confirmation.header":
|
|
71
|
+
"¿Borrar regla de aprobación?",
|
|
72
|
+
"grantApprovalRule.actions.delete.confirmation.content":
|
|
73
|
+
"¿Seguro que quieres borrar la regla de aprobación de solicitud de acceso?",
|
|
74
|
+
"grantApprovalRule.comment": "Comentario",
|
|
75
|
+
"grantApprovalRule.comment.placeholder": "Comentario",
|
|
76
|
+
"grantApprovalRule.conditions": "Condiciones",
|
|
77
|
+
"grantApprovalRule.conditions.addCondition": "Añadir condición",
|
|
78
|
+
"grantApprovalRule.conditions.error.invalid_conditions":
|
|
79
|
+
"Condiciones invalidas",
|
|
80
|
+
"grantApprovalRule.conditions.field_name": "Campo",
|
|
81
|
+
"grantApprovalRule.conditions.operator": "Operador",
|
|
82
|
+
"grantApprovalRule.conditions.operator.eq": "Es igual",
|
|
83
|
+
"grantApprovalRule.conditions.operator.neq": "No es igual",
|
|
84
|
+
"grantApprovalRule.conditions.operator.placeholder": "Operador",
|
|
85
|
+
"grantApprovalRule.conditions.value": "Valor",
|
|
86
|
+
"grantApprovalRule.conditions.field_prefix": "Contexto",
|
|
87
|
+
"grantApprovalRule.conditions.field_prefix.request":
|
|
88
|
+
"Metadata de la petición",
|
|
89
|
+
"grantApprovalRule.conditions.field_prefix.note": "Nota de la estructura",
|
|
90
|
+
"grantApprovalRule.conditions.field_prefix.null": "-",
|
|
91
|
+
"grantApprovalRule.conditions.field_prefix.metadata":
|
|
92
|
+
"Metadata de la estructura",
|
|
93
|
+
"grantApprovalRule.conditions.field_prefix.placeholder": "Contexto",
|
|
94
|
+
"grantApprovalRule.name": "Nombre",
|
|
95
|
+
"grantApprovalRule.name.placeholder": "Nombre",
|
|
96
|
+
"grantApprovalRule.subheader": "Regla de aprobación de solicitud de acceso",
|
|
97
|
+
"grantApprovalRules.delete": "Borrar",
|
|
98
|
+
"grantApprovalRules.edit": "Editar",
|
|
99
|
+
"grantApprovalRules.new": "Nueva regla",
|
|
100
|
+
"grantApprovalRule.role": "Rol",
|
|
101
|
+
"grantApprovalRule.role.placeholder": "Rol",
|
|
102
|
+
"grantApprovalRule.domain": "Dominio",
|
|
62
103
|
"grantRequest.actions.approve": "Aprobar",
|
|
63
104
|
"grantRequest.actions.cancel.confirmation.content": "¿Estás seguro?",
|
|
64
105
|
"grantRequest.actions.cancel.confirmation.header": "Cancelar solicitud",
|
|
@@ -2,24 +2,29 @@ import _ from "lodash/fp";
|
|
|
2
2
|
import { clearRedirect } from "@truedat/core/routines";
|
|
3
3
|
import {
|
|
4
4
|
GRANT_REQUEST_APPROVALS,
|
|
5
|
+
GRANT_APPROVAL_RULES,
|
|
6
|
+
MY_GRANT_REQUESTS,
|
|
5
7
|
REFERENCE_DATASETS,
|
|
6
|
-
STRUCTURES,
|
|
7
|
-
STRUCTURE_TYPES,
|
|
8
8
|
STRUCTURE_TAGS,
|
|
9
|
+
STRUCTURE_TYPES,
|
|
10
|
+
STRUCTURES,
|
|
9
11
|
linkTo,
|
|
10
12
|
} from "@truedat/core/routes";
|
|
11
13
|
import {
|
|
12
14
|
bulkUpdateStructures,
|
|
13
15
|
checkoutGrantRequest,
|
|
16
|
+
createGrantApprovalRule,
|
|
14
17
|
createGrantRequestApproval,
|
|
15
18
|
createProfileGroup,
|
|
16
19
|
createReferenceDataset,
|
|
17
20
|
createSystem,
|
|
18
21
|
createTag,
|
|
22
|
+
deleteGrantApprovalRule,
|
|
19
23
|
deleteReferenceDataset,
|
|
20
24
|
deleteStructure,
|
|
21
25
|
deleteTag,
|
|
22
26
|
doStructureNoteAction,
|
|
27
|
+
updateGrantApprovalRule,
|
|
23
28
|
updateReferenceDataset,
|
|
24
29
|
updateStructure,
|
|
25
30
|
updateStructureType,
|
|
@@ -49,7 +54,12 @@ export const structureRedirect = (
|
|
|
49
54
|
const id = _.path("data.id")(payload);
|
|
50
55
|
return linkTo.SYSTEM_STRUCTURES({ id });
|
|
51
56
|
}
|
|
52
|
-
case checkoutGrantRequest.SUCCESS:
|
|
57
|
+
case checkoutGrantRequest.SUCCESS: {
|
|
58
|
+
const requests = _.path("data._embedded.requests")(payload);
|
|
59
|
+
return _.size(requests) === 1
|
|
60
|
+
? linkTo.GRANT_REQUEST({ id: requests[0].id })
|
|
61
|
+
: MY_GRANT_REQUESTS;
|
|
62
|
+
}
|
|
53
63
|
case uploadStructures.SUCCESS: {
|
|
54
64
|
return STRUCTURES;
|
|
55
65
|
}
|
|
@@ -92,6 +102,16 @@ export const structureRedirect = (
|
|
|
92
102
|
case deleteReferenceDataset.SUCCESS: {
|
|
93
103
|
return REFERENCE_DATASETS;
|
|
94
104
|
}
|
|
105
|
+
case createGrantApprovalRule.SUCCESS: {
|
|
106
|
+
return GRANT_APPROVAL_RULES;
|
|
107
|
+
}
|
|
108
|
+
case deleteGrantApprovalRule.SUCCESS: {
|
|
109
|
+
return GRANT_APPROVAL_RULES;
|
|
110
|
+
}
|
|
111
|
+
case updateGrantApprovalRule.SUCCESS: {
|
|
112
|
+
const id = payload?.updateGrantApprovalRule?.id;
|
|
113
|
+
return linkTo.GRANT_APPROVAL_RULE({ id });
|
|
114
|
+
}
|
|
95
115
|
default:
|
|
96
116
|
return state;
|
|
97
117
|
}
|
package/src/routines.js
CHANGED
|
@@ -37,6 +37,7 @@ export const clearSystems = createRoutine("CLEAR_SYSTEMS");
|
|
|
37
37
|
export const clearUserSearchFilters = createRoutine("CLEAR_USER_SEARCH_FILTERS");
|
|
38
38
|
export const closeGrantFilter = createRoutine("CLOSE_GRANT_FILTER");
|
|
39
39
|
export const closeStructureFilter = createRoutine("CLOSE_STRUCTURE_FILTER");
|
|
40
|
+
export const createGrantApprovalRule = createRoutine("CREATE_GRANT_APPROVAL_RULE");
|
|
40
41
|
export const createGrantRequestApproval = createRoutine("CREATE_GRANT_REQUEST_APPROVAL");
|
|
41
42
|
export const createGrantRequestStatus = createRoutine("CREATE_GRANT_REQUEST_STATUS");
|
|
42
43
|
export const createGraph = createRoutine("CREATE_GRAPH");
|
|
@@ -46,6 +47,7 @@ export const createStructureGraph = createRoutine("CREATE_STRUCTURE_GRAPH");
|
|
|
46
47
|
export const createStructureType = createRoutine("CREATE_STRUCTURE_TYPE");
|
|
47
48
|
export const createSystem = createRoutine("CREATE_SYSTEM");
|
|
48
49
|
export const createTag = createRoutine("CREATE_TAG");
|
|
50
|
+
export const deleteGrantApprovalRule = createRoutine("DELETE_GRANT_APPROVAL_RULE");
|
|
49
51
|
export const deleteReferenceDataset = createRoutine("DELETE_REFERENCE_DATASET");
|
|
50
52
|
export const deleteStructureTag = createRoutine("DELETE_STRUCTURE_TAG");
|
|
51
53
|
export const deleteStructure = createRoutine("DELETE_STRUCTURE");
|
|
@@ -116,6 +118,7 @@ export const toggleGrantFilterValue = createRoutine("TOGGLE_GRANT_FILTER_VALUE")
|
|
|
116
118
|
export const toggleStructureDateFilter = createRoutine("TOGGLE_STRUCTURE_DATE_FILTER");
|
|
117
119
|
export const toggleStructureFilterValue = createRoutine("TOGGLE_STRUCTURE_FILTER_VALUE");
|
|
118
120
|
export const updateGrant = createRoutine("UPDATE_GRANT");
|
|
121
|
+
export const updateGrantApprovalRule = createRoutine("UPDATE_GRANT_APPROVAL_RULE");
|
|
119
122
|
export const updateGrantRequestFilter = createRoutine("UPDATE_GRANT_REQUEST_FILTER_SAGA");
|
|
120
123
|
export const updateGrantRequestTemplateContent = createRoutine("UPDATE_GRANT_REQUEST_TEMPLATE_CONTENT");
|
|
121
124
|
export const updateGrantRequestUser = createRoutine("UPDATE_GRANT_REQUEST_USER");
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { testSaga } from "redux-saga-test-plan";
|
|
2
|
+
import {
|
|
3
|
+
createGrantApprovalRuleRequestSaga,
|
|
4
|
+
createGrantApprovalRuleSaga,
|
|
5
|
+
} from "../createGrantApprovalRule";
|
|
6
|
+
import { CREATE_GRANT_APPROVAL_RULE } from "../../api/mutations";
|
|
7
|
+
import { createGrantApprovalRule } from "../../routines";
|
|
8
|
+
|
|
9
|
+
describe("sagas: createGrantApprovalRuleRequestSaga", () => {
|
|
10
|
+
it("should invoke createGrantApprovalRuleSaga on createGrantApprovalRule.TRIGGER", () => {
|
|
11
|
+
expect(() => {
|
|
12
|
+
testSaga(createGrantApprovalRuleRequestSaga)
|
|
13
|
+
.next()
|
|
14
|
+
.takeLatest(
|
|
15
|
+
createGrantApprovalRule.TRIGGER,
|
|
16
|
+
createGrantApprovalRuleSaga
|
|
17
|
+
)
|
|
18
|
+
.finish()
|
|
19
|
+
.isDone();
|
|
20
|
+
}).not.toThrow();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("should throw exception if an unhandled action is received", () => {
|
|
24
|
+
expect(() => {
|
|
25
|
+
testSaga(createGrantApprovalRuleRequestSaga)
|
|
26
|
+
.next()
|
|
27
|
+
.takeLatest("FOO", createGrantApprovalRuleRequestSaga);
|
|
28
|
+
}).toThrow();
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
describe("sagas: createGrantApprovalRuleSaga", () => {
|
|
33
|
+
const client = { mutate: jest.fn() };
|
|
34
|
+
const approvalRule = {
|
|
35
|
+
id: "15",
|
|
36
|
+
name: "approvalRule1",
|
|
37
|
+
action: "approve",
|
|
38
|
+
role: "grants",
|
|
39
|
+
comment: "bla",
|
|
40
|
+
conditions: [
|
|
41
|
+
{
|
|
42
|
+
field: "foo",
|
|
43
|
+
operator: "eq",
|
|
44
|
+
value: "bar",
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
domainIds: ["1"],
|
|
48
|
+
};
|
|
49
|
+
const payload = approvalRule;
|
|
50
|
+
const data = { foo: "bar" };
|
|
51
|
+
|
|
52
|
+
it("should put a success action when a response is returned", () => {
|
|
53
|
+
expect(() => {
|
|
54
|
+
testSaga(createGrantApprovalRuleSaga, { payload })
|
|
55
|
+
.next()
|
|
56
|
+
.getContext("client")
|
|
57
|
+
.next(client)
|
|
58
|
+
.put(createGrantApprovalRule.request(payload))
|
|
59
|
+
.next()
|
|
60
|
+
.call(client.mutate, {
|
|
61
|
+
mutation: CREATE_GRANT_APPROVAL_RULE,
|
|
62
|
+
variables: approvalRule,
|
|
63
|
+
})
|
|
64
|
+
.next({ data })
|
|
65
|
+
.put(createGrantApprovalRule.success(data))
|
|
66
|
+
.next()
|
|
67
|
+
.put(createGrantApprovalRule.fulfill())
|
|
68
|
+
.next()
|
|
69
|
+
.isDone();
|
|
70
|
+
}).not.toThrow();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("should put a failure action when the call returns an error", () => {
|
|
74
|
+
const message = "Request failed";
|
|
75
|
+
const error = { message };
|
|
76
|
+
|
|
77
|
+
expect(() => {
|
|
78
|
+
testSaga(createGrantApprovalRuleSaga, { payload })
|
|
79
|
+
.next()
|
|
80
|
+
.getContext("client")
|
|
81
|
+
.next(client)
|
|
82
|
+
.put(createGrantApprovalRule.request(payload))
|
|
83
|
+
.next()
|
|
84
|
+
.call(client.mutate, {
|
|
85
|
+
mutation: CREATE_GRANT_APPROVAL_RULE,
|
|
86
|
+
variables: approvalRule,
|
|
87
|
+
})
|
|
88
|
+
.throw(error)
|
|
89
|
+
.put(createGrantApprovalRule.failure(message))
|
|
90
|
+
.next()
|
|
91
|
+
.put(createGrantApprovalRule.fulfill())
|
|
92
|
+
.next()
|
|
93
|
+
.isDone();
|
|
94
|
+
}).not.toThrow();
|
|
95
|
+
});
|
|
96
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { testSaga } from "redux-saga-test-plan";
|
|
2
|
+
import {
|
|
3
|
+
deleteGrantApprovalRuleRequestSaga,
|
|
4
|
+
deleteGrantApprovalRuleSaga,
|
|
5
|
+
onSuccess,
|
|
6
|
+
} from "../deleteGrantApprovalRule";
|
|
7
|
+
import { DELETE_GRANT_APPROVAL_RULE } from "../../api/mutations";
|
|
8
|
+
import { deleteGrantApprovalRule } from "../../routines";
|
|
9
|
+
|
|
10
|
+
describe("sagas: deleteGrantApprovalRuleRequestSaga", () => {
|
|
11
|
+
it("should invoke deleteGrantApprovalRuleSaga on deleteGrantApprovalRule.TRIGGER", () => {
|
|
12
|
+
expect(() => {
|
|
13
|
+
testSaga(deleteGrantApprovalRuleRequestSaga)
|
|
14
|
+
.next()
|
|
15
|
+
.takeLatest(
|
|
16
|
+
deleteGrantApprovalRule.TRIGGER,
|
|
17
|
+
deleteGrantApprovalRuleSaga
|
|
18
|
+
)
|
|
19
|
+
.finish()
|
|
20
|
+
.isDone();
|
|
21
|
+
}).not.toThrow();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("should throw exception if an unhandled action is received", () => {
|
|
25
|
+
expect(() => {
|
|
26
|
+
testSaga(deleteGrantApprovalRuleRequestSaga)
|
|
27
|
+
.next()
|
|
28
|
+
.takeLatest("FOO", deleteGrantApprovalRuleRequestSaga);
|
|
29
|
+
}).toThrow();
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
describe("sagas: deleteGrantApprovalRuleSaga", () => {
|
|
34
|
+
const client = { mutate: jest.fn() };
|
|
35
|
+
const approvalRule = { id: "15" };
|
|
36
|
+
const payload = approvalRule;
|
|
37
|
+
const data = { foo: "bar" };
|
|
38
|
+
|
|
39
|
+
it("should put a success action when a response is returned", () => {
|
|
40
|
+
expect(() => {
|
|
41
|
+
testSaga(deleteGrantApprovalRuleSaga, { payload })
|
|
42
|
+
.next()
|
|
43
|
+
.getContext("client")
|
|
44
|
+
.next(client)
|
|
45
|
+
.put(deleteGrantApprovalRule.request(payload))
|
|
46
|
+
.next()
|
|
47
|
+
.call(client.mutate, {
|
|
48
|
+
mutation: DELETE_GRANT_APPROVAL_RULE,
|
|
49
|
+
update: onSuccess,
|
|
50
|
+
variables: approvalRule,
|
|
51
|
+
})
|
|
52
|
+
.next({ data })
|
|
53
|
+
.put(deleteGrantApprovalRule.success(data))
|
|
54
|
+
.next()
|
|
55
|
+
.put(deleteGrantApprovalRule.fulfill())
|
|
56
|
+
.next()
|
|
57
|
+
.isDone();
|
|
58
|
+
}).not.toThrow();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("should put a failure action when the call returns an error", () => {
|
|
62
|
+
const message = "Request failed";
|
|
63
|
+
const error = { message };
|
|
64
|
+
|
|
65
|
+
expect(() => {
|
|
66
|
+
testSaga(deleteGrantApprovalRuleSaga, { payload })
|
|
67
|
+
.next()
|
|
68
|
+
.getContext("client")
|
|
69
|
+
.next(client)
|
|
70
|
+
.put(deleteGrantApprovalRule.request(payload))
|
|
71
|
+
.next()
|
|
72
|
+
.call(client.mutate, {
|
|
73
|
+
mutation: DELETE_GRANT_APPROVAL_RULE,
|
|
74
|
+
update: onSuccess,
|
|
75
|
+
variables: approvalRule,
|
|
76
|
+
})
|
|
77
|
+
.throw(error)
|
|
78
|
+
.put(deleteGrantApprovalRule.failure(message))
|
|
79
|
+
.next()
|
|
80
|
+
.put(deleteGrantApprovalRule.fulfill())
|
|
81
|
+
.next()
|
|
82
|
+
.isDone();
|
|
83
|
+
}).not.toThrow();
|
|
84
|
+
});
|
|
85
|
+
});
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { testSaga } from "redux-saga-test-plan";
|
|
2
|
+
import {
|
|
3
|
+
updateGrantApprovalRuleRequestSaga,
|
|
4
|
+
updateGrantApprovalRuleSaga,
|
|
5
|
+
} from "../updateGrantApprovalRule";
|
|
6
|
+
import { UPDATE_GRANT_APPROVAL_RULE } from "../../api/mutations";
|
|
7
|
+
import { updateGrantApprovalRule } from "../../routines";
|
|
8
|
+
|
|
9
|
+
describe("sagas: updateGrantApprovalRuleRequestSaga", () => {
|
|
10
|
+
it("should invoke updateGrantApprovalRuleSaga on updateGrantApprovalRule.TRIGGER", () => {
|
|
11
|
+
expect(() => {
|
|
12
|
+
testSaga(updateGrantApprovalRuleRequestSaga)
|
|
13
|
+
.next()
|
|
14
|
+
.takeLatest(
|
|
15
|
+
updateGrantApprovalRule.TRIGGER,
|
|
16
|
+
updateGrantApprovalRuleSaga
|
|
17
|
+
)
|
|
18
|
+
.finish()
|
|
19
|
+
.isDone();
|
|
20
|
+
}).not.toThrow();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("should throw exception if an unhandled action is received", () => {
|
|
24
|
+
expect(() => {
|
|
25
|
+
testSaga(updateGrantApprovalRuleRequestSaga)
|
|
26
|
+
.next()
|
|
27
|
+
.takeLatest("FOO", updateGrantApprovalRuleRequestSaga);
|
|
28
|
+
}).toThrow();
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
describe("sagas: updateGrantApprovalRuleSaga", () => {
|
|
33
|
+
const client = { mutate: jest.fn() };
|
|
34
|
+
const approvalRule = {
|
|
35
|
+
id: "15",
|
|
36
|
+
name: "approvalRule1",
|
|
37
|
+
action: "approve",
|
|
38
|
+
role: "grants",
|
|
39
|
+
comment: "bla",
|
|
40
|
+
conditions: [
|
|
41
|
+
{
|
|
42
|
+
field: "foo",
|
|
43
|
+
operator: "eq",
|
|
44
|
+
value: "bar",
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
domainIds: ["1"],
|
|
48
|
+
};
|
|
49
|
+
const payload = approvalRule;
|
|
50
|
+
const data = { foo: "bar" };
|
|
51
|
+
|
|
52
|
+
it("should put a success action when a response is returned", () => {
|
|
53
|
+
expect(() => {
|
|
54
|
+
testSaga(updateGrantApprovalRuleSaga, { payload })
|
|
55
|
+
.next()
|
|
56
|
+
.getContext("client")
|
|
57
|
+
.next(client)
|
|
58
|
+
.put(updateGrantApprovalRule.request(payload))
|
|
59
|
+
.next()
|
|
60
|
+
.call(client.mutate, {
|
|
61
|
+
mutation: UPDATE_GRANT_APPROVAL_RULE,
|
|
62
|
+
variables: approvalRule,
|
|
63
|
+
})
|
|
64
|
+
.next({ data })
|
|
65
|
+
.put(updateGrantApprovalRule.success(data))
|
|
66
|
+
.next()
|
|
67
|
+
.put(updateGrantApprovalRule.fulfill())
|
|
68
|
+
.next()
|
|
69
|
+
.isDone();
|
|
70
|
+
}).not.toThrow();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("should put a failure action when the call returns an error", () => {
|
|
74
|
+
const message = "Request failed";
|
|
75
|
+
const error = { message };
|
|
76
|
+
|
|
77
|
+
expect(() => {
|
|
78
|
+
testSaga(updateGrantApprovalRuleSaga, { payload })
|
|
79
|
+
.next()
|
|
80
|
+
.getContext("client")
|
|
81
|
+
.next(client)
|
|
82
|
+
.put(updateGrantApprovalRule.request(payload))
|
|
83
|
+
.next()
|
|
84
|
+
.call(client.mutate, {
|
|
85
|
+
mutation: UPDATE_GRANT_APPROVAL_RULE,
|
|
86
|
+
variables: approvalRule,
|
|
87
|
+
})
|
|
88
|
+
.throw(error)
|
|
89
|
+
.put(updateGrantApprovalRule.failure(message))
|
|
90
|
+
.next()
|
|
91
|
+
.put(updateGrantApprovalRule.fulfill())
|
|
92
|
+
.next()
|
|
93
|
+
.isDone();
|
|
94
|
+
}).not.toThrow();
|
|
95
|
+
});
|
|
96
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { call, put, takeLatest, getContext } from "redux-saga/effects";
|
|
2
|
+
import { CREATE_GRANT_APPROVAL_RULE } from "../api/mutations";
|
|
3
|
+
import { createGrantApprovalRule } from "../routines";
|
|
4
|
+
|
|
5
|
+
export function* createGrantApprovalRuleSaga({ payload }) {
|
|
6
|
+
const client = yield getContext("client");
|
|
7
|
+
try {
|
|
8
|
+
yield put(createGrantApprovalRule.request(payload));
|
|
9
|
+
const { data } = yield call(client.mutate, {
|
|
10
|
+
mutation: CREATE_GRANT_APPROVAL_RULE,
|
|
11
|
+
variables: payload,
|
|
12
|
+
});
|
|
13
|
+
yield put(createGrantApprovalRule.success(data));
|
|
14
|
+
} catch (error) {
|
|
15
|
+
yield put(createGrantApprovalRule.failure(error.message));
|
|
16
|
+
} finally {
|
|
17
|
+
yield put(createGrantApprovalRule.fulfill());
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function* createGrantApprovalRuleRequestSaga() {
|
|
22
|
+
yield takeLatest(
|
|
23
|
+
createGrantApprovalRule.TRIGGER,
|
|
24
|
+
createGrantApprovalRuleSaga
|
|
25
|
+
);
|
|
26
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { call, put, takeLatest, getContext } from "redux-saga/effects";
|
|
2
|
+
import { DELETE_GRANT_APPROVAL_RULE } from "../api/mutations";
|
|
3
|
+
import { deleteGrantApprovalRule } from "../routines";
|
|
4
|
+
|
|
5
|
+
export const onSuccess = (cache) => {
|
|
6
|
+
cache.evict({ id: "ROOT_QUERY", fieldName: "grantApprovalRules" });
|
|
7
|
+
cache.gc();
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function* deleteGrantApprovalRuleSaga({ payload }) {
|
|
11
|
+
const client = yield getContext("client");
|
|
12
|
+
try {
|
|
13
|
+
yield put(deleteGrantApprovalRule.request(payload));
|
|
14
|
+
const { data } = yield call(client.mutate, {
|
|
15
|
+
mutation: DELETE_GRANT_APPROVAL_RULE,
|
|
16
|
+
update: onSuccess,
|
|
17
|
+
variables: payload,
|
|
18
|
+
});
|
|
19
|
+
yield put(deleteGrantApprovalRule.success(data));
|
|
20
|
+
} catch (error) {
|
|
21
|
+
yield put(deleteGrantApprovalRule.failure(error.message));
|
|
22
|
+
} finally {
|
|
23
|
+
yield put(deleteGrantApprovalRule.fulfill());
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function* deleteGrantApprovalRuleRequestSaga() {
|
|
28
|
+
yield takeLatest(
|
|
29
|
+
deleteGrantApprovalRule.TRIGGER,
|
|
30
|
+
deleteGrantApprovalRuleSaga
|
|
31
|
+
);
|
|
32
|
+
}
|
package/src/sagas/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { bulkUpdateStructuresRequestsSaga } from "./bulkUpdateStructures";
|
|
2
|
+
import { createGrantApprovalRuleRequestSaga } from "./createGrantApprovalRule";
|
|
2
3
|
import { createGrantRequestApprovalRequestSaga } from "./createGrantRequestApproval";
|
|
3
4
|
import { createGrantRequestStatusRequestSaga } from "./createGrantRequestStatus";
|
|
4
5
|
import { createGraphRequestSaga } from "./createGraph";
|
|
@@ -7,6 +8,7 @@ import { createReferenceDatasetRequestSaga } from "./createReferenceDataset";
|
|
|
7
8
|
import { createStructureGraphRequestSaga } from "./createStructureGraph";
|
|
8
9
|
import { createSystemRequestSaga } from "./createSystem";
|
|
9
10
|
import { createTagRequestSaga } from "./createTag";
|
|
11
|
+
import { deleteGrantApprovalRuleRequestSaga } from "./deleteGrantApprovalRule";
|
|
10
12
|
import { deleteStructureTagRequestSaga } from "./deleteStructureTag";
|
|
11
13
|
import { deleteReferenceDatasetRequestSaga } from "./deleteReferenceDataset";
|
|
12
14
|
import { deleteStructureRequestSaga } from "./deleteStructure";
|
|
@@ -43,6 +45,7 @@ import { tagStructureRequestSaga } from "./tagStructure";
|
|
|
43
45
|
import { operateGrantRequestToCartRequestSaga } from "./operateGrantRequestCart";
|
|
44
46
|
import { requestGrantRemovalRequestSaga } from "./requestGrantRemoval";
|
|
45
47
|
import { saveUserSearchFiltersRequestSaga } from "./saveUserSearchFilters";
|
|
48
|
+
import { updateGrantApprovalRuleRequestSaga } from "./updateGrantApprovalRule";
|
|
46
49
|
import { updateReferenceDatasetRequestSaga } from "./updateReferenceDataset";
|
|
47
50
|
import { updateStructureRequestSaga } from "./updateStructure";
|
|
48
51
|
import { updateStructureTypeRequestSaga } from "./updateStructureType";
|
|
@@ -53,6 +56,7 @@ import { updateTagRequestSaga } from "./updateTag";
|
|
|
53
56
|
|
|
54
57
|
export {
|
|
55
58
|
bulkUpdateStructuresRequestsSaga,
|
|
59
|
+
createGrantApprovalRuleRequestSaga,
|
|
56
60
|
createGrantRequestApprovalRequestSaga,
|
|
57
61
|
createGrantRequestStatusRequestSaga,
|
|
58
62
|
createGraphRequestSaga,
|
|
@@ -61,6 +65,7 @@ export {
|
|
|
61
65
|
createStructureGraphRequestSaga,
|
|
62
66
|
createSystemRequestSaga,
|
|
63
67
|
createTagRequestSaga,
|
|
68
|
+
deleteGrantApprovalRuleRequestSaga,
|
|
64
69
|
deleteStructureTagRequestSaga,
|
|
65
70
|
deleteReferenceDatasetRequestSaga,
|
|
66
71
|
deleteStructureRequestSaga,
|
|
@@ -98,6 +103,7 @@ export {
|
|
|
98
103
|
requestGrantRemovalRequestSaga,
|
|
99
104
|
saveUserSearchFiltersRequestSaga,
|
|
100
105
|
updateReferenceDatasetRequestSaga,
|
|
106
|
+
updateGrantApprovalRuleRequestSaga,
|
|
101
107
|
updateStructureRequestSaga,
|
|
102
108
|
updateStructureTypeRequestSaga,
|
|
103
109
|
updateSystemRequestSaga,
|
|
@@ -108,6 +114,7 @@ export {
|
|
|
108
114
|
|
|
109
115
|
export default [
|
|
110
116
|
bulkUpdateStructuresRequestsSaga(),
|
|
117
|
+
createGrantApprovalRuleRequestSaga(),
|
|
111
118
|
createGrantRequestApprovalRequestSaga(),
|
|
112
119
|
createGrantRequestStatusRequestSaga(),
|
|
113
120
|
createGraphRequestSaga(),
|
|
@@ -116,6 +123,7 @@ export default [
|
|
|
116
123
|
createStructureGraphRequestSaga(),
|
|
117
124
|
createTagRequestSaga(),
|
|
118
125
|
createSystemRequestSaga(),
|
|
126
|
+
deleteGrantApprovalRuleRequestSaga(),
|
|
119
127
|
deleteStructureTagRequestSaga(),
|
|
120
128
|
deleteReferenceDatasetRequestSaga(),
|
|
121
129
|
deleteStructureRequestSaga(),
|
|
@@ -152,6 +160,7 @@ export default [
|
|
|
152
160
|
operateGrantRequestToCartRequestSaga(),
|
|
153
161
|
requestGrantRemovalRequestSaga(),
|
|
154
162
|
saveUserSearchFiltersRequestSaga(),
|
|
163
|
+
updateGrantApprovalRuleRequestSaga(),
|
|
155
164
|
updateReferenceDatasetRequestSaga(),
|
|
156
165
|
updateStructureRequestSaga(),
|
|
157
166
|
updateTagRequestSaga(),
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { call, put, takeLatest, getContext } from "redux-saga/effects";
|
|
2
|
+
import { UPDATE_GRANT_APPROVAL_RULE } from "../api/mutations";
|
|
3
|
+
import { updateGrantApprovalRule } from "../routines";
|
|
4
|
+
|
|
5
|
+
export function* updateGrantApprovalRuleSaga({ payload }) {
|
|
6
|
+
const client = yield getContext("client");
|
|
7
|
+
try {
|
|
8
|
+
yield put(updateGrantApprovalRule.request(payload));
|
|
9
|
+
const { data } = yield call(client.mutate, {
|
|
10
|
+
mutation: UPDATE_GRANT_APPROVAL_RULE,
|
|
11
|
+
variables: payload,
|
|
12
|
+
});
|
|
13
|
+
yield put(updateGrantApprovalRule.success(data));
|
|
14
|
+
} catch (error) {
|
|
15
|
+
yield put(updateGrantApprovalRule.failure(error.message));
|
|
16
|
+
} finally {
|
|
17
|
+
yield put(updateGrantApprovalRule.fulfill());
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function* updateGrantApprovalRuleRequestSaga() {
|
|
22
|
+
yield takeLatest(
|
|
23
|
+
updateGrantApprovalRule.TRIGGER,
|
|
24
|
+
updateGrantApprovalRuleSaga
|
|
25
|
+
);
|
|
26
|
+
}
|