@truedat/bg 6.3.0 → 6.3.2

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.
Files changed (43) hide show
  1. package/package.json +6 -6
  2. package/src/concepts/components/ConceptCreate.js +1 -1
  3. package/src/taxonomy/api.js +1 -15
  4. package/src/taxonomy/components/AddDomainMember.js +24 -0
  5. package/src/taxonomy/components/DomainMembers.js +4 -105
  6. package/src/taxonomy/components/DomainRoutes.js +4 -4
  7. package/src/taxonomy/components/__tests__/AddDomainMember.spec.js +12 -0
  8. package/src/taxonomy/components/__tests__/DomainMembers.spec.js +10 -93
  9. package/src/taxonomy/components/__tests__/__snapshots__/AddDomainMember.spec.js.snap +170 -0
  10. package/src/taxonomy/components/__tests__/__snapshots__/DomainMembers.spec.js.snap +37 -111
  11. package/src/taxonomy/reducers/__tests__/domainRedirect.spec.js +1 -20
  12. package/src/taxonomy/reducers/domainRedirect.js +1 -15
  13. package/src/taxonomy/reducers/index.js +0 -10
  14. package/src/taxonomy/routines.js +0 -9
  15. package/src/taxonomy/sagas/index.js +0 -15
  16. package/src/taxonomy/components/AddMember.js +0 -23
  17. package/src/taxonomy/components/AddMemberForm.js +0 -187
  18. package/src/taxonomy/components/DomainMember.js +0 -230
  19. package/src/taxonomy/components/DomainMembersActions.js +0 -32
  20. package/src/taxonomy/components/ModalOnRoleDeletion.js +0 -77
  21. package/src/taxonomy/components/__tests__/AddMember.spec.js +0 -10
  22. package/src/taxonomy/components/__tests__/AddMemberForm.spec.js +0 -78
  23. package/src/taxonomy/components/__tests__/DomainMember.spec.js +0 -61
  24. package/src/taxonomy/components/__tests__/__snapshots__/AddMember.spec.js.snap +0 -26
  25. package/src/taxonomy/components/__tests__/__snapshots__/AddMemberForm.spec.js.snap +0 -187
  26. package/src/taxonomy/components/__tests__/__snapshots__/DomainMember.spec.js.snap +0 -47
  27. package/src/taxonomy/reducers/__tests__/domainConceptChildren.spec.js +0 -45
  28. package/src/taxonomy/reducers/__tests__/domainConceptChildrenLoading.spec.js +0 -38
  29. package/src/taxonomy/reducers/__tests__/domainMembers.spec.js +0 -33
  30. package/src/taxonomy/reducers/domainConceptChildren.js +0 -24
  31. package/src/taxonomy/reducers/domainConceptChildrenLoading.js +0 -16
  32. package/src/taxonomy/reducers/domainMemberDeleting.js +0 -14
  33. package/src/taxonomy/reducers/domainMemberSaving.js +0 -12
  34. package/src/taxonomy/reducers/domainMembers.js +0 -22
  35. package/src/taxonomy/sagas/__tests__/addDomainMember.spec.js +0 -49
  36. package/src/taxonomy/sagas/__tests__/fetchDomainConceptChildren.spec.js +0 -105
  37. package/src/taxonomy/sagas/__tests__/fetchDomainMembers.spec.js +0 -73
  38. package/src/taxonomy/sagas/__tests__/updateDomainMember.spec.js +0 -81
  39. package/src/taxonomy/sagas/addDomainMember.js +0 -32
  40. package/src/taxonomy/sagas/deleteDomainMember.js +0 -29
  41. package/src/taxonomy/sagas/fetchDomainConceptChildren.js +0 -47
  42. package/src/taxonomy/sagas/fetchDomainMembers.js +0 -28
  43. package/src/taxonomy/sagas/updateDomainMember.js +0 -28
