@truedat/dd 4.44.3 → 4.45.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.
Files changed (95) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/package.json +24 -20
  3. package/src/api/mutations.js +27 -0
  4. package/src/api/queries.js +24 -0
  5. package/src/api.js +2 -0
  6. package/src/components/DictionaryRoutes.js +7 -5
  7. package/src/components/EditDomainPopup.js +1 -1
  8. package/src/components/FilteredNav.js +9 -9
  9. package/src/components/GrantFilters.js +1 -5
  10. package/src/components/GrantRequestApprovalPopup.js +0 -1
  11. package/src/components/PendingStructureNotes.js +1 -1
  12. package/src/components/ReferenceDataset.js +23 -0
  13. package/src/components/ReferenceDatasetActions.js +88 -0
  14. package/src/components/ReferenceDatasetBreadcrumbs.js +22 -0
  15. package/src/components/ReferenceDatasetCreate.js +36 -0
  16. package/src/components/ReferenceDatasetDetail.js +42 -0
  17. package/src/components/ReferenceDatasetForm.js +109 -0
  18. package/src/components/ReferenceDatasetHeader.js +32 -0
  19. package/src/components/ReferenceDatasetRoutes.js +56 -0
  20. package/src/components/ReferenceDatasetTable.js +42 -0
  21. package/src/components/ReferenceDatasets.js +61 -0
  22. package/src/components/ReferenceDatasetsTable.js +105 -0
  23. package/src/components/StructureConfidentialButton.js +1 -1
  24. package/src/components/StructureFilters.js +1 -5
  25. package/src/components/StructureNotesEdit.js +6 -6
  26. package/src/components/StructureProperties.js +4 -1
  27. package/src/components/StructureTabPane.js +4 -2
  28. package/src/components/StructureTagsRoutes.js +0 -1
  29. package/src/components/StructureTypesCrumbs.js +0 -1
  30. package/src/components/StructureVersionListItem.js +2 -2
  31. package/src/components/StructureView.js +1 -3
  32. package/src/components/SystemForm.js +1 -1
  33. package/src/components/__tests__/LineageRoutes.spec.js +4 -4
  34. package/src/components/__tests__/ReferenceDataset.spec.js +64 -0
  35. package/src/components/__tests__/ReferenceDatasetActions.spec.js +17 -0
  36. package/src/components/__tests__/ReferenceDatasetBreadcrumbs.spec.js +12 -0
  37. package/src/components/__tests__/ReferenceDatasetCreate.spec.js +12 -0
  38. package/src/components/__tests__/ReferenceDatasetDetail.spec.js +37 -0
  39. package/src/components/__tests__/ReferenceDatasetForm.spec.js +51 -0
  40. package/src/components/__tests__/ReferenceDatasetHeader.spec.js +17 -0
  41. package/src/components/__tests__/ReferenceDatasetRoutes.spec.js +74 -0
  42. package/src/components/__tests__/ReferenceDatasetTable.spec.js +18 -0
  43. package/src/components/__tests__/ReferenceDatasets.spec.js +32 -0
  44. package/src/components/__tests__/ReferenceDatasetsTable.spec.js +22 -0
  45. package/src/components/__tests__/StructureConfidentialButton.spec.js +26 -30
  46. package/src/components/__tests__/StructureNotesEdit.spec.js +2 -9
  47. package/src/components/__tests__/StructureProperties.spec.js +6 -8
  48. package/src/components/__tests__/StructureVersionListItem.spec.js +4 -4
  49. package/src/components/__tests__/__snapshots__/DictionaryRoutes.spec.js.snap +4 -0
  50. package/src/components/__tests__/__snapshots__/LineageRoutes.spec.js.snap +1 -20
  51. package/src/components/__tests__/__snapshots__/ProfileExecution.spec.js.snap +2 -1
  52. package/src/components/__tests__/__snapshots__/ReferenceDataset.spec.js.snap +365 -0
  53. package/src/components/__tests__/__snapshots__/ReferenceDatasetActions.spec.js.snap +65 -0
  54. package/src/components/__tests__/__snapshots__/ReferenceDatasetBreadcrumbs.spec.js.snap +25 -0
  55. package/src/components/__tests__/__snapshots__/ReferenceDatasetCreate.spec.js.snap +98 -0
  56. package/src/components/__tests__/__snapshots__/ReferenceDatasetDetail.spec.js.snap +135 -0
  57. package/src/components/__tests__/__snapshots__/ReferenceDatasetForm.spec.js.snap +61 -0
  58. package/src/components/__tests__/__snapshots__/ReferenceDatasetHeader.spec.js.snap +95 -0
  59. package/src/components/__tests__/__snapshots__/ReferenceDatasetRoutes.spec.js.snap +414 -0
  60. package/src/components/__tests__/__snapshots__/ReferenceDatasetTable.spec.js.snap +75 -0
  61. package/src/components/__tests__/__snapshots__/ReferenceDatasets.spec.js.snap +128 -0
  62. package/src/components/__tests__/__snapshots__/ReferenceDatasetsTable.spec.js.snap +86 -0
  63. package/src/components/__tests__/__snapshots__/StructureConfidentialButton.spec.js.snap +13 -33
  64. package/src/components/__tests__/__snapshots__/StructureProperties.spec.js.snap +76 -71
  65. package/src/components/__tests__/__snapshots__/StructureTabPane.spec.js.snap +1 -1
  66. package/src/components/__tests__/__snapshots__/StructureVersionListItem.spec.js.snap +31 -64
  67. package/src/components/index.js +0 -6
  68. package/src/messages/en.js +18 -0
  69. package/src/messages/es.js +20 -0
  70. package/src/reducers/__tests__/ddMessage.spec.js +26 -5
  71. package/src/reducers/__tests__/graph.spec.js +1 -6
  72. package/src/reducers/__tests__/referenceDatasetSaving.spec.js +44 -0
  73. package/src/reducers/__tests__/structureRedirect.spec.js +37 -13
  74. package/src/reducers/ddMessage.js +26 -1
  75. package/src/reducers/index.js +2 -0
  76. package/src/reducers/referenceDatasetSaving.js +16 -0
  77. package/src/reducers/structureRedirect.js +36 -15
  78. package/src/reducers/structuresUploadEvents.js +0 -1
  79. package/src/routines.js +35 -74
  80. package/src/sagas/__tests__/createReferenceDataset.spec.js +90 -0
  81. package/src/sagas/__tests__/deleteReferenceDataset.spec.js +81 -0
  82. package/src/sagas/__tests__/updateReferenceDataset.spec.js +116 -0
  83. package/src/sagas/createReferenceDataset.js +34 -0
  84. package/src/sagas/deleteReferenceDataset.js +29 -0
  85. package/src/sagas/downloadReferenceDataset.js +44 -0
  86. package/src/sagas/index.js +31 -22
  87. package/src/sagas/updateReferenceDataset.js +35 -0
  88. package/src/selectors/getRelationSortingCriteria.js +3 -5
  89. package/src/selectors/getTabVisibility.js +1 -4
  90. package/src/components/ProfilingElements.js +0 -89
  91. package/src/components/ProfilingGraph.js +0 -89
  92. package/src/components/ProfilingPatterns.js +0 -57
  93. package/src/components/StructureProfiling.js +0 -124
  94. package/src/components/__tests__/StructureProfiling.spec.js +0 -45
  95. package/src/components/__tests__/__snapshots__/StructureProfiling.spec.js.snap +0 -444
