@truedat/dq 4.42.4 → 4.43.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 +5 -5
- package/src/api.js +6 -0
- package/src/components/ImplementationStructureDelete.js +41 -0
- package/src/components/ImplementationStructureLink.js +24 -0
- package/src/components/ImplementationStructures.js +138 -0
- package/src/components/ImplementationStructuresNew.js +125 -0
- package/src/components/RuleImplementationTabs.js +16 -1
- package/src/components/RuleImplementationsTable.js +10 -3
- package/src/components/RuleRoutes.js +37 -1
- package/src/components/__tests__/ImplementationStructureDelete.spec.js +27 -0
- package/src/components/__tests__/ImplementationStructureLink.spec.js +23 -0
- package/src/components/__tests__/ImplementationStructures.spec.js +88 -0
- package/src/components/__tests__/ImplementationStructuresNew.spec.js +34 -0
- package/src/components/__tests__/RuleImplementation.spec.js +2 -1
- package/src/components/__tests__/RuleImplementationTabs.spec.js +2 -1
- package/src/components/__tests__/__snapshots__/ImplementationStructureDelete.spec.js.snap +10 -0
- package/src/components/__tests__/__snapshots__/ImplementationStructureLink.spec.js.snap +11 -0
- package/src/components/__tests__/__snapshots__/ImplementationStructures.spec.js.snap +208 -0
- package/src/components/__tests__/__snapshots__/ImplementationStructuresNew.spec.js.snap +106 -0
- package/src/components/__tests__/__snapshots__/RuleImplementation.spec.js.snap +7 -1
- package/src/components/__tests__/__snapshots__/RuleImplementationTabs.spec.js.snap +8 -2
- package/src/messages/en.js +13 -1
- package/src/messages/es.js +14 -1
- package/src/reducers/ruleImplementation.js +1 -0
- package/src/reducers/ruleImplementationRedirect.js +4 -0
- package/src/routines.js +7 -0
- package/src/sagas/__tests__/createImplementationStructure.spec.js +86 -0
- package/src/sagas/__tests__/deleteImplementationStructure.spec.js +84 -0
- package/src/sagas/createImplementationStructure.js +32 -0
- package/src/sagas/deleteImplementationStructure.js +37 -0
- package/src/sagas/index.js +16 -10
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { compile } from "path-to-regexp";
|
|
2
|
+
import { testSaga } from "redux-saga-test-plan";
|
|
3
|
+
import { apiJsonDelete, JSON_OPTS } from "@truedat/core/services/api";
|
|
4
|
+
import {
|
|
5
|
+
deleteImplementationStructureRequestSaga,
|
|
6
|
+
deleteImplementationStructureSaga,
|
|
7
|
+
} from "../deleteImplementationStructure";
|
|
8
|
+
import {
|
|
9
|
+
deleteImplementationStructure,
|
|
10
|
+
fetchRuleImplementation,
|
|
11
|
+
} from "../../routines";
|
|
12
|
+
import { API_IMPLEMENTATIONS_STRUCTURE } from "../../api";
|
|
13
|
+
|
|
14
|
+
describe("sagas: deleteImplementationStructureRequestSaga", () => {
|
|
15
|
+
it("should invoke deleteImplementationStructureSaga on trigger", () => {
|
|
16
|
+
expect(() => {
|
|
17
|
+
testSaga(deleteImplementationStructureRequestSaga)
|
|
18
|
+
.next()
|
|
19
|
+
.takeLatest(
|
|
20
|
+
deleteImplementationStructure.TRIGGER,
|
|
21
|
+
deleteImplementationStructureSaga
|
|
22
|
+
)
|
|
23
|
+
.finish()
|
|
24
|
+
.isDone();
|
|
25
|
+
}).not.toThrow();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("should throw exception if an unhandled action is received", () => {
|
|
29
|
+
expect(() => {
|
|
30
|
+
testSaga(deleteImplementationStructureRequestSaga)
|
|
31
|
+
.next()
|
|
32
|
+
.takeLatest("FOO", deleteImplementationStructure);
|
|
33
|
+
}).toThrow();
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe("sagas: deleteImplementationStructureSaga", () => {
|
|
38
|
+
const implementationId = 1;
|
|
39
|
+
const id = 2;
|
|
40
|
+
|
|
41
|
+
const url = compile(API_IMPLEMENTATIONS_STRUCTURE)({
|
|
42
|
+
implementationId,
|
|
43
|
+
id,
|
|
44
|
+
});
|
|
45
|
+
const payload = { implementationId, id };
|
|
46
|
+
const data = {};
|
|
47
|
+
|
|
48
|
+
it("should put a success action when a response is returned", () => {
|
|
49
|
+
expect(() => {
|
|
50
|
+
testSaga(deleteImplementationStructureSaga, { payload })
|
|
51
|
+
.next()
|
|
52
|
+
.put(deleteImplementationStructure.request())
|
|
53
|
+
.next()
|
|
54
|
+
.call(apiJsonDelete, url, JSON_OPTS)
|
|
55
|
+
.next({ data })
|
|
56
|
+
.put(deleteImplementationStructure.success(data))
|
|
57
|
+
.next()
|
|
58
|
+
.put(fetchRuleImplementation.trigger({ id: implementationId }))
|
|
59
|
+
.next()
|
|
60
|
+
.put(deleteImplementationStructure.fulfill())
|
|
61
|
+
.next()
|
|
62
|
+
.isDone();
|
|
63
|
+
}).not.toThrow();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("should put a failure action when the call returns an error", () => {
|
|
67
|
+
const message = "Request failed";
|
|
68
|
+
const error = { message };
|
|
69
|
+
|
|
70
|
+
expect(() => {
|
|
71
|
+
testSaga(deleteImplementationStructureSaga, { payload })
|
|
72
|
+
.next()
|
|
73
|
+
.put(deleteImplementationStructure.request())
|
|
74
|
+
.next()
|
|
75
|
+
.call(apiJsonDelete, url, JSON_OPTS)
|
|
76
|
+
.throw(error)
|
|
77
|
+
.put(deleteImplementationStructure.failure(message))
|
|
78
|
+
.next()
|
|
79
|
+
.put(deleteImplementationStructure.fulfill())
|
|
80
|
+
.next()
|
|
81
|
+
.isDone();
|
|
82
|
+
}).not.toThrow();
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { compile } from "path-to-regexp";
|
|
2
|
+
import { call, put, takeLatest } from "redux-saga/effects";
|
|
3
|
+
import { apiJsonPost, JSON_OPTS } from "@truedat/core/services/api";
|
|
4
|
+
import { createImplementationStructure } from "../routines";
|
|
5
|
+
import { API_IMPLEMENTATIONS_STRUCTURES } from "../api";
|
|
6
|
+
|
|
7
|
+
export function* createImplementationStructureSaga({ payload }) {
|
|
8
|
+
try {
|
|
9
|
+
const { implementationId, dataStructureId, type, redirectUrl } = payload;
|
|
10
|
+
const url = compile(API_IMPLEMENTATIONS_STRUCTURES)({ implementationId });
|
|
11
|
+
const requestData = { data_structure_id: dataStructureId, type };
|
|
12
|
+
yield put(createImplementationStructure.request(payload));
|
|
13
|
+
const { data } = yield call(apiJsonPost, url, requestData, JSON_OPTS);
|
|
14
|
+
yield put(createImplementationStructure.success({ data, redirectUrl }));
|
|
15
|
+
} catch (error) {
|
|
16
|
+
if (error.response) {
|
|
17
|
+
const { status, data } = error.response;
|
|
18
|
+
yield put(createImplementationStructure.failure({ status, data }));
|
|
19
|
+
} else {
|
|
20
|
+
yield put(createImplementationStructure.failure(error.message));
|
|
21
|
+
}
|
|
22
|
+
} finally {
|
|
23
|
+
yield put(createImplementationStructure.fulfill());
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function* createImplementationStructureRequestSaga() {
|
|
28
|
+
yield takeLatest(
|
|
29
|
+
createImplementationStructure.TRIGGER,
|
|
30
|
+
createImplementationStructureSaga
|
|
31
|
+
);
|
|
32
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { compile } from "path-to-regexp";
|
|
2
|
+
import { call, put, takeLatest } from "redux-saga/effects";
|
|
3
|
+
import { apiJsonDelete, JSON_OPTS } from "@truedat/core/services/api";
|
|
4
|
+
import {
|
|
5
|
+
deleteImplementationStructure,
|
|
6
|
+
fetchRuleImplementation,
|
|
7
|
+
} from "../routines";
|
|
8
|
+
import { API_IMPLEMENTATIONS_STRUCTURE } from "../api";
|
|
9
|
+
|
|
10
|
+
export function* deleteImplementationStructureSaga({ payload }) {
|
|
11
|
+
try {
|
|
12
|
+
const { implementationId, id } = payload;
|
|
13
|
+
|
|
14
|
+
const url = compile(API_IMPLEMENTATIONS_STRUCTURE)({ id });
|
|
15
|
+
yield put(deleteImplementationStructure.request());
|
|
16
|
+
const { data } = yield call(apiJsonDelete, url, JSON_OPTS);
|
|
17
|
+
yield put(deleteImplementationStructure.success(data));
|
|
18
|
+
//Re-fetch implementation
|
|
19
|
+
yield put(fetchRuleImplementation.trigger({ id: implementationId }));
|
|
20
|
+
} catch (error) {
|
|
21
|
+
if (error.response) {
|
|
22
|
+
const { status, data } = error.response;
|
|
23
|
+
yield put(deleteImplementationStructure.failure({ status, data }));
|
|
24
|
+
} else {
|
|
25
|
+
yield put(deleteImplementationStructure.failure(error.message));
|
|
26
|
+
}
|
|
27
|
+
} finally {
|
|
28
|
+
yield put(deleteImplementationStructure.fulfill());
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function* deleteImplementationStructureRequestSaga() {
|
|
33
|
+
yield takeLatest(
|
|
34
|
+
deleteImplementationStructure.TRIGGER,
|
|
35
|
+
deleteImplementationStructureSaga
|
|
36
|
+
);
|
|
37
|
+
}
|
package/src/sagas/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { createExecutionGroupRequestSaga } from "./createExecutionGroup";
|
|
2
|
-
import {
|
|
2
|
+
import { createImplementationStructureRequestSaga } from "./createImplementationStructure";
|
|
3
3
|
import { createRemediationRequestSaga } from "./createRemediation";
|
|
4
|
+
import { createRuleImplementationRequestSaga } from "./createRuleImplementation";
|
|
4
5
|
import { createRuleRequestSaga } from "./createRule";
|
|
5
|
-
import {
|
|
6
|
+
import { deleteImplementationStructureRequestSaga } from "./deleteImplementationStructure";
|
|
6
7
|
import { deleteRemediationRequestSaga } from "./deleteRemediation";
|
|
7
8
|
import { deleteRuleRequestSaga } from "./deleteRule";
|
|
8
9
|
import { deleteRuleResultRequestSaga } from "./deleteRuleResult";
|
|
@@ -17,19 +18,21 @@ import { fetchRuleImplementationsRequestSaga } from "./fetchRuleImplementations"
|
|
|
17
18
|
import { fetchRuleRequestSaga } from "./fetchRule";
|
|
18
19
|
import { fetchRulesRequestSaga } from "./fetchRules";
|
|
19
20
|
import { searchRuleImplementationsRequestSaga } from "./searchRuleImplementations";
|
|
21
|
+
import { setRuleImplementationStatusRequestSaga } from "./setRuleImplementationStatus";
|
|
20
22
|
import { updateRemediationRequestSaga } from "./updateRemediation";
|
|
21
|
-
import { uploadImplementationsRequestsSaga } from "./uploadImplementations";
|
|
22
|
-
import { uploadRulesRequestsSaga } from "./uploadRules";
|
|
23
23
|
import { updateRuleImplementationRequestSaga } from "./updateRuleImplementation";
|
|
24
24
|
import { updateRuleRequestSaga } from "./updateRule";
|
|
25
|
+
import { uploadImplementationsRequestsSaga } from "./uploadImplementations";
|
|
25
26
|
import { uploadResultsRequestSaga } from "./uploadResults";
|
|
27
|
+
import { uploadRulesRequestsSaga } from "./uploadRules";
|
|
26
28
|
|
|
27
29
|
export {
|
|
28
30
|
createExecutionGroupRequestSaga,
|
|
31
|
+
createImplementationStructureRequestSaga,
|
|
29
32
|
createRemediationRequestSaga,
|
|
30
33
|
createRuleImplementationRequestSaga,
|
|
31
34
|
createRuleRequestSaga,
|
|
32
|
-
|
|
35
|
+
deleteImplementationStructureRequestSaga,
|
|
33
36
|
deleteRemediationRequestSaga,
|
|
34
37
|
deleteRuleRequestSaga,
|
|
35
38
|
deleteRuleResultRequestSaga,
|
|
@@ -44,20 +47,22 @@ export {
|
|
|
44
47
|
fetchRuleRequestSaga,
|
|
45
48
|
fetchRulesRequestSaga,
|
|
46
49
|
searchRuleImplementationsRequestSaga,
|
|
50
|
+
setRuleImplementationStatusRequestSaga,
|
|
47
51
|
updateRemediationRequestSaga,
|
|
48
|
-
uploadRulesRequestsSaga,
|
|
49
|
-
uploadImplementationsRequestsSaga,
|
|
50
52
|
updateRuleImplementationRequestSaga,
|
|
51
53
|
updateRuleRequestSaga,
|
|
54
|
+
uploadImplementationsRequestsSaga,
|
|
52
55
|
uploadResultsRequestSaga,
|
|
56
|
+
uploadRulesRequestsSaga,
|
|
53
57
|
};
|
|
54
58
|
|
|
55
59
|
export default [
|
|
56
60
|
createExecutionGroupRequestSaga(),
|
|
61
|
+
createImplementationStructureRequestSaga(),
|
|
57
62
|
createRemediationRequestSaga(),
|
|
58
63
|
createRuleImplementationRequestSaga(),
|
|
59
64
|
createRuleRequestSaga(),
|
|
60
|
-
|
|
65
|
+
deleteImplementationStructureRequestSaga(),
|
|
61
66
|
deleteRemediationRequestSaga(),
|
|
62
67
|
deleteRuleRequestSaga(),
|
|
63
68
|
deleteRuleResultRequestSaga(),
|
|
@@ -72,10 +77,11 @@ export default [
|
|
|
72
77
|
fetchRuleRequestSaga(),
|
|
73
78
|
fetchRulesRequestSaga(),
|
|
74
79
|
searchRuleImplementationsRequestSaga(),
|
|
80
|
+
setRuleImplementationStatusRequestSaga(),
|
|
75
81
|
updateRemediationRequestSaga(),
|
|
76
|
-
uploadRulesRequestsSaga(),
|
|
77
|
-
uploadImplementationsRequestsSaga(),
|
|
78
82
|
updateRuleImplementationRequestSaga(),
|
|
79
83
|
updateRuleRequestSaga(),
|
|
84
|
+
uploadImplementationsRequestsSaga(),
|
|
80
85
|
uploadResultsRequestSaga(),
|
|
86
|
+
uploadRulesRequestsSaga(),
|
|
81
87
|
];
|