@@ -1,105 +0,0 @@
1
- import { compile } from "path-to-regexp";
2
- import { testSaga } from "redux-saga-test-plan";
3
- import { apiJson, JSON_OPTS } from "@truedat/core/services/api";
4
- import {
5
- fetchDomainConceptChildrenSaga,
6
- fetchDomainConceptChildrenRequestSaga
7
- } from "../fetchDomainConceptChildren";
8
- import { fetchDomainConceptChildren } from "../../routines";
9
- import { API_DOMAIN_CONCEPT_CHILDREN } from "../../api";
10
-
11
- describe("sagas: fetchDomainConceptChildrenRequestSaga", () => {
12
- it("should invoke fetchDomainConceptChildrenSaga on trigger", () => {
13
- expect(() => {
14
- testSaga(fetchDomainConceptChildrenRequestSaga)
15
- .next()
16
- .takeLatest(
17
- fetchDomainConceptChildren.TRIGGER,
18
- fetchDomainConceptChildrenSaga
19
- )
20
- .finish()
21
- .isDone();
22
- }).not.toThrow();
23
- });
24
-
25
- it("should throw exception if an unhandled action is received", () => {
26
- expect(() => {
27
- testSaga(fetchDomainConceptChildrenRequestSaga)
28
- .next()
29
- .takeLatest("FOO", fetchDomainConceptChildren);
30
- }).toThrow();
31
- });
32
- });
33
-
34
- describe("sagas: fetchDomainConceptChildrenSaga", () => {
35
- const domain_id = 1;
36
- const user_name = "My Cool User";
37
- const principal_type = "user";
38
- const acl_entry_id = 2;
39
- const url = compile(API_DOMAIN_CONCEPT_CHILDREN)({
40
- domain_id,
41
- user_name
42
- });
43
- const payload = { domain_id, user_name, principal_type, acl_entry_id };
44
-
45
- it("should put a success action when a response is returned", () => {
46
- const data = { counter: 1 };
47
-
48
- expect(() => {
49
- testSaga(fetchDomainConceptChildrenSaga, { payload })
50
- .next()
51
- .put(fetchDomainConceptChildren.request())
52
- .next()
53
- .call(apiJson, url, JSON_OPTS)
54
- .next({ data: { data } })
55
- .put(
56
- fetchDomainConceptChildren.success({
57
- data: { ...data, acl_entry_id }
58
- })
59
- )
60
- .next()
61
- .put(fetchDomainConceptChildren.fulfill())
62
- .next()
63
- .isDone();
64
- }).not.toThrow();
65
- });
66
-
67
- it("should put a success action when principal_type is group and a response is returned", () => {
68
- const data = { counter: 0, acl_entry_id };
69
-
70
- expect(() => {
71
- testSaga(fetchDomainConceptChildrenSaga, {
72
- payload: { ...payload, principal_type: "group" }
73
- })
74
- .next()
75
- .put(
76
- fetchDomainConceptChildren.success({
77
- data: { ...data, acl_entry_id }
78
- })
79
- )
80
- .next()
81
- .put(fetchDomainConceptChildren.fulfill())
82
- .next()
83
- .isDone();
84
- }).not.toThrow();
85
- });
86
-
87
- it("should put a failure action when the call returns an error", () => {
88
- const message = "Request failed";
89
- const error = { message };
90
-
91
- expect(() => {
92
- testSaga(fetchDomainConceptChildrenSaga, { payload })
93
- .next()
94
- .put(fetchDomainConceptChildren.request())
95
- .next()
96
- .call(apiJson, url, JSON_OPTS)
97
- .throw(error)
98
- .put(fetchDomainConceptChildren.failure(message))
99
- .next()
100
- .put(fetchDomainConceptChildren.fulfill())
101
- .next()
102
- .isDone();
103
- }).not.toThrow();
104
- });
105
- });
@@ -1,73 +0,0 @@
1
- import { compile } from "path-to-regexp";
2
- import { testSaga } from "redux-saga-test-plan";
3
- import { apiJson, JSON_OPTS } from "@truedat/core/services/api";
4
- import {
5
- fetchDomainMembersSaga,
6
- fetchDomainMembersRequestSaga
7
- } from "../fetchDomainMembers";
8
- import { fetchDomainMembers } from "../../routines";
9
- import { API_DOMAIN_MEMBERS } from "../../api";
10
-
11
- describe("sagas: fetchDomainMembersRequestSaga", () => {
12
- it("should invoke fetchDomainMembersSaga on trigger", () => {
13
- expect(() => {
14
- testSaga(fetchDomainMembersRequestSaga)
15
- .next()
16
- .takeLatest(fetchDomainMembers.TRIGGER, fetchDomainMembersSaga)
17
- .finish()
18
- .isDone();
19
- }).not.toThrow();
20
- });
21
-
22
- it("should throw exception if an unhandled action is received", () => {
23
- expect(() => {
24
- testSaga(fetchDomainMembersRequestSaga)
25
- .next()
26
- .takeLatest("FOO", fetchDomainMembersSaga);
27
- }).toThrow();
28
- });
29
- });
30
-
31
- describe("sagas: fetchDomainMembersSaga", () => {
32
- const id = 1;
33
- const payload = { id };
34
- const url = compile(API_DOMAIN_MEMBERS)({ id });
35
- const data = {
36
- collection: [{ id: 1 }, { id: 2 }]
37
- };
38
-
39
- it("should put a success action when a response is returned", () => {
40
- expect(() => {
41
- testSaga(fetchDomainMembersSaga, { payload })
42
- .next()
43
- .put(fetchDomainMembers.request())
44
- .next()
45
- .call(apiJson, url, JSON_OPTS)
46
- .next({ data })
47
- .put(fetchDomainMembers.success(data))
48
- .next()
49
- .put(fetchDomainMembers.fulfill())
50
- .next()
51
- .isDone();
52
- }).not.toThrow();
53
- });
54
-
55
- it("should put a failure action when the call throws an error", () => {
56
- const message = "Request failed";
57
- const error = { message };
58
-
59
- expect(() => {
60
- testSaga(fetchDomainMembersSaga, { payload })
61
- .next()
62
- .put(fetchDomainMembers.request())
63
- .next()
64
- .call(apiJson, url, JSON_OPTS)
65
- .throw(error)
66
- .put(fetchDomainMembers.failure(message))
67
- .next()
68
- .put(fetchDomainMembers.fulfill())
69
- .next()
70
- .isDone();
71
- }).not.toThrow();
72
- });
73
- });
@@ -1,81 +0,0 @@
1
- import _ from "lodash/fp";
2
- import { compile } from "path-to-regexp";
3
- import { testSaga } from "redux-saga-test-plan";
4
- import { updateDomainMember } from "@truedat/bg/routines";
5
- import { apiJsonPatch, JSON_OPTS } from "@truedat/core/services/api";
6
- import {
7
- updateDomainMemberRequestSaga,
8
- updateDomainMemberSaga,
9
- } from "../updateDomainMember";
10
-
11
- import { API_DOMAIN_MEMBER } from "../../api";
12
-
13
- const toApiPath = compile(API_DOMAIN_MEMBER);
14
-
15
- describe("sagas: updateDomainMemberSaga", () => {
16
- it("should invoke updateDomainMemberSaga on updateDomainMember.TRIGGER", () => {
17
- expect(() => {
18
- testSaga(updateDomainMemberRequestSaga)
19
- .next()
20
- .takeLatest(updateDomainMember.TRIGGER, updateDomainMemberSaga)
21
- .finish()
22
- .isDone();
23
- }).not.toThrow();
24
- });
25
-
26
- it("should throw exception if an unhandled action is received", () => {
27
- expect(() => {
28
- testSaga(updateDomainMemberRequestSaga)
29
- .next()
30
- .takeLatest("FOO", updateDomainMemberRequestSaga);
31
- }).toThrow();
32
- });
33
- });
34
-
35
- describe("sagas: updateDomainMemberSaga", () => {
36
- const payload = {
37
- id: 1,
38
- acl_entry: {
39
- description: "some_description",
40
- },
41
- };
42
-
43
- const { acl_entry } = payload;
44
-
45
- const url = toApiPath({ id: payload.id });
46
-
47
- it("should put a success action when a response is returned", () => {
48
- expect(() => {
49
- testSaga(updateDomainMemberSaga, { payload })
50
- .next()
51
- .put(updateDomainMember.request(payload))
52
- .next()
53
- .call(apiJsonPatch, url, { acl_entry }, JSON_OPTS)
54
- .next({ data: payload })
55
- .put(updateDomainMember.success(payload))
56
- .next()
57
- .put(updateDomainMember.fulfill())
58
- .next()
59
- .isDone();
60
- }).not.toThrow();
61
- });
62
-
63
- it("should put a failure action when the call returns an error", () => {
64
- const message = "Request failed";
65
- const error = { message };
66
-
67
- expect(() => {
68
- testSaga(updateDomainMemberSaga, { payload })
69
- .next()
70
- .put(updateDomainMember.request(payload))
71
- .next()
72
- .call(apiJsonPatch, url, { acl_entry }, JSON_OPTS)
73
- .throw(error)
74
- .put(updateDomainMember.failure(message))
75
- .next()
76
- .put(updateDomainMember.fulfill())
77
- .next()
78
- .isDone();
79
- }).not.toThrow();
80
- });
81
- });
@@ -1,32 +0,0 @@
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 { addDomainMember } from "../routines";
5
- import { API_RESOURCE_ACL_ENTRIES } from "../api";
6
-
7
- const toApiPath = compile(API_RESOURCE_ACL_ENTRIES);
8
-
9
- export function* addDomainMemberSaga({ payload }) {
10
- try {
11
- const { resource_id, acl_entry } = payload;
12
- const url = toApiPath({ resource_id });
13
- const requestData = { acl_entry };
14
- const meta = { resource_id };
15
- yield put({ meta, ...addDomainMember.request() });
16
- const { data } = yield call(apiJsonPost, url, requestData, JSON_OPTS);
17
- yield put({ meta, ...addDomainMember.success(data) });
18
- } catch (error) {
19
- if (error.response) {
20
- const { status, data } = error.response;
21
- yield put(addDomainMember.failure({ status, data }));
22
- } else {
23
- yield put(addDomainMember.failure(error.message));
24
- }
25
- } finally {
26
- yield put(addDomainMember.fulfill());
27
- }
28
- }
29
-
30
- export function* addDomainMemberRequestSaga() {
31
- yield takeLatest(addDomainMember.TRIGGER, addDomainMemberSaga);
32
- }
@@ -1,29 +0,0 @@
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 { deleteDomainMember } from "../routines";
5
- import { API_ACL_ENTRY } from "../api";
6
-
7
- const toApiPath = compile(API_ACL_ENTRY);
8
-
9
- export function* deleteDomainMemberSaga({ payload }) {
10
- try {
11
- const url = toApiPath(payload);
12
- yield put(deleteDomainMember.request());
13
- yield call(apiJsonDelete, url, JSON_OPTS);
14
- yield put(deleteDomainMember.success(payload));
15
- } catch (error) {
16
- if (error.response) {
17
- const { status, data } = error.response;
18
- yield put(deleteDomainMember.failure({ status, data }));
19
- } else {
20
- yield put(deleteDomainMember.failure(error.message));
21
- }
22
- } finally {
23
- yield put(deleteDomainMember.fulfill());
24
- }
25
- }
26
-
27
- export function* deleteDomainMemberRequestSaga() {
28
- yield takeLatest(deleteDomainMember.TRIGGER, deleteDomainMemberSaga);
29
- }
@@ -1,47 +0,0 @@
1
- import _ from "lodash/fp";
2
- import { compile } from "path-to-regexp";
3
- import { call, put, takeLatest } from "redux-saga/effects";
4
- import { apiJson, JSON_OPTS } from "@truedat/core/services/api";
5
- import { fetchDomainConceptChildren } from "../routines";
6
- import { API_DOMAIN_CONCEPT_CHILDREN } from "../api";
7
-
8
- export function* fetchDomainConceptChildrenSaga({ payload }) {
9
- try {
10
- const { domain_id, user_name, principal_type, acl_entry_id } = payload;
11
- if (principal_type == "user") {
12
- const url = compile(API_DOMAIN_CONCEPT_CHILDREN)({
13
- domain_id,
14
- user_name
15
- });
16
- yield put(fetchDomainConceptChildren.request());
17
- const { data } = yield call(apiJson, url, JSON_OPTS);
18
- yield put(
19
- fetchDomainConceptChildren.success({
20
- data: { ..._.getOr({}, "data")(data), acl_entry_id }
21
- })
22
- );
23
- } else {
24
- yield put(
25
- fetchDomainConceptChildren.success({
26
- data: { counter: 0, acl_entry_id }
27
- })
28
- );
29
- }
30
- } catch (error) {
31
- if (error.response) {
32
- const { status, data } = error.response;
33
- yield put(fetchDomainConceptChildren.failure({ status, data }));
34
- } else {
35
- yield put(fetchDomainConceptChildren.failure(error.message));
36
- }
37
- } finally {
38
- yield put(fetchDomainConceptChildren.fulfill());
39
- }
40
- }
41
-
42
- export function* fetchDomainConceptChildrenRequestSaga() {
43
- yield takeLatest(
44
- fetchDomainConceptChildren.TRIGGER,
45
- fetchDomainConceptChildrenSaga
46
- );
47
- }
@@ -1,28 +0,0 @@
1
- import { compile } from "path-to-regexp";
2
- import { call, put, takeLatest } from "redux-saga/effects";
3
- import { apiJson, JSON_OPTS } from "@truedat/core/services/api";
4
- import { fetchDomainMembers } from "../routines";
5
- import { API_DOMAIN_MEMBERS } from "../api";
6
-
7
- export function* fetchDomainMembersSaga({ payload }) {
8
- try {
9
- const { id } = payload;
10
- const url = compile(API_DOMAIN_MEMBERS)({ id });
11
- yield put(fetchDomainMembers.request());
12
- const { data } = yield call(apiJson, url, JSON_OPTS);
13
- yield put(fetchDomainMembers.success(data));
14
- } catch (error) {
15
- if (error.response) {
16
- const { status, data } = error.response;
17
- yield put(fetchDomainMembers.failure({ status, data }));
18
- } else {
19
- yield put(fetchDomainMembers.failure(error.message));
20
- }
21
- } finally {
22
- yield put(fetchDomainMembers.fulfill());
23
- }
24
- }
25
-
26
- export function* fetchDomainMembersRequestSaga() {
27
- yield takeLatest(fetchDomainMembers.TRIGGER, fetchDomainMembersSaga);
28
- }
@@ -1,28 +0,0 @@
1
- import { compile } from "path-to-regexp";
2
- import { call, put, takeLatest } from "redux-saga/effects";
3
- import { apiJsonPatch, JSON_OPTS } from "@truedat/core/services/api";
4
- import { updateDomainMember } from "../routines";
5
- import { API_DOMAIN_MEMBER } from "../api";
6
-
7
- export function* updateDomainMemberSaga({ payload }) {
8
- try {
9
- const { id, acl_entry } = payload;
10
- const url = compile(API_DOMAIN_MEMBER)({ id });
11
- yield put(updateDomainMember.request(payload));
12
- const { data } = yield call(apiJsonPatch, url, { acl_entry }, JSON_OPTS);
13
- yield put(updateDomainMember.success(data));
14
- } catch (error) {
15
- if (error.response) {
16
- const { status, data } = error.response;
17
- yield put(updateDomainMember.failure({ status, data }));
18
- } else {
19
- yield put(updateDomainMember.failure(error.message));
20
- }
21
- } finally {
22
- yield put(updateDomainMember.fulfill());
23
- }
24
- }
25
-
26
- export function* updateDomainMemberRequestSaga() {
27
- yield takeLatest(updateDomainMember.TRIGGER, updateDomainMemberSaga);
28
- }