@@ -0,0 +1,81 @@
1
+ import { testSaga } from "redux-saga-test-plan";
2
+ import {
3
+ deleteReferenceDatasetRequestSaga,
4
+ deleteReferenceDatasetSaga,
5
+ onSuccess,
6
+ } from "../deleteReferenceDataset";
7
+ import { DELETE_REFERENCE_DATASET } from "../../api/mutations";
8
+ import { deleteReferenceDataset } from "../../routines";
9
+
10
+ describe("sagas: deleteReferenceDatasetRequestSaga", () => {
11
+ it("should invoke deleteReferenceDatasetSaga on deleteReferenceDataset.TRIGGER", () => {
12
+ expect(() => {
13
+ testSaga(deleteReferenceDatasetRequestSaga)
14
+ .next()
15
+ .takeLatest(deleteReferenceDataset.TRIGGER, deleteReferenceDatasetSaga)
16
+ .finish()
17
+ .isDone();
18
+ }).not.toThrow();
19
+ });
20
+
21
+ it("should throw exception if an unhandled action is received", () => {
22
+ expect(() => {
23
+ testSaga(deleteReferenceDatasetRequestSaga)
24
+ .next()
25
+ .takeLatest("FOO", deleteReferenceDatasetRequestSaga);
26
+ }).toThrow();
27
+ });
28
+ });
29
+
30
+ describe("sagas: deleteReferenceDatasetSaga", () => {
31
+ const client = { mutate: jest.fn() };
32
+ const id = "123";
33
+ const payload = { id };
34
+
35
+ it("should put a success action when a response is returned", () => {
36
+ expect(() => {
37
+ testSaga(deleteReferenceDatasetSaga, { payload })
38
+ .next()
39
+ .getContext("client")
40
+ .next(client)
41
+ .put(deleteReferenceDataset.request(payload))
42
+ .next()
43
+ .call(client.mutate, {
44
+ mutation: DELETE_REFERENCE_DATASET,
45
+ update: onSuccess,
46
+ variables: payload,
47
+ })
48
+ .next({ data: payload })
49
+ .put(deleteReferenceDataset.success(payload))
50
+ .next()
51
+ .put(deleteReferenceDataset.fulfill())
52
+ .next()
53
+ .isDone();
54
+ }).not.toThrow();
55
+ });
56
+
57
+ it("should put a failure action when the call returns an error", () => {
58
+ const message = "Request failed";
59
+ const error = { message };
60
+
61
+ expect(() => {
62
+ testSaga(deleteReferenceDatasetSaga, { payload })
63
+ .next()
64
+ .getContext("client")
65
+ .next(client)
66
+ .put(deleteReferenceDataset.request(payload))
67
+ .next()
68
+ .call(client.mutate, {
69
+ mutation: DELETE_REFERENCE_DATASET,
70
+ update: onSuccess,
71
+ variables: payload,
72
+ })
73
+ .throw(error)
74
+ .put(deleteReferenceDataset.failure(message))
75
+ .next()
76
+ .put(deleteReferenceDataset.fulfill())
77
+ .next()
78
+ .isDone();
79
+ }).not.toThrow();
80
+ });
81
+ });
@@ -0,0 +1,116 @@
1
+ import { testSaga } from "redux-saga-test-plan";
2
+ import { toBase64 } from "@truedat/core/services/file";
3
+ import {
4
+ updateReferenceDatasetRequestSaga,
5
+ updateReferenceDatasetSaga,
6
+ onSuccess,
7
+ } from "../updateReferenceDataset";
8
+ import { UPDATE_REFERENCE_DATASET } from "../../api/mutations";
9
+ import { updateReferenceDataset } from "../../routines";
10
+
11
+ describe("sagas: updateReferenceDatasetRequestSaga", () => {
12
+ it("should invoke updateReferenceDatasetSaga on updateReferenceDataset.TRIGGER", () => {
13
+ expect(() => {
14
+ testSaga(updateReferenceDatasetRequestSaga)
15
+ .next()
16
+ .takeLatest(updateReferenceDataset.TRIGGER, updateReferenceDatasetSaga)
17
+ .finish()
18
+ .isDone();
19
+ }).not.toThrow();
20
+ });
21
+
22
+ it("should throw exception if an unhandled action is received", () => {
23
+ expect(() => {
24
+ testSaga(updateReferenceDatasetRequestSaga)
25
+ .next()
26
+ .takeLatest("FOO", updateReferenceDatasetRequestSaga);
27
+ }).toThrow();
28
+ });
29
+ });
30
+
31
+ describe("sagas: updateReferenceDatasetSaga", () => {
32
+ const client = { mutate: jest.fn() };
33
+ const file = { foo: "bar" };
34
+ const id = "42";
35
+ const name = "foo";
36
+ const encoded = "data:text/csv;base64,Rk9PO0JBUjtCQVo=";
37
+ const payload = { id, name, file };
38
+ const dataset = { id, name, data: encoded };
39
+ const variables = { dataset };
40
+
41
+ it("should put a success action when a response is returned", () => {
42
+ expect(() => {
43
+ testSaga(updateReferenceDatasetSaga, { payload })
44
+ .next()
45
+ .getContext("client")
46
+ .next(client)
47
+ .call(toBase64, file)
48
+ .next(encoded)
49
+ .put(updateReferenceDataset.request(dataset))
50
+ .next()
51
+ .call(client.mutate, {
52
+ mutation: UPDATE_REFERENCE_DATASET,
53
+ update: onSuccess,
54
+ variables,
55
+ })
56
+ .next({ data: payload })
57
+ .put(updateReferenceDataset.success(payload))
58
+ .next()
59
+ .put(updateReferenceDataset.fulfill())
60
+ .next()
61
+ .isDone();
62
+ }).not.toThrow();
63
+ });
64
+
65
+ it("should not encode file if absent from payload", () => {
66
+ const payload = { id, name };
67
+ const dataset = payload;
68
+ const variables = { dataset };
69
+ expect(() => {
70
+ testSaga(updateReferenceDatasetSaga, { payload })
71
+ .next()
72
+ .getContext("client")
73
+ .next(client)
74
+ .put(updateReferenceDataset.request(dataset))
75
+ .next()
76
+ .call(client.mutate, {
77
+ mutation: UPDATE_REFERENCE_DATASET,
78
+ update: onSuccess,
79
+ variables,
80
+ })
81
+ .next({ data: payload })
82
+ .put(updateReferenceDataset.success(payload))
83
+ .next()
84
+ .put(updateReferenceDataset.fulfill())
85
+ .next()
86
+ .isDone();
87
+ }).not.toThrow();
88
+ });
89
+
90
+ it("should put a failure action when the call returns an error", () => {
91
+ const message = "Request failed";
92
+ const error = { message };
93
+
94
+ expect(() => {
95
+ testSaga(updateReferenceDatasetSaga, { payload })
96
+ .next()
97
+ .getContext("client")
98
+ .next(client)
99
+ .call(toBase64, file)
100
+ .next(encoded)
101
+ .put(updateReferenceDataset.request(dataset))
102
+ .next()
103
+ .call(client.mutate, {
104
+ mutation: UPDATE_REFERENCE_DATASET,
105
+ update: onSuccess,
106
+ variables,
107
+ })
108
+ .throw(error)
109
+ .put(updateReferenceDataset.failure(message))
110
+ .next()
111
+ .put(updateReferenceDataset.fulfill())
112
+ .next()
113
+ .isDone();
114
+ }).not.toThrow();
115
+ });
116
+ });
@@ -0,0 +1,34 @@
1
+ import { call, put, takeLatest, getContext } from "redux-saga/effects";
2
+ import { toBase64 } from "@truedat/core/services/file";
3
+ import { CREATE_REFERENCE_DATASET } from "../api/mutations";
4
+ import { createReferenceDataset } from "../routines";
5
+
6
+ export const onSuccess = (cache) => {
7
+ cache.evict({ id: "ROOT_QUERY", fieldName: "referenceDatasets" });
8
+ cache.gc();
9
+ };
10
+
11
+ export function* createReferenceDatasetSaga({
12
+ payload: { file, ...rest } = {},
13
+ }) {
14
+ const client = yield getContext("client");
15
+ try {
16
+ const dataUrl = yield call(toBase64, file);
17
+ const dataset = { ...rest, data: dataUrl };
18
+ yield put(createReferenceDataset.request(dataset));
19
+ const { data } = yield call(client.mutate, {
20
+ mutation: CREATE_REFERENCE_DATASET,
21
+ update: onSuccess,
22
+ variables: { dataset },
23
+ });
24
+ yield put(createReferenceDataset.success(data));
25
+ } catch (error) {
26
+ yield put(createReferenceDataset.failure(error.message));
27
+ } finally {
28
+ yield put(createReferenceDataset.fulfill());
29
+ }
30
+ }
31
+
32
+ export function* createReferenceDatasetRequestSaga() {
33
+ yield takeLatest(createReferenceDataset.TRIGGER, createReferenceDatasetSaga);
34
+ }
@@ -0,0 +1,29 @@
1
+ import { call, put, takeLatest, getContext } from "redux-saga/effects";
2
+ import { DELETE_REFERENCE_DATASET } from "../api/mutations";
3
+ import { deleteReferenceDataset } from "../routines";
4
+
5
+ export const onSuccess = (cache) => {
6
+ cache.evict({ id: "ROOT_QUERY", fieldName: "referenceDatasets" });
7
+ cache.gc();
8
+ };
9
+
10
+ export function* deleteReferenceDatasetSaga({ payload }) {
11
+ const client = yield getContext("client");
12
+ try {
13
+ yield put(deleteReferenceDataset.request(payload));
14
+ const { data } = yield call(client.mutate, {
15
+ mutation: DELETE_REFERENCE_DATASET,
16
+ update: onSuccess,
17
+ variables: payload,
18
+ });
19
+ yield put(deleteReferenceDataset.success(data));
20
+ } catch (error) {
21
+ yield put(deleteReferenceDataset.failure(error.message));
22
+ } finally {
23
+ yield put(deleteReferenceDataset.fulfill());
24
+ }
25
+ }
26
+
27
+ export function* deleteReferenceDatasetRequestSaga() {
28
+ yield takeLatest(deleteReferenceDataset.TRIGGER, deleteReferenceDatasetSaga);
29
+ }
@@ -0,0 +1,44 @@
1
+ import _ from "lodash/fp";
2
+ import { compile } from "path-to-regexp";
3
+ import FileSaver from "file-saver";
4
+ import { call, put, takeLatest } from "redux-saga/effects";
5
+ import { apiJson, JSON_OPTS } from "@truedat/core/services/api";
6
+ import { lowerDeburrTrim } from "@truedat/core/services/sort";
7
+ import { downloadReferenceDataset } from "../routines";
8
+ import { API_REFERENCE_DATA_DOWNLOAD } from "../api";
9
+
10
+ export function saveFile(name, data) {
11
+ if (!_.isEmpty(data)) {
12
+ const fileName = lowerDeburrTrim(name);
13
+ const blob = new Blob([String.fromCharCode(0xfeff), data], {
14
+ type: "text/csv;charset=utf-8",
15
+ });
16
+ FileSaver.saveAs(blob, `${fileName}.csv`);
17
+ }
18
+ }
19
+
20
+ export function* downloadReferenceDatasetSaga({ payload: { id, name } = {} }) {
21
+ try {
22
+ const url = compile(API_REFERENCE_DATA_DOWNLOAD)({ id });
23
+ yield put(downloadReferenceDataset.request(id));
24
+ const { data } = yield call(apiJson, url, JSON_OPTS);
25
+ yield call(saveFile, name, data);
26
+ yield put(downloadReferenceDataset.success({ id }));
27
+ } catch (error) {
28
+ if (error.response) {
29
+ const { status, data } = error.response;
30
+ yield put(downloadReferenceDataset.failure({ status, data }));
31
+ } else {
32
+ yield put(downloadReferenceDataset.failure(error.message));
33
+ }
34
+ } finally {
35
+ yield put(downloadReferenceDataset.fulfill());
36
+ }
37
+ }
38
+
39
+ export function* downloadReferenceDatasetRequestSaga() {
40
+ yield takeLatest(
41
+ downloadReferenceDataset.TRIGGER,
42
+ downloadReferenceDatasetSaga
43
+ );
44
+ }
@@ -1,24 +1,26 @@
1
1
  import { bulkUpdateStructuresRequestsSaga } from "./bulkUpdateStructures";
