@truedat/dd 4.51.2 → 4.51.3

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 (29) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/package.json +6 -6
  3. package/src/api/queries.js +24 -0
  4. package/src/api.js +0 -2
  5. package/src/components/DictionaryRoutes.js +0 -5
  6. package/src/components/EditDomainForm.js +15 -20
  7. package/src/components/LineageForm.js +23 -34
  8. package/src/components/PendingStructureNoteRow.js +5 -8
  9. package/src/components/PendingStructureNotes.js +25 -46
  10. package/src/components/PendingStructureNotesTable.js +46 -57
  11. package/src/components/StructuresRoutes.js +1 -11
  12. package/src/components/__tests__/EditDomainForm.spec.js +31 -46
  13. package/src/components/__tests__/LineageForm.spec.js +37 -122
  14. package/src/components/__tests__/PendingStructureNoteRow.spec.js +2 -2
  15. package/src/components/__tests__/PendingStructureNotes.spec.js +13 -15
  16. package/src/components/__tests__/__snapshots__/EditDomainForm.spec.js.snap +2 -71
  17. package/src/components/__tests__/__snapshots__/LineageForm.spec.js.snap +13 -14
  18. package/src/components/__tests__/__snapshots__/PendingStructureNotes.spec.js.snap +1 -2
  19. package/src/components/__tests__/__snapshots__/PendingStructureNotesTable.spec.js.snap +8 -16
  20. package/src/reducers/index.js +0 -2
  21. package/src/routines.js +0 -1
  22. package/src/sagas/index.js +0 -3
  23. package/src/selectors/index.js +0 -1
  24. package/src/reducers/__tests__/unitDomains.spec.js +0 -27
  25. package/src/reducers/unitDomains.js +0 -16
  26. package/src/sagas/__tests__/fetchUnitDomains.spec.js +0 -91
  27. package/src/sagas/fetchUnitDomains.js +0 -29
  28. package/src/selectors/__tests__/getDomainOptions.spec.js +0 -32
  29. package/src/selectors/getDomainOptions.js +0 -17
@@ -4,7 +4,6 @@ exports[`<PendingStructureNotes /> matches the latest snapshot 1`] = `
4
4
  <div>
5
5
  <div
6
6
  class="ui segment"
7
- style="display: none;"
8
7
  >
9
8
  <h2
10
9
  class="ui header"
@@ -25,7 +24,7 @@ exports[`<PendingStructureNotes /> matches the latest snapshot 1`] = `
25
24
  </div>
26
25
  </h2>
27
26
  <form
28
- class="ui form"
27
+ class="ui loading form"
29
28
  >
30
29
  <h5
31
30
  class="ui header"
@@ -46,9 +46,7 @@ exports[`<PendingStructureNotesTable /> matches the latest snapshot 1`] = `
46
46
  >
47
47
  <td
48
48
  class=""
49
- >
50
- bar
51
- </td>
49
+ />
52
50
  <td
53
51
  class=""
54
52
  >
@@ -56,18 +54,16 @@ exports[`<PendingStructureNotesTable /> matches the latest snapshot 1`] = `
56
54
  </td>
57
55
  <td
58
56
  class=""
59
- >
60
- bar system
61
- </td>
57
+ />
62
58
  <td
63
59
  class=""
64
60
  >
65
- bar domain
61
+
66
62
  </td>
67
63
  <td
68
64
  class=""
69
65
  >
70
- bar rute
66
+
71
67
  </td>
72
68
  </tr>
73
69
  <tr
@@ -75,9 +71,7 @@ exports[`<PendingStructureNotesTable /> matches the latest snapshot 1`] = `
75
71
  >
76
72
  <td
77
73
  class=""
78
- >
79
- foo
80
- </td>
74
+ />
81
75
  <td
82
76
  class=""
83
77
  >
@@ -85,18 +79,16 @@ exports[`<PendingStructureNotesTable /> matches the latest snapshot 1`] = `
85
79
  </td>
86
80
  <td
87
81
  class=""
88
- >
89
- foo system
90
- </td>
82
+ />
91
83
  <td
92
84
  class=""
93
85
  >
94
- foo domain 1, foo domain 2
86
+
95
87
  </td>
96
88
  <td
97
89
  class=""
98
90
  >
99
- foo rute &gt; other route
91
+
100
92
  </td>
101
93
  </tr>
102
94
  </tbody>
@@ -87,7 +87,6 @@ import { systemStructuresLoading } from "./systemStructuresLoading";
87
87
  import { systems } from "./systems";
88
88
  import { systemsLoading } from "./systemsLoading";
89
89
  import { tagSaving } from "./tagSaving";
90
- import { unitDomains } from "./unitDomains";
91
90
  import { uploadingStructuresFile } from "./uploadingStructuresFile";
92
91
  import { userPermissions } from "./userPermissions";
93
92
  import { userSearchFilters } from "./userSearchFilters";
@@ -184,7 +183,6 @@ export {
184
183
  systems,
185
184
  systemsLoading,
186
185
  tagSaving,
187
- unitDomains,
188
186
  uploadingStructuresFile,
189
187
  userPermissions,
190
188
  userSearchFilters,
package/src/routines.js CHANGED
@@ -80,7 +80,6 @@ export const fetchStructuresUploadEvents = createRoutine("FETCH_STRUCTURES_UPLOA
80
80
  export const fetchSystem = createRoutine("FETCH_SYSTEM");
81
81
  export const fetchSystemStructures = createRoutine("FETCH_SYSTEM_STRUCTURES");
82
82
  export const fetchSystems = createRoutine("FETCH_SYSTEMS");
83
- export const fetchUnitDomains = createRoutine("FETCH_UNIT_DOMAINS");
84
83
  export const fetchUserSearchFilters = createRoutine("FETCH_USER_SEARCH_FILTERS");
85
84
  export const filterStructures = createRoutine("FILTER_STRUCTURES");
86
85
  export const hoverNode = createRoutine("HOVER_NODE");
@@ -38,7 +38,6 @@ import { fetchStructuresUploadEventsRequestSaga } from "./fetchStructuresUploadE
38
38
  import { fetchSystemRequestSaga } from "./fetchSystem";
39
39
  import { fetchSystemStructuresRequestSaga } from "./fetchSystemStructures";
40
40
  import { fetchSystemsRequestSaga } from "./fetchSystems";
41
- import { fetchUnitDomainsRequestSaga } from "./fetchUnitDomains";
42
41
  import { fetchUserSearchFiltersRequestSaga } from "./fetchUserSearchFilters";
43
42
  import { tagStructureRequestSaga } from "./tagStructure";
44
43
  import { operateGrantRequestToCartRequestSaga } from "./operateGrantRequestCart";
@@ -93,7 +92,6 @@ export {
93
92
  fetchSystemRequestSaga,
94
93
  fetchSystemStructuresRequestSaga,
95
94
  fetchSystemsRequestSaga,
96
- fetchUnitDomainsRequestSaga,
97
95
  fetchUserSearchFiltersRequestSaga,
98
96
  tagStructureRequestSaga,
99
97
  operateGrantRequestToCartRequestSaga,
@@ -149,7 +147,6 @@ export default [
149
147
  fetchSystemRequestSaga(),
150
148
  fetchSystemStructuresRequestSaga(),
151
149
  fetchSystemsRequestSaga(),
152
- fetchUnitDomainsRequestSaga(),
153
150
  fetchUserSearchFiltersRequestSaga(),
154
151
  tagStructureRequestSaga(),
155
152
  operateGrantRequestToCartRequestSaga(),
@@ -11,7 +11,6 @@ export {
11
11
  defaultStructureProperties,
12
12
  getStructureProperties,
13
13
  } from "./getStructureProperties";
14
- export { getDomainOptions } from "./getDomainOptions";
15
14
  export {
16
15
  getParentRelationColumns,
17
16
  getChildrenRelationColumns,
@@ -1,27 +0,0 @@
1
- import { fetchUnitDomains } from "../../routines";
2
- import { unitDomains } from "..";
3
-
4
- const fooState = { foo: "bar" };
5
-
6
- describe("reducers: unitDomains", () => {
7
- const initialState = [];
8
-
9
- it("should provide the initial state", () => {
10
- expect(unitDomains(undefined, {})).toEqual(initialState);
11
- });
12
-
13
- it("should handle the fetchUnitDomains.SUCCESS action", () => {
14
- const data = [{ id: 1, name: "foo" }];
15
-
16
- expect(
17
- unitDomains(fooState, {
18
- type: fetchUnitDomains.SUCCESS,
19
- payload: { data },
20
- })
21
- ).toMatchObject(data);
22
- });
23
-
24
- it("should ignore unknown actions", () => {
25
- expect(unitDomains(fooState, { type: "FOO" })).toBe(fooState);
26
- });
27
- });
@@ -1,16 +0,0 @@
1
- import { fetchUnitDomains } from "../routines";
2
-
3
- const initialState = [];
4
-
5
- const unitDomains = (state = initialState, { type, payload }) => {
6
- switch (type) {
7
- case fetchUnitDomains.TRIGGER:
8
- return initialState;
9
- case fetchUnitDomains.SUCCESS:
10
- return payload?.data;
11
- default:
12
- return state;
13
- }
14
- };
15
-
16
- export { unitDomains };
@@ -1,91 +0,0 @@
1
- import { testSaga } from "redux-saga-test-plan";
2
- import { apiJson, JSON_OPTS } from "@truedat/core/services/api";
3
- import {
4
- fetchUnitDomainsRequestSaga,
5
- fetchUnitDomainsSaga,
6
- } from "../fetchUnitDomains";
7
- import { fetchUnitDomains } from "../../routines";
8
- import { API_UNIT_DOMAINS } from "../../api";
9
-
10
- describe("sagas: fetchUnitDomainsRequestSaga", () => {
11
- it("should invoke fetchUnitDomainsSaga on trigger", () => {
12
- expect(() => {
13
- testSaga(fetchUnitDomainsRequestSaga)
14
- .next()
15
- .takeLatest(fetchUnitDomains.TRIGGER, fetchUnitDomainsSaga)
16
- .finish()
17
- .isDone();
18
- }).not.toThrow();
19
- });
20
-
21
- it("should throw exception if an unhandled action is received", () => {
22
- expect(() => {
23
- testSaga(fetchUnitDomainsRequestSaga)
24
- .next()
25
- .takeLatest("FOO", fetchUnitDomainsSaga);
26
- }).toThrow();
27
- });
28
- });
29
-
30
- describe("sagas: fetchUnitDomainsSaga", () => {
31
- const data = [
32
- { id: 1, name: "d1" },
33
- { id: 2, name: "d2" },
34
- ];
35
-
36
- it("should put a success action when a response is returned", () => {
37
- expect(() => {
38
- testSaga(fetchUnitDomainsSaga)
39
- .next()
40
- .put(fetchUnitDomains.request())
41
- .next()
42
- .call(apiJson, API_UNIT_DOMAINS + "?actions=view_lineage", JSON_OPTS)
43
- .next({ data })
44
- .put(fetchUnitDomains.success(data))
45
- .next()
46
- .put(fetchUnitDomains.fulfill())
47
- .next()
48
- .isDone();
49
- }).not.toThrow();
50
- });
51
-
52
- it("should put a failure action when the call returns an error", () => {
53
- const message = "Request failed";
54
- const error = { message };
55
-
56
- expect(() => {
57
- testSaga(fetchUnitDomainsSaga)
58
- .next()
59
- .put(fetchUnitDomains.request())
60
- .next()
61
- .call(apiJson, API_UNIT_DOMAINS + "?actions=view_lineage", JSON_OPTS)
62
- .throw(error)
63
- .put(fetchUnitDomains.failure(message))
64
- .next()
65
- .put(fetchUnitDomains.fulfill())
66
- .next()
67
- .isDone();
68
- }).not.toThrow();
69
- });
70
-
71
- it("should put a failure action when the call returns an object message", () => {
72
- const status = 404;
73
- const data = "foo";
74
- const response = { status, data };
75
- const error = { response };
76
-
77
- expect(() => {
78
- testSaga(fetchUnitDomainsSaga)
79
- .next()
80
- .put(fetchUnitDomains.request())
81
- .next()
82
- .call(apiJson, API_UNIT_DOMAINS + "?actions=view_lineage", JSON_OPTS)
83
- .throw(error)
84
- .put(fetchUnitDomains.failure({ status, data }))
85
- .next()
86
- .put(fetchUnitDomains.fulfill())
87
- .next()
88
- .isDone();
89
- }).not.toThrow();
90
- });
91
- });
@@ -1,29 +0,0 @@
1
- import { call, put, takeLatest } from "redux-saga/effects";
2
- import { apiJson, JSON_OPTS } from "@truedat/core/services/api";
3
- import { fetchUnitDomains } from "../routines";
4
- import { API_UNIT_DOMAINS } from "../api";
5
-
6
- export function* fetchUnitDomainsSaga() {
7
- try {
8
- yield put(fetchUnitDomains.request());
9
- const { data } = yield call(
10
- apiJson,
11
- API_UNIT_DOMAINS + "?actions=view_lineage",
12
- JSON_OPTS
13
- );
14
- yield put(fetchUnitDomains.success(data));
15
- } catch (error) {
16
- if (error.response) {
17
- const { status, data } = error.response;
18
- yield put(fetchUnitDomains.failure({ status, data }));
19
- } else {
20
- yield put(fetchUnitDomains.failure(error.message));
21
- }
22
- } finally {
23
- yield put(fetchUnitDomains.fulfill());
24
- }
25
- }
26
-
27
- export function* fetchUnitDomainsRequestSaga() {
28
- yield takeLatest(fetchUnitDomains.TRIGGER, fetchUnitDomainsSaga);
29
- }
@@ -1,32 +0,0 @@
1
- import _ from "lodash/fp";
2
- import { getDomainOptions } from "..";
3
-
4
- describe("selectors: getDomainOptions", () => {
5
- it("should obtain the selected system by id from the systems reducer", () => {
6
- const d1 = { id: 1, name: "foo", parent_id: undefined };
7
- const d2 = { id: 2, name: "bar", parent_id: 1, parent_ids: [1] };
8
- const unitDomains = [d1, d2];
9
- const state = { unitDomains };
10
- const res = getDomainOptions(state);
11
- expect(res).toEqual([
12
- {
13
- id: 1,
14
- name: "foo",
15
- parent_id: undefined,
16
- ancestors: [],
17
- descendents: [_.omit(["parent_ids"])(d2)],
18
- children: [_.omit(["parent_ids"])(d2)],
19
- level: 0,
20
- },
21
- {
22
- id: 2,
23
- name: "bar",
24
- parent_id: 1,
25
- ancestors: [d1],
26
- descendents: [],
27
- children: [],
28
- level: 1,
29
- },
30
- ]);
31
- });
32
- });
@@ -1,17 +0,0 @@
1
- import _ from "lodash/fp";
2
- import { createSelector } from "reselect";
3
- import { getDomainSelectorOptions } from "@truedat/bg/selectors";
4
-
5
- export const getDomainOptions = createSelector(
6
- _.prop("unitDomains"),
7
- (unitDomains) => {
8
- const domains = _.flow(
9
- _.map((domain) => ({
10
- ...domain,
11
- parent_id: _.head(domain.parent_ids),
12
- })),
13
- _.map(_.omit(["parent_ids"]))
14
- )(unitDomains);
15
- return getDomainSelectorOptions({ domains });
16
- }
17
- );