@truedat/bg 7.0.5 → 7.0.7

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 (99) hide show
  1. package/package.json +6 -6
  2. package/src/concepts/components/DomainConcepts.js +1 -4
  3. package/src/concepts/components/__tests__/__snapshots__/ConceptForm.spec.js.snap +5 -5
  4. package/src/concepts/components/__tests__/__snapshots__/ConceptsBulkUpdate.spec.js.snap +5 -5
  5. package/src/concepts/components/__tests__/__snapshots__/SharedToForm.spec.js.snap +5 -5
  6. package/src/hooks/useDomains.js +77 -0
  7. package/src/messages/en.js +6 -0
  8. package/src/messages/es.js +5 -0
  9. package/src/reducers/index.js +0 -1
  10. package/src/taxonomy/components/AddDomainMember.js +1 -7
  11. package/src/taxonomy/components/Domain.js +80 -84
  12. package/src/taxonomy/components/DomainActions.js +57 -84
  13. package/src/taxonomy/components/DomainCrumbs.js +51 -43
  14. package/src/taxonomy/components/DomainDetail.js +88 -46
  15. package/src/taxonomy/components/DomainForm.js +34 -36
  16. package/src/taxonomy/components/DomainImplementations.js +1 -4
  17. package/src/taxonomy/components/DomainMembers.js +8 -1
  18. package/src/taxonomy/components/DomainRoutes.js +8 -55
  19. package/src/taxonomy/components/DomainStructures.js +1 -4
  20. package/src/taxonomy/components/DomainTabs.js +22 -29
  21. package/src/taxonomy/components/Domains.js +66 -27
  22. package/src/taxonomy/components/DomainsActions.js +5 -14
  23. package/src/taxonomy/components/EditDomain.js +35 -21
  24. package/src/taxonomy/components/NewDomain.js +47 -22
  25. package/src/taxonomy/components/__tests__/Domain.spec.js +17 -8
  26. package/src/taxonomy/components/__tests__/DomainActions.spec.js +62 -7
  27. package/src/taxonomy/components/__tests__/DomainCrumbs.spec.js +18 -5
  28. package/src/taxonomy/components/__tests__/DomainDetail.spec.js +87 -4
  29. package/src/taxonomy/components/__tests__/DomainForm.spec.js +189 -4
  30. package/src/taxonomy/components/__tests__/DomainMembers.spec.js +1 -3
  31. package/src/taxonomy/components/__tests__/DomainStructures.spec.js +3 -2
  32. package/src/taxonomy/components/__tests__/Domains.spec.js +103 -6
  33. package/src/taxonomy/components/__tests__/EditDomain.spec.js +56 -5
  34. package/src/taxonomy/components/__tests__/NewDomain.spec.js +65 -6
  35. package/src/taxonomy/components/__tests__/__snapshots__/AddDomainMember.spec.js.snap +0 -10
  36. package/src/taxonomy/components/__tests__/__snapshots__/Domain.spec.js.snap +35 -48
  37. package/src/taxonomy/components/__tests__/__snapshots__/DomainActions.spec.js.snap +56 -1
  38. package/src/taxonomy/components/__tests__/__snapshots__/DomainCrumbs.spec.js.snap +14 -2
  39. package/src/taxonomy/components/__tests__/__snapshots__/DomainDetail.spec.js.snap +93 -40
  40. package/src/taxonomy/components/__tests__/__snapshots__/DomainForm.spec.js.snap +7 -7
  41. package/src/taxonomy/components/__tests__/__snapshots__/Domains.spec.js.snap +75 -10
  42. package/src/taxonomy/components/__tests__/__snapshots__/DomainsActions.spec.js.snap +20 -1
  43. package/src/taxonomy/components/__tests__/__snapshots__/EditDomain.spec.js.snap +192 -30
  44. package/src/taxonomy/components/__tests__/__snapshots__/NewDomain.spec.js.snap +405 -28
  45. package/src/taxonomy/components/index.js +1 -2
  46. package/src/taxonomy/index.js +0 -1
  47. package/src/taxonomy/routines.js +0 -10
  48. package/src/taxonomy/sagas/index.js +2 -21
  49. package/src/taxonomy/selectors/getDomainsConcept.js +0 -13
  50. package/src/taxonomy/selectors/index.js +0 -16
  51. package/src/taxonomy/components/DomainCards.js +0 -97
  52. package/src/taxonomy/components/DomainLoader.js +0 -60
  53. package/src/taxonomy/components/DomainMembersLoader.js +0 -44
  54. package/src/taxonomy/components/DomainsLoader.js +0 -40
  55. package/src/taxonomy/components/__tests__/DomainCards.spec.js +0 -30
  56. package/src/taxonomy/components/__tests__/DomainsLoader.spec.js +0 -38
  57. package/src/taxonomy/components/__tests__/__snapshots__/DomainCards.spec.js.snap +0 -160
  58. package/src/taxonomy/reducers/__tests__/domain.spec.js +0 -58
  59. package/src/taxonomy/reducers/__tests__/domainConceptLoading.spec.js +0 -26
  60. package/src/taxonomy/reducers/__tests__/domainCreating.spec.js +0 -24
  61. package/src/taxonomy/reducers/__tests__/domainLoading.spec.js +0 -22
  62. package/src/taxonomy/reducers/__tests__/domainMembersActions.spec.js +0 -38
  63. package/src/taxonomy/reducers/__tests__/domainMembersLoading.spec.js +0 -26
  64. package/src/taxonomy/reducers/__tests__/domainRedirect.spec.js +0 -36
  65. package/src/taxonomy/reducers/__tests__/domainUpdating.spec.js +0 -24
  66. package/src/taxonomy/reducers/__tests__/domains.spec.js +0 -30
  67. package/src/taxonomy/reducers/__tests__/domainsActions.spec.js +0 -36
  68. package/src/taxonomy/reducers/__tests__/domainsConcept.spec.js +0 -30
  69. package/src/taxonomy/reducers/__tests__/domainsFilter.spec.js +0 -41
  70. package/src/taxonomy/reducers/__tests__/domainsLoading.spec.js +0 -22
  71. package/src/taxonomy/reducers/domain.js +0 -32
  72. package/src/taxonomy/reducers/domainActions.js +0 -19
  73. package/src/taxonomy/reducers/domainCreating.js +0 -14
  74. package/src/taxonomy/reducers/domainLoading.js +0 -14
  75. package/src/taxonomy/reducers/domainMembersActions.js +0 -22
  76. package/src/taxonomy/reducers/domainMembersLoading.js +0 -12
  77. package/src/taxonomy/reducers/domainRedirect.js +0 -25
  78. package/src/taxonomy/reducers/domainUpdating.js +0 -14
  79. package/src/taxonomy/reducers/domains.js +0 -19
  80. package/src/taxonomy/reducers/domainsActions.js +0 -20
  81. package/src/taxonomy/reducers/domainsConcept.js +0 -19
  82. package/src/taxonomy/reducers/domainsConceptLoading.js +0 -12
  83. package/src/taxonomy/reducers/domainsFilter.js +0 -24
  84. package/src/taxonomy/reducers/domainsLoading.js +0 -12
  85. package/src/taxonomy/reducers/index.js +0 -31
  86. package/src/taxonomy/sagas/__tests__/fetchDomain.spec.js +0 -69
  87. package/src/taxonomy/sagas/__tests__/fetchDomains.spec.js +0 -90
  88. package/src/taxonomy/sagas/createDomain.js +0 -27
  89. package/src/taxonomy/sagas/deleteDomain.js +0 -34
  90. package/src/taxonomy/sagas/fetchDomain.js +0 -30
  91. package/src/taxonomy/sagas/fetchDomains.js +0 -37
  92. package/src/taxonomy/sagas/updateDomain.js +0 -30
  93. package/src/taxonomy/selectors/__tests__/domainParentOptionsSelector.spec.js +0 -24
  94. package/src/taxonomy/selectors/__tests__/getDomainActions.spec.js +0 -46
  95. package/src/taxonomy/selectors/__tests__/getDomainGroups.spec.js +0 -17
  96. package/src/taxonomy/selectors/__tests__/getDomainTypes.spec.js +0 -14
  97. package/src/taxonomy/selectors/domainParentOptionsSelector.js +0 -12
  98. package/src/taxonomy/selectors/getDomainActions.js +0 -32
  99. package/src/taxonomy/selectors/getDomainGroups.js +0 -11
@@ -1,30 +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 { fetchDomain } from "../routines";
5
- import { API_DOMAIN } from "../api";
6
-
7
- const toApiPath = compile(API_DOMAIN);
8
-
9
- export function* fetchDomainSaga({ payload }) {
10
- try {
11
- const { id } = payload;
12
- const url = toApiPath({ id });
13
- yield put(fetchDomain.request());
14
- const { data } = yield call(apiJson, url, JSON_OPTS);
15
- yield put(fetchDomain.success(data));
16
- } catch (error) {
17
- if (error.response) {
18
- const { status, data } = error.response;
19
- yield put(fetchDomain.failure({ status, data }));
20
- } else {
21
- yield put(fetchDomain.failure(error.message));
22
- }
23
- } finally {
24
- yield put(fetchDomain.fulfill());
25
- }
26
- }
27
-
28
- export function* fetchDomainRequestSaga() {
29
- yield takeLatest(fetchDomain.TRIGGER, fetchDomainSaga);
30
- }
@@ -1,37 +0,0 @@
1
- import _ from "lodash/fp";
2
- import { call, put, takeLatest } from "redux-saga/effects";
3
- import { apiJson, JSON_OPTS } from "@truedat/core/services/api";
4
- import { fetchDomains } from "../routines";
5
- import { API_DOMAINS } from "../api";
6
-
7
- export function* fetchDomainsSaga({ payload }) {
8
- try {
9
- const { actions, filter } = payload || {};
10
- const json_opts = actions
11
- ? {
12
- ...JSON_OPTS,
13
- params: {
14
- actions: _.flow(_.castArray, _.join(","))(actions),
15
- filter,
16
- },
17
- }
18
- : JSON_OPTS;
19
- const url = API_DOMAINS;
20
- yield put(fetchDomains.request(payload));
21
- const { data } = yield call(apiJson, url, json_opts);
22
- yield put(fetchDomains.success({ data, actions }));
23
- } catch (error) {
24
- if (error.response) {
25
- const { status, data } = error.response;
26
- yield put(fetchDomains.failure({ status, data }));
27
- } else {
28
- yield put(fetchDomains.failure(error.message));
29
- }
30
- } finally {
31
- yield put(fetchDomains.fulfill());
32
- }
33
- }
34
-
35
- export function* fetchDomainsRequestSaga() {
36
- yield takeLatest(fetchDomains.TRIGGER, fetchDomainsSaga);
37
- }
@@ -1,30 +0,0 @@
1
- import { compile } from "path-to-regexp";
2
- import { call, put, takeLatest } from "redux-saga/effects";
3
- import { apiJsonPut, JSON_OPTS } from "@truedat/core/services/api";
4
- import { updateDomain } from "../routines";
5
- import { API_DOMAIN } from "../api";
6
-
7
- const toApiPath = compile(API_DOMAIN);
8
-
9
- export function* updateDomainSaga({ payload: domain }) {
10
- try {
11
- const url = toApiPath(domain);
12
- const body = { domain };
13
- yield put(updateDomain.request());
14
- const { data } = yield call(apiJsonPut, url, body, JSON_OPTS);
15
- yield put(updateDomain.success(data));
16
- } catch (error) {
17
- if (error.response) {
18
- const { status, data } = error.response;
19
- yield put(updateDomain.failure({ status, data }));
20
- } else {
21
- yield put(updateDomain.failure(error.message));
22
- }
23
- } finally {
24
- yield put(updateDomain.fulfill());
25
- }
26
- }
27
-
28
- export function* updateDomainRequestSaga() {
29
- yield takeLatest(updateDomain.TRIGGER, updateDomainSaga);
30
- }
@@ -1,24 +0,0 @@
1
- import { domainParentOptionsSelector } from "..";
2
-
3
- describe("selectors: domainParentOptionsSelector", () => {
4
- const parentable_ids = [1, 3, 5];
5
- const domain = { parentable_ids };
6
- const domains = [
7
- { id: 1, name: "foo" },
8
- { id: 2, name: "bar" },
9
- { id: 3, name: "baz" }
10
- ];
11
-
12
- const state = { domains, domain };
13
-
14
- it("should return an option for each domain whose id is parentable", () => {
15
- const res = domainParentOptionsSelector(state);
16
- expect(res).toHaveLength(2);
17
- expect(res).toEqual(
18
- expect.arrayContaining([
19
- { key: 1, text: "foo", value: 1 },
20
- { key: 3, text: "baz", value: 3 }
21
- ])
22
- );
23
- });
24
- });
@@ -1,46 +0,0 @@
1
- import { getPrimaryActions, getSecondaryActions } from "./../getDomainActions";
2
-
3
- const domainActions = {
4
- create: {
5
- href: "/api/domains/",
6
- input: {},
7
- method: "post"
8
- },
9
- update: {
10
- href: "/api/domains/1",
11
- input: {},
12
- method: "put"
13
- }
14
- };
15
- const availableActions = {
16
- create: {
17
- action: jest.fn(),
18
- icon: "cube",
19
- messageId: "domain.actions.create",
20
- order: 1
21
- },
22
- update: {
23
- action: jest.fn(),
24
- icon: "cube",
25
- messageId: "domain.actions.update",
26
- order: 1
27
- }
28
- };
29
-
30
- describe("selectors: getDomainActions", () => {
31
- it("should return a create action", () => {
32
- const res = getPrimaryActions({ domainActions, availableActions });
33
- expect(res).toHaveLength(1);
34
- expect(res).toEqual([
35
- { key: "create", ...availableActions.create, ...domainActions.create }
36
- ]);
37
- });
38
-
39
- it("should return a update action", () => {
40
- const res = getSecondaryActions({ domainActions, availableActions });
41
- expect(res).toHaveLength(1);
42
- expect(res).toEqual([
43
- { key: "update", ...availableActions.update, ...domainActions.update }
44
- ]);
45
- });
46
- });
@@ -1,17 +0,0 @@
1
- import { getDomainGroups } from "..";
2
-
3
- describe("selectors: getDomainGroups", () => {
4
- const domains = [
5
- { id: 1, name: "domain", domain_group: { id: 1, name: "group" } },
6
- { id: 2, name: "domain1", domain_group: { id: 2, name: "group1" } },
7
- { id: 3, name: "domain2" },
8
- { id: 4, name: "domain3", domain_group: { id: 3, name: "group2" } }
9
- ];
10
-
11
- it("should return child domains if a domain is selected and there is no search filter", () => {
12
- const domainGroups = getDomainGroups({
13
- domains
14
- });
15
- expect(domainGroups).toMatchObject(["group", "group1", "group2"]);
16
- });
17
- });
@@ -1,14 +0,0 @@
1
- import { getDomainTypes } from "..";
2
-
3
- describe("selectors: getDomainTypes", () => {
4
- const d1 = { type: "Type2" };
5
- const d2 = { type: "Type1" };
6
- const d3 = { foo: "bar" };
7
- const domains = [d1, d2, d1, d3, d2, d2, d3];
8
-
9
- it("should return unique domain types", () => {
10
- const domainTypes = getDomainTypes({ domains });
11
- expect(domainTypes.length).toBe(2);
12
- expect(domainTypes).toEqual(["Type1", "Type2"]);
13
- });
14
- });
@@ -1,12 +0,0 @@
1
- import _ from "lodash/fp";
2
- import { createSelector } from "reselect";
3
-
4
- export const domainParentOptionsSelector = createSelector(
5
- _.pathOr([], "domain.parentable_ids"),
6
- _.propOr([], "domains"),
7
- (parentableIds, domains) =>
8
- _.flow(
9
- _.filter(d => _.includes(d.id)(parentableIds)),
10
- _.map(({ id, name }) => ({ key: id, text: name, value: id }))
11
- )(domains)
12
- );
@@ -1,32 +0,0 @@
1
- import _ from "lodash/fp";
2
- import { createSelector } from "reselect";
3
-
4
- const secondaryActions = ["delete", "update"];
5
- const hiddenActions = ["show", "index"];
6
-
7
- const getDomainActions = _.propOr({}, "domainActions");
8
- const getAvailableActions = _.propOr({}, "availableActions");
9
-
10
- const getNotHiddenActions = createSelector(
11
- [getDomainActions, getAvailableActions],
12
- (domainActions, availableActions) =>
13
- _.flow(
14
- _.omit(hiddenActions),
15
- _.toPairs,
16
- _.map(([key, actionProps]) => ({ key, ...actionProps })),
17
- _.filter(({ key }) => _.has(key)(availableActions)),
18
- _.map(a => ({ ...a, ..._.prop(_.prop("key")(a))(availableActions) }))
19
- )(domainActions)
20
- );
21
-
22
- export const getPrimaryActions = createSelector(
23
- [getNotHiddenActions],
24
- domainActions =>
25
- _.filter(({ key }) => !_.includes(key)(secondaryActions))(domainActions)
26
- );
27
-
28
- export const getSecondaryActions = createSelector(
29
- [getNotHiddenActions],
30
- domainActions =>
31
- _.filter(({ key }) => _.includes(key)(secondaryActions))(domainActions)
32
- );
@@ -1,11 +0,0 @@
1
- import _ from "lodash/fp";
2
- import { createSelector } from "reselect";
3
-
4
- export const getDomainGroups = createSelector(
5
- _.propOr([], "domains"),
6
- _.flow(
7
- _.map(_.path("domain_group.name")),
8
- _.filter(_.isString),
9
- _.sortBy(_.toLower)
10
- )
11
- );