2
- //import { cancelPollRequestSaga } from "./cancelPoll";
3
2
  import { createGrantRequestApprovalRequestSaga } from "./createGrantRequestApproval";
4
3
  import { createGraphRequestSaga } from "./createGraph";
5
4
  import { createProfileGroupRequestSaga } from "./createProfileGroup";
5
+ import { createReferenceDatasetRequestSaga } from "./createReferenceDataset";
6
6
  import { createStructureGraphRequestSaga } from "./createStructureGraph";
7
7
  import { createStructureTagRequestSaga } from "./createStructureTag";
8
- import { deleteStructureRequestSaga } from "./deleteStructure";
9
8
  import { createSystemRequestSaga } from "./createSystem";
10
9
  import { deleteLinkStructureTagRequestSaga } from "./deleteLinkStructureTag";
10
+ import { deleteReferenceDatasetRequestSaga } from "./deleteReferenceDataset";
11
+ import { deleteStructureRequestSaga } from "./deleteStructure";
11
12
  import { deleteStructureTagRequestSaga } from "./deleteStructureTag";
12
13
  import { deleteUserSearchFilterRequestSaga } from "./deleteUserSearchFilter";
13
14
  import { doStructureNoteActionRequestSaga } from "./doStructureNoteAction";
14
15
  import { downloadCsvGraphRequestSaga } from "./downloadCsvGraph";
15
- import { downloadGrantsRequestSaga } from "./downloadGrants";
16
16
  import { downloadEditableStructuresRequestSaga } from "./downloadEditableStructures";
17
+ import { downloadGrantsRequestSaga } from "./downloadGrants";
18
+ import { downloadReferenceDatasetRequestSaga } from "./downloadReferenceDataset";
17
19
  import { downloadStructuresRequestSaga } from "./downloadStructures";
18
20
  import { fetchGrantFiltersRequestSaga } from "./fetchGrantFilters";
19
- import { fetchGrantsRequestSaga } from "./fetchGrants";
20
21
  import { fetchGrantRequestRequestSaga } from "./fetchGrantRequest";
21
22
  import { fetchGrantRequestsRequestSaga } from "./fetchGrantRequests";
23
+ import { fetchGrantsRequestSaga } from "./fetchGrants";
22
24
  import { fetchGraphRequestSaga } from "./fetchGraph";
23
25
  import { fetchLineageEventsRequestSaga } from "./fetchLineageEvents";
24
26
  import { fetchLinksStructureTagsRequestSaga } from "./fetchLinksStructureTags";
@@ -31,45 +33,48 @@ import { fetchStructureNotesRequestSaga } from "./fetchStructureNotes";
31
33
  import { fetchStructureRequestSaga } from "./fetchStructure";
32
34
  import { fetchStructureTypeRequestSaga } from "./fetchStructureType";
33
35
  import { fetchStructureTypesRequestSaga } from "./fetchStructureTypes";
34
- import { fetchUserSearchFiltersRequestSaga } from "./fetchUserSearchFilters";
35
36
  import { fetchStructuresRequestSaga } from "./fetchStructures";
36
37
  import { fetchStructuresUploadEventsRequestSaga } from "./fetchStructuresUploadEvents";
37
38
  import { fetchSystemRequestSaga } from "./fetchSystem";
38
39
  import { fetchSystemStructuresRequestSaga } from "./fetchSystemStructures";
39
40
  import { fetchSystemsRequestSaga } from "./fetchSystems";
40
41
  import { fetchUnitDomainsRequestSaga } from "./fetchUnitDomains";
42
+ import { fetchUserSearchFiltersRequestSaga } from "./fetchUserSearchFilters";
41
43
  import { linkStructureTagRequestSaga } from "./linkStructureTag";
44
+ import { operateGrantRequestToCartRequestSaga } from "./operateGrantRequestCart";
42
45
  import { saveUserSearchFiltersRequestSaga } from "./saveUserSearchFilters";
46
+ import { updateReferenceDatasetRequestSaga } from "./updateReferenceDataset";
43
47
  import { updateStructureRequestSaga } from "./updateStructure";
44
48
  import { updateStructureTagRequestSaga } from "./updateStructureTag";
45
49
  import { updateStructureTypeRequestSaga } from "./updateStructureType";
46
50
  import { updateSystemRequestSaga } from "./updateSystem";
47
- import { uploadStructuresRequestSaga } from "./uploadStructures";
48
51
  import { uploadStructuresDomainsRequestSaga } from "./uploadStructuresDomains";
49
- import { operateGrantRequestToCartRequestSaga } from "./operateGrantRequestCart";
52
+ import { uploadStructuresRequestSaga } from "./uploadStructures";
50
53
 
51
54
  export {
52
55
  bulkUpdateStructuresRequestsSaga,
53
- //cancelPollRequestSaga,
54
56
  createGrantRequestApprovalRequestSaga,
55
57
  createGraphRequestSaga,
56
58
  createProfileGroupRequestSaga,
59
+ createReferenceDatasetRequestSaga,
57
60
  createStructureGraphRequestSaga,
58
61
  createStructureTagRequestSaga,
59
- deleteStructureRequestSaga,
60
62
  createSystemRequestSaga,
61
63
  deleteLinkStructureTagRequestSaga,
64
+ deleteReferenceDatasetRequestSaga,
65
+ deleteStructureRequestSaga,
62
66
  deleteStructureTagRequestSaga,
63
67
  deleteUserSearchFilterRequestSaga,
64
68
  doStructureNoteActionRequestSaga,
65
69
  downloadCsvGraphRequestSaga,
66
- downloadGrantsRequestSaga,
67
70
  downloadEditableStructuresRequestSaga,
71
+ downloadGrantsRequestSaga,
72
+ downloadReferenceDatasetRequestSaga,
68
73
  downloadStructuresRequestSaga,
69
74
  fetchGrantFiltersRequestSaga,
70
- fetchGrantsRequestSaga,
71
75
  fetchGrantRequestRequestSaga,
72
76
  fetchGrantRequestsRequestSaga,
77
+ fetchGrantsRequestSaga,
73
78
  fetchGraphRequestSaga,
74
79
  fetchLineageEventsRequestSaga,
75
80
  fetchLinksStructureTagsRequestSaga,
@@ -82,46 +87,49 @@ export {
82
87
  fetchStructureRequestSaga,
83
88
  fetchStructureTypeRequestSaga,
84
89
  fetchStructureTypesRequestSaga,
85
- fetchStructuresUploadEventsRequestSaga,
86
- fetchUserSearchFiltersRequestSaga,
87
90
  fetchStructuresRequestSaga,
91
+ fetchStructuresUploadEventsRequestSaga,
88
92
  fetchSystemRequestSaga,
89
93
  fetchSystemStructuresRequestSaga,
90
94
  fetchSystemsRequestSaga,
91
95
  fetchUnitDomainsRequestSaga,
96
+ fetchUserSearchFiltersRequestSaga,
92
97
  linkStructureTagRequestSaga,
98
+ operateGrantRequestToCartRequestSaga,
93
99
  saveUserSearchFiltersRequestSaga,
100
+ updateReferenceDatasetRequestSaga,
94
101
  updateStructureRequestSaga,
95
102
  updateStructureTagRequestSaga,
96
103
  updateStructureTypeRequestSaga,
97
104
  updateSystemRequestSaga,
98
- uploadStructuresRequestSaga,
99
105
  uploadStructuresDomainsRequestSaga,
100
- operateGrantRequestToCartRequestSaga,
106
+ uploadStructuresRequestSaga,
101
107
  };
102
108
 
103
109
  export default [
104
110
  bulkUpdateStructuresRequestsSaga(),
105
- //cancelPollRequestSaga(),
106
111
  createGrantRequestApprovalRequestSaga(),
107
112
  createGraphRequestSaga(),
108
113
  createProfileGroupRequestSaga(),
114
+ createReferenceDatasetRequestSaga(),
109
115
  createStructureGraphRequestSaga(),
110
116
  createStructureTagRequestSaga(),
111
- deleteStructureRequestSaga(),
112
117
  createSystemRequestSaga(),
113
118
  deleteLinkStructureTagRequestSaga(),
119
+ deleteReferenceDatasetRequestSaga(),
120
+ deleteStructureRequestSaga(),
114
121
  deleteStructureTagRequestSaga(),
115
122
  deleteUserSearchFilterRequestSaga(),
116
123
  doStructureNoteActionRequestSaga(),
117
124
  downloadCsvGraphRequestSaga(),
118
- downloadGrantsRequestSaga(),
119
125
  downloadEditableStructuresRequestSaga(),
126
+ downloadGrantsRequestSaga(),
127
+ downloadReferenceDatasetRequestSaga(),
120
128
  downloadStructuresRequestSaga(),
121
129
  fetchGrantFiltersRequestSaga(),
122
- fetchGrantsRequestSaga(),
123
130
  fetchGrantRequestRequestSaga(),
124
131
  fetchGrantRequestsRequestSaga(),
132
+ fetchGrantsRequestSaga(),
125
133
  fetchGraphRequestSaga(),
126
134
  fetchLineageEventsRequestSaga(),
127
135
  fetchLinksStructureTagsRequestSaga(),
@@ -134,20 +142,21 @@ export default [
134
142
  fetchStructureRequestSaga(),
135
143
  fetchStructureTypeRequestSaga(),
136
144
  fetchStructureTypesRequestSaga(),
137
- fetchUserSearchFiltersRequestSaga(),
138
145
  fetchStructuresRequestSaga(),
139
146
  fetchStructuresUploadEventsRequestSaga(),
140
147
  fetchSystemRequestSaga(),
141
148
  fetchSystemStructuresRequestSaga(),
142
149
  fetchSystemsRequestSaga(),
143
150
  fetchUnitDomainsRequestSaga(),
151
+ fetchUserSearchFiltersRequestSaga(),
144
152
  linkStructureTagRequestSaga(),
153
+ operateGrantRequestToCartRequestSaga(),
145
154
  saveUserSearchFiltersRequestSaga(),
155
+ updateReferenceDatasetRequestSaga(),
146
156
  updateStructureRequestSaga(),
147
157
  updateStructureTagRequestSaga(),
148
158
  updateStructureTypeRequestSaga(),
149
159
  updateSystemRequestSaga(),
150
- uploadStructuresRequestSaga(),
151
160
  uploadStructuresDomainsRequestSaga(),
152
- operateGrantRequestToCartRequestSaga(),
161
+ uploadStructuresRequestSaga(),
153
162
  ];
@@ -0,0 +1,35 @@
1
+ import { call, put, takeLatest, getContext } from "redux-saga/effects";
2
+ import { toBase64 } from "@truedat/core/services/file";
3
+ import { UPDATE_REFERENCE_DATASET } from "../api/mutations";
4
+ import { updateReferenceDataset } from "../routines";
5
+
6
+ export const onSuccess = (cache, { data: { updateReferenceDataset } }) => {
7
+ cache.evict({ id: "ROOT_QUERY", fieldName: "referenceDatasets" });
8
+ cache.evict({ id: cache.identify(updateReferenceDataset) });
9
+ cache.gc();
10
+ };
11
+
12
+ export function* updateReferenceDatasetSaga({
13
+ payload: { file, ...rest } = {},
14
+ }) {
15
+ const client = yield getContext("client");
16
+ try {
17
+ const dataUrl = file ? yield call(toBase64, file) : null;
18
+ const dataset = dataUrl ? { ...rest, data: dataUrl } : rest;
19
+ yield put(updateReferenceDataset.request(dataset));
20
+ const { data } = yield call(client.mutate, {
21
+ mutation: UPDATE_REFERENCE_DATASET,
22
+ update: onSuccess,
23
+ variables: { dataset },
24
+ });
25
+ yield put(updateReferenceDataset.success(data));
26
+ } catch (error) {
27
+ yield put(updateReferenceDataset.failure(error.message));
28
+ } finally {
29
+ yield put(updateReferenceDataset.fulfill());
30
+ }
31
+ }
32
+
33
+ export function* updateReferenceDatasetRequestSaga() {
34
+ yield takeLatest(updateReferenceDataset.TRIGGER, updateReferenceDatasetSaga);
35
+ }
@@ -1,11 +1,9 @@
1
1
  import _ from "lodash/fp";
2
2
  import { createSelector } from "reselect";
3
- import { lowerDeburr } from "@truedat/core/services/sort";
3
+ import { lowerDeburrPath } from "@truedat/core/services/sort";
4
4
 
5
- const lowerDeburrPath = (field, key) => _.flow(_.path(key), lowerDeburr)(field);
6
-
7
- const nameCriteria = field => lowerDeburrPath(field, "structure.name");
8
- const typeCriteria = field => lowerDeburrPath(field, "relation_type.name");
5
+ const nameCriteria = lowerDeburrPath("structure.name");
6
+ const typeCriteria = lowerDeburrPath("relation_type.name");
9
7
 
10
8
  const defaultRelationSortingCriteria = [typeCriteria, nameCriteria];
11
9
 
@@ -42,10 +42,7 @@ const impactTabVisible = _.anyPass([_.path("structure.degree.out")]);
42
42
  const parentsTabVisible = _.conformsTo({ parentRelations: notEmpty });
43
43
  const childrenTabVisible = _.conformsTo({ childrenRelations: notEmpty });
44
44
  const eventsTabVisible = _.flow(_.prop("structureVersion"), _.isEmpty);
45
- const grantsTabVisible = _.flow(
46
- _.path("structure.grants"),
47
- _.negate(_.isEmpty)
48
- );
45
+ const grantsTabVisible = _.flow(_.path("structure.grants"), notEmpty);
49
46
 
50
47
  export const getTabVisibility = (state) => ({
51
48
  fields: fieldsTabVisible(state),
@@ -1,89 +0,0 @@
1
- import _ from "lodash/fp";
2
- import React, { useState } from "react";
3
- import PropTypes from "prop-types";
4
- import { connect } from "react-redux";
5
- import { Button, Icon, Grid } from "semantic-ui-react";
6
- import { FormattedMessage } from "react-intl";
7
- import ProfilingGraph from "./ProfilingGraph";
8
- import ProfilingPatterns from "./ProfilingPatterns";
9
-
10
- export const ProfilingElements = ({ profile }) => {
11
- const { most_frequent, patterns } = profile || {};
12
- const [elementActive, setElementActive] = useState("graph");
13
- const titleElement =
14
- elementActive === "graph"
15
- ? "structure.field.graph.title"
16
- : "structure.field.patterns.title";
17
- return (
18
- <>
19
- {!_.isEmpty(most_frequent) && !_.isEmpty(patterns) && (
20
- <>
21
- <Grid>
22
- <Grid.Column width={8}>
23
- <p>
24
- <FormattedMessage id={titleElement} />:
25
- </p>
26
- </Grid.Column>
27
- <Grid.Column width={8} textAlign="right">
28
- <Button.Group floated="right">
29
- <Button
30
- active={elementActive === "graph"}
31
- icon
32
- onClick={() => setElementActive("graph")}
33
- >
34
- <Icon name="chart line" />
35
- </Button>
36
- <Button
37
- active={elementActive === "patterns"}
38
- icon
39
- onClick={() => setElementActive("patterns")}
40
- >
41
- <Icon name="list ul" />
42
- </Button>
43
- </Button.Group>
44
- </Grid.Column>
45
- </Grid>
46
-
47
- {elementActive === "graph" && <ProfilingGraph />}
48
- {elementActive === "patterns" && <ProfilingPatterns />}
49
- </>
50
- )}
51
-
52
- {!_.isEmpty(most_frequent) && _.isEmpty(patterns) && (
53
- <>
54
- <Grid>
55
- <Grid.Column width={16}>
56
- <p>
57
- <FormattedMessage id="structure.field.graph.title" />:
58
- </p>
59
- </Grid.Column>
60
- </Grid>
61
-
62
- <ProfilingGraph />
63
- </>
64
- )}
65
-
66
- {_.isEmpty(most_frequent) && !_.isEmpty(patterns) && (
67
- <>
68
- <Grid>
69
- <Grid.Column width={16}>
70
- <p>
71
- <FormattedMessage id="structure.field.patterns.title" />
72
- </p>
73
- </Grid.Column>
74
- </Grid>
75
-
76
- <ProfilingPatterns />
77
- </>
78
- )}
79
- </>
80
- );
81
- };
82
-
83
- ProfilingElements.propTypes = {
84
- profile: PropTypes.object,
85
- };
86
-
87
- const mapStateToProps = ({ structureProfile: profile }) => ({ profile });
88
-
89
- export default connect(mapStateToProps)(ProfilingElements);