@truedat/dd 4.43.1 → 4.43.4

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 (35) hide show
  1. package/CHANGELOG.md +14 -2
  2. package/package.json +7 -7
  3. package/src/api.js +3 -0
  4. package/src/components/DictionaryRoutes.js +10 -0
  5. package/src/components/GrantRequestApprovalForm.js +10 -4
  6. package/src/components/LinkStructureTagForm.js +21 -15
  7. package/src/components/MetadataFiltersInput.js +1 -1
  8. package/src/components/MetadataViewForm.js +2 -2
  9. package/src/components/MyGrantRequests.js +1 -1
  10. package/src/components/PendingStructureNotes.js +3 -3
  11. package/src/components/StructureTagForm.js +5 -2
  12. package/src/components/StructureTypeForm.js +2 -2
  13. package/src/components/StructuresUploadEvents.js +38 -0
  14. package/src/components/StructuresUploadEventsTable.js +183 -0
  15. package/src/components/__tests__/StructuresUploadEventsTable.spec.js +84 -0
  16. package/src/components/__tests__/__snapshots__/DictionaryRoutes.spec.js.snap +4 -0
  17. package/src/components/__tests__/__snapshots__/StructuresUploadEventsTable.spec.js.snap +130 -0
  18. package/src/messages/en.js +17 -0
  19. package/src/messages/es.js +18 -0
  20. package/src/reducers/__tests__/structuresUploadEvents.spec.js +46 -0
  21. package/src/reducers/__tests__/structuresUploadEventsLoading.spec.js +26 -0
  22. package/src/reducers/ddMessage.js +54 -30
  23. package/src/reducers/index.js +4 -0
  24. package/src/reducers/structuresUploadEvents.js +16 -0
  25. package/src/reducers/structuresUploadEventsLoading.js +16 -0
  26. package/src/routines.js +1 -0
  27. package/src/sagas/__tests__/fetchStructuresUploadEvents.spec.js +79 -0
  28. package/src/sagas/__tests__/uploadStructures.spec.js +3 -2
  29. package/src/sagas/fetchStructuresUploadEvents.js +29 -0
  30. package/src/sagas/index.js +3 -0
  31. package/src/sagas/uploadStructures.js +2 -2
  32. package/src/selectors/__tests__/getStructuresUploadEventColumns.spec.js +20 -0
  33. package/src/selectors/getStructuresUploadEventColumns.js +74 -0
  34. package/src/selectors/index.js +4 -0
  35. package/src/styles/structuresUploadEventColumns.less +24 -0
@@ -21,6 +21,10 @@ exports[`<DictionaryRoutes /> matches the latest snapshot 1`] = `
21
21
  path="/structure_types"
22
22
  render={[Function]}
23
23
  />
24
+ <Route
25
+ path="/bulk_update_template_content_events"
26
+ render={[Function]}
27
+ />
24
28
  <Route
25
29
  path="/structure_notes"
26
30
  render={[Function]}
@@ -0,0 +1,130 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`<StructuresUploadEventsTable /> matches the latest snapshot 1`] = `
4
+ <div>
5
+ <table
6
+ class="ui selectable sortable table"
7
+ >
8
+ <thead
9
+ class=""
10
+ >
11
+ <tr
12
+ class=""
13
+ >
14
+ <th
15
+ class="two wide"
16
+ >
17
+ CSV hash
18
+ </th>
19
+ <th
20
+ class="two wide"
21
+ >
22
+ Status
23
+ </th>
24
+ <th
25
+ class="two wide"
26
+ >
27
+ Response
28
+ </th>
29
+ <th
30
+ class="two wide"
31
+ >
32
+ Date
33
+ </th>
34
+ </tr>
35
+ </thead>
36
+ <tbody
37
+ class=""
38
+ >
39
+ <tr
40
+ class="contracted"
41
+ >
42
+ <td
43
+ class=""
44
+ >
45
+ 99E400B91D164F8F0A39F400CA323C8F
46
+ </td>
47
+ <td
48
+ class=""
49
+ >
50
+ Completed
51
+ </td>
52
+ <td
53
+ class=""
54
+ >
55
+ <p>
56
+ Bulk update completed. Loaded 3 errors 0
57
+ </p>
58
+ <ul
59
+ class="csv-bulk-upload-error"
60
+ />
61
+ </td>
62
+ <td
63
+ class="center aligned"
64
+ >
65
+ <time
66
+ datetime="1650729204638"
67
+ >
68
+ 2022-04-23 15:53
69
+ </time>
70
+ </td>
71
+ </tr>
72
+ <tr
73
+ class="contracted"
74
+ >
75
+ <td
76
+ class=""
77
+ >
78
+ 47D90FDF1AD967BD7DBBDAE28664278E
79
+ </td>
80
+ <td
81
+ class=""
82
+ >
83
+ Completed
84
+ </td>
85
+ <td
86
+ class=""
87
+ >
88
+ <p>
89
+ Bulk update completed. Loaded 0 errors 3
90
+ </p>
91
+ <ul
92
+ class="csv-bulk-upload-error"
93
+ >
94
+ <li>
95
+ External id: file://corporate-landing-s3/cep-pro-ld-cor/batch/SAP/FSCM/vendor_issue/SAP_FSCM_CM_VENDOR_ISUE/ZFSCM_AC The field &lt;gdpr&gt; does not have a permitted value
96
+ </li>
97
+ <li>
98
+ External id: file://corporate-landing-s3/cep-pro-ld-cor/batch/SAP/FSCM/vendor_issue/SAP_FSCM_CM_VENDOR_ISUE/ZFSCM_FN The field &lt;business_description&gt; is required
99
+ </li>
100
+ <li>
101
+ External id: file://corporate-landing-s3/cep-pro-ld-cor/batch/SAP/FSCM/vendor_issue/SAP_FSCM_CM_VENDOR_ISUE/ZFSCM_PC The field &lt;business_description&gt; is required
102
+ </li>
103
+ </ul>
104
+ <a
105
+ class="alert-exporter-in-table"
106
+ download="errors.csv"
107
+ href="data:text/csv;charset=utf-8,\\"RENDEREDMESSAGE\\",\\"EXTERNAL_ID\\",\\"FIELD\\",\\"MESSAGE\\",\\"ROW\\"
108
+ \\"External id: file://corporate-landing-s3/cep-pro-ld-cor/batch/SAP/FSCM/vendor_issue/SAP_FSCM_CM_VENDOR_ISUE/ZFSCM_AC The field <gdpr> does not have a permitted value\\",\\"file://corporate-landing-s3/cep-pro-ld-cor/batch/SAP/FSCM/vendor_issue/SAP_FSCM_CM_VENDOR_ISUE/ZFSCM_AC\\",\\"gdpr\\",\\"df_content.inclusion\\",\\"4\\"
109
+ \\"External id: file://corporate-landing-s3/cep-pro-ld-cor/batch/SAP/FSCM/vendor_issue/SAP_FSCM_CM_VENDOR_ISUE/ZFSCM_FN The field <business_description> is required\\",\\"file://corporate-landing-s3/cep-pro-ld-cor/batch/SAP/FSCM/vendor_issue/SAP_FSCM_CM_VENDOR_ISUE/ZFSCM_FN\\",\\"business_description\\",\\"df_content.required\\",\\"2\\"
110
+ \\"External id: file://corporate-landing-s3/cep-pro-ld-cor/batch/SAP/FSCM/vendor_issue/SAP_FSCM_CM_VENDOR_ISUE/ZFSCM_PC The field <business_description> is required\\",\\"file://corporate-landing-s3/cep-pro-ld-cor/batch/SAP/FSCM/vendor_issue/SAP_FSCM_CM_VENDOR_ISUE/ZFSCM_PC\\",\\"business_description\\",\\"df_content.required\\",\\"3\\""
111
+ style="float: right;"
112
+ target="_self"
113
+ >
114
+ Export to CSV
115
+ </a>
116
+ </td>
117
+ <td
118
+ class="center aligned"
119
+ >
120
+ <time
121
+ datetime="1650726888770"
122
+ >
123
+ 2022-04-23 15:14
124
+ </time>
125
+ </td>
126
+ </tr>
127
+ </tbody>
128
+ </table>
129
+ </div>
130
+ `;
@@ -395,8 +395,25 @@ export default {
395
395
  "structures.bulkUpdateStructures.no.structures.header": "Empty Search",
396
396
  "structures.bulkUpdateStructures.success.header":
397
397
  "Bulk update completed. Loaded {count_ids} errors {count_errors}",
398
+ "structures.bulkUpdateStructures.success.accepted.header":
399
+ "Bulk update accepted (status: {status}): CSV hash: {csv_hash}, task reference: {task_reference}",
398
400
  "structures.bulkUpdateStructures.success.errors":
399
401
  "Error in external id {externalId}, message: {message}",
402
+ "structures.bulkUploadEvents.header": "Notes upload events",
403
+ "structures.bulkUploadEvents.subheader": "Structures notes CSV upload events",
404
+ "structures.bulkUploadEvents.props.csv_hash": "CSV hash",
405
+ "structures.bulkUploadEvents.props.status": "Status",
406
+ "structures.bulkUploadEvents.props.response": "Response",
407
+ "structures.bulkUploadEvents.props.message": "Message",
408
+ "structures.bulkUploadEvents.props.inserted_at": "Date",
409
+ "structures.bulkUploadEvents.results.empty": "No structure notes CSV bulk upload events found",
410
+ "structures.bulkUploadEvents.status.already_calculated": "Already calculated",
411
+ "structures.bulkUploadEvents.status.already_started": "Already started",
412
+ "structures.bulkUploadEvents.status.completed": "Completed",
413
+ "structures.bulkUploadEvents.status.failed": "Failed",
414
+ "structures.bulkUploadEvents.status.just_started": "Just started",
415
+ "structures.bulkUploadEvents.status.started": "Started",
416
+ "structures.bulkUploadEvents.status.timed_out": "Timed out",
400
417
  "structures.bulkUploadStructuresDomains.success.errors.domain: not_exist":
401
418
  "Error in line {row}, in external id {externalId}, domain does not exist",
402
419
  "structures.bulkUploadStructuresDomains.success.errors.update_domain: forbbiden":
@@ -401,8 +401,26 @@ export default {
401
401
  "structures.bulkUpdateStructures.no.structures.header": "Búsqueda vacía",
402
402
  "structures.bulkUpdateStructures.success.header":
403
403
  "¡Actualización finalizada! subidos {count_ids} errores {count_errors}",
404
+ "structures.bulkUpdateStructures.success.accepted.header":
405
+ "CSV aceptado (estado: {status}): Hash del fichero: {csv_hash}, referencia de task: {task_reference}",
404
406
  "structures.bulkUpdateStructures.success.errors":
405
407
  "Error en external id {externalId}, mensaje: {message}",
408
+ "structures.bulkUploadEvents.header": "Eventos de subida de notas",
409
+ "structures.bulkUploadEvents.subheader": "Eventos de subida de notas de estructuras por CSV",
410
+ "structures.bulkUploadEvents.props.csv_hash": "Hash de CSV",
411
+ "structures.bulkUploadEvents.props.status": "Estado",
412
+ "structures.bulkUploadEvents.props.response": "Respuesta",
413
+ "structures.bulkUploadEvents.props.message": "Mensaje",
414
+ "structures.bulkUploadEvents.props.inserted_at": "Fecha",
415
+ "structures.bulkUploadEvents.results.empty": "Ningún evento de subida de notas por CSV encontrado",
416
+ "structures.bulkUploadEvents.status.already_calculated": "Previamente calculado",
417
+ "structures.bulkUploadEvents.status.already_started": "Previamente iniciado",
418
+ "structures.bulkUploadEvents.status.completed": "Finalizado",
419
+ "structures.bulkUploadEvents.status.failed": "Fallido",
420
+ "structures.bulkUploadEvents.status.just_started": "Acaba de iniciarse",
421
+ "structures.bulkUploadEvents.status.started": "Iniciado",
422
+ "structures.bulkUploadEvents.status.timed_out":
423
+ "Tiempo de espera máximo sobrepasado",
406
424
  "structures.bulkUploadStructuresDomains.success.errors.domain: not_exist":
407
425
  "Error en linea {row}, en external id {externalId}, el dominio no existe",
408
426
  "structures.bulkUploadStructuresDomains.success.errors.structure: not_exist":
@@ -0,0 +1,46 @@
1
+ import { fetchStructuresUploadEvents } from "../../routines";
2
+ import { structuresUploadEvents } from "..";
3
+
4
+ const fooState = { foo: "bar" };
5
+
6
+ describe("reducers: structuresUploadEvents", () => {
7
+ const initialState = [];
8
+
9
+ it("should provide the initial state", () => {
10
+ expect(structuresUploadEvents(undefined, {})).toEqual(initialState);
11
+ });
12
+
13
+ it("should handle the fetchStructuresUploadEvents.SUCCESS action", () => {
14
+ const someEvents = [
15
+ {
16
+ csv_hash: "99E400B91D164F8F0A39F400CA323C8F",
17
+ inserted_at: "2022-04-23T15:53:24.638484Z",
18
+ message: null,
19
+ response: {},
20
+ status: "COMPLETED",
21
+ task_reference: "0.3225053307.1609564164.100549",
22
+ user_id: 467,
23
+ },
24
+ {
25
+ csv_hash: "47D90FDF1AD967BD7DBBDAE28664278E",
26
+ inserted_at: "2022-04-23T15:14:48.770275Z",
27
+ message: null,
28
+ response: {},
29
+ status: "COMPLETED",
30
+ task_reference: "0.3225053307.1609564162.101463",
31
+ user_id: 467,
32
+ },
33
+ ];
34
+
35
+ expect(
36
+ structuresUploadEvents(fooState, {
37
+ type: fetchStructuresUploadEvents.SUCCESS,
38
+ payload: someEvents,
39
+ })
40
+ ).toMatchObject(someEvents);
41
+ });
42
+
43
+ it("should ignore unknown actions", () => {
44
+ expect(structuresUploadEvents(fooState, { type: "FOO" })).toBe(fooState);
45
+ });
46
+ });
@@ -0,0 +1,26 @@
1
+ import { fetchStructuresUploadEvents } from "../../routines";
2
+ import { structuresUploadEventsLoading } from "..";
3
+
4
+ const fooState = { foo: "bar" };
5
+
6
+ describe("reducers: structuresUploadEventsLoading", () => {
7
+ it("should provide the initial state", () => {
8
+ expect(structuresUploadEventsLoading(undefined, {})).toBe(false);
9
+ });
10
+
11
+ it("should be true after receiving the fetchStructuresUploadEvents.REQUEST action", () => {
12
+ expect(structuresUploadEventsLoading(fooState, { type: fetchStructuresUploadEvents.REQUEST })).toBe(true);
13
+ });
14
+
15
+ it("should be false after receiving the fetchStructuresUploadEvents.SUCCESS action", () => {
16
+ expect(structuresUploadEventsLoading(fooState, { type: fetchStructuresUploadEvents.SUCCESS })).toBe(false);
17
+ });
18
+
19
+ it("should be false after receiving the fetchStructuresUploadEvents.FAILURE action", () => {
20
+ expect(structuresUploadEventsLoading(fooState, { type: fetchStructuresUploadEvents.FAILURE })).toBe(false);
21
+ });
22
+
23
+ it("should ignore unhandled actions", () => {
24
+ expect(structuresUploadEventsLoading(fooState, { type: "FOO" })).toBe(fooState);
25
+ });
26
+ });
@@ -9,42 +9,66 @@ import {
9
9
 
10
10
  const initialState = null;
11
11
 
12
+ const bulkUpdateErrors = (payload) => {
13
+ const messagesImp = _.has("errors")(payload.data)
14
+ ? _.flow(
15
+ _.propOr([], "errors"),
16
+ _.map((error) => ({
17
+ id: `structures.bulkUpdateStructures.failed.note.${error.message}`,
18
+ fields: {
19
+ row: error.row,
20
+ id: error.id,
21
+ field: error.field,
22
+ externalId: error.external_id,
23
+ message: error.message,
24
+ },
25
+ defaultMessage: "structures.bulkUploadStructures.success.errors",
26
+ }))
27
+ )(payload.data)
28
+ : "";
29
+ return {
30
+ error: false,
31
+ header: "structures.bulkUpdateStructures.success.header",
32
+ icon: "check",
33
+ color: payload.data.errors.length >= 1 ? "orange" : "green",
34
+ text: "",
35
+ messages: messagesImp,
36
+ fields: {
37
+ count_ids: payload.data.ids.length,
38
+ count_errors: payload.data.errors.length,
39
+ },
40
+ downloadable: true,
41
+ initialMaxListItems: 5,
42
+ };
43
+ };
44
+
45
+ const bulkUpdateAccepted = ({ csv_hash, status, task_reference }) => {
46
+ return {
47
+ error: false,
48
+ header: "structures.bulkUpdateStructures.success.accepted.header",
49
+ icon: "check",
50
+ color: "blue",
51
+ text: "",
52
+ fields: { csv_hash, status, task_reference },
53
+ };
54
+ };
55
+
12
56
  const ddMessage = (state = initialState, { type, payload }) => {
57
+
13
58
  switch (type) {
14
59
  case dismissAlert.TRIGGER:
15
60
  return initialState;
16
61
  case uploadStructures.SUCCESS:
17
62
  case bulkUpdateStructures.SUCCESS: {
18
- const messagesImp = _.has("errors")(payload.data)
19
- ? _.flow(
20
- _.propOr([], "errors"),
21
- _.map((error) => ({
22
- id: `structures.bulkUpdateStructures.failed.note.${error.message}`,
23
- fields: {
24
- row: error.row,
25
- id: error.id,
26
- field: error.field,
27
- externalId: error.external_id,
28
- message: error.message,
29
- },
30
- defaultMessage: "structures.bulkUploadStructures.success.errors",
31
- }))
32
- )(payload.data)
33
- : "";
34
- return {
35
- error: false,
36
- header: "structures.bulkUpdateStructures.success.header",
37
- icon: "check",
38
- color: payload.data.errors.length >= 1 ? "orange" : "green",
39
- text: "",
40
- messages: messagesImp,
41
- fields: {
42
- count_ids: payload.data.ids.length,
43
- count_errors: payload.data.errors.length,
44
- },
45
- downloadable: true,
46
- initialMaxListItems: 5,
47
- };
63
+
64
+
65
+ if (payload.status === 202) {
66
+ return bulkUpdateAccepted(payload.data)
67
+ } else if (payload.status === 200) {
68
+ return bulkUpdateErrors(payload)
69
+ }
70
+
71
+
48
72
  }
49
73
 
50
74
  case uploadStructuresDomains.SUCCESS: {
@@ -83,6 +83,8 @@ import { structuresEditableDownloading } from "./structuresEditableDownloading";
83
83
  import { structuresLoading } from "./structuresLoading";
84
84
  import { structuresPageSize } from "./structuresPageSize";
85
85
  import { structuresSiblings } from "./structureSiblings";
86
+ import { structuresUploadEvents } from "./structuresUploadEvents";
87
+ import { structuresUploadEventsLoading } from "./structuresUploadEventsLoading";
86
88
  import { system } from "./system";
87
89
  import { systemId } from "./systemId";
88
90
  import { systemStructures } from "./systemStructures";
@@ -183,6 +185,8 @@ export {
183
185
  structuresLoading,
184
186
  structuresPageSize,
185
187
  structuresSiblings,
188
+ structuresUploadEvents,
189
+ structuresUploadEventsLoading,
186
190
  system,
187
191
  systemId,
188
192
  systemStructures,
@@ -0,0 +1,16 @@
1
+ import _ from "lodash/fp";
2
+ import { fetchStructuresUploadEvents } from "../routines";
3
+
4
+ export const initialState = [];
5
+
6
+ export const structuresUploadEvents = (
7
+ state = initialState,
8
+ { type, payload }
9
+ ) => {
10
+ switch (type) {
11
+ case fetchStructuresUploadEvents.SUCCESS:
12
+ return payload;
13
+ default:
14
+ return state;
15
+ }
16
+ };
@@ -0,0 +1,16 @@
1
+ import { fetchStructuresUploadEvents } from "../routines";
2
+
3
+ const structuresUploadEventsLoading = (state = false, { type }) => {
4
+ switch (type) {
5
+ case fetchStructuresUploadEvents.REQUEST:
6
+ return true;
7
+ case fetchStructuresUploadEvents.SUCCESS:
8
+ return false;
9
+ case fetchStructuresUploadEvents.FAILURE:
10
+ return false;
11
+ default:
12
+ return state;
13
+ }
14
+ };
15
+
16
+ export { structuresUploadEventsLoading };
package/src/routines.js CHANGED
@@ -86,6 +86,7 @@ export const fetchUserSearchFilters = createRoutine(
86
86
  "FETCH_USER_SEARCH_FILTERS"
87
87
  );
88
88
  export const fetchStructures = createRoutine("FETCH_STRUCTURES");
89
+ export const fetchStructuresUploadEvents = createRoutine("FETCH_STRUCTURES_UPLOAD_EVENTS");
89
90
  export const fetchSystem = createRoutine("FETCH_SYSTEM");
90
91
  export const fetchSystemStructures = createRoutine("FETCH_SYSTEM_STRUCTURES");
91
92
  export const fetchSystems = createRoutine("FETCH_SYSTEMS");
@@ -0,0 +1,79 @@
1
+ import { testSaga } from "redux-saga-test-plan";
2
+ import { apiJson, JSON_OPTS } from "@truedat/core/services/api";
3
+ import {
4
+ fetchStructuresUploadEventsRequestSaga,
5
+ fetchStructuresUploadEventsSaga,
6
+ } from "../fetchStructuresUploadEvents";
7
+ import { fetchStructuresUploadEvents } from "../../routines";
8
+ import { API_STRUCTURES_UPLOAD_EVENTS } from "../../api";
9
+
10
+ describe("sagas: fetchStructuresUploadEventsRequestSaga", () => {
11
+ it("should invoke fetchStructuresUploadEventsSaga on trigger", () => {
12
+ expect(() => {
13
+ testSaga(fetchStructuresUploadEventsRequestSaga)
14
+ .next()
15
+ .takeLatest(
16
+ fetchStructuresUploadEvents.TRIGGER,
17
+ fetchStructuresUploadEventsSaga
18
+ )
19
+ .finish()
20
+ .isDone();
21
+ }).not.toThrow();
22
+ });
23
+
24
+ it("should throw exception if an unhandled action is received", () => {
25
+ expect(() => {
26
+ testSaga(fetchStructuresUploadEventsRequestSaga)
27
+ .next()
28
+ .takeLatest("FOO", fetchStructuresUploadEventsSaga);
29
+ }).toThrow();
30
+ });
31
+ });
32
+
33
+ describe("sagas: fetchStructuresUploadEventsSaga", () => {
34
+ it("should put a success action when a response is returned", () => {
35
+ const url = API_STRUCTURES_UPLOAD_EVENTS;
36
+ const data = [
37
+ {
38
+ csv_hash: "99E400B91D164F8F0A39F400CA323C8F",
39
+ },
40
+ {
41
+ csv_hash: "47D90FDF1AD967BD7DBBDAE28664278E",
42
+ },
43
+ ];
44
+
45
+ expect(() => {
46
+ testSaga(fetchStructuresUploadEventsSaga)
47
+ .next()
48
+ .put(fetchStructuresUploadEvents.request())
49
+ .next()
50
+ .call(apiJson, url, JSON_OPTS)
51
+ .next({ data })
52
+ .put(fetchStructuresUploadEvents.success(data))
53
+ .next()
54
+ .put(fetchStructuresUploadEvents.fulfill())
55
+ .next()
56
+ .isDone();
57
+ }).not.toThrow();
58
+ });
59
+
60
+ it("should put a failure action when the call returns an error", () => {
61
+ const message = "Request failed";
62
+ const error = { message };
63
+ const url = API_STRUCTURES_UPLOAD_EVENTS;
64
+
65
+ expect(() => {
66
+ testSaga(fetchStructuresUploadEventsSaga)
67
+ .next()
68
+ .put(fetchStructuresUploadEvents.request())
69
+ .next()
70
+ .call(apiJson, url, JSON_OPTS)
71
+ .throw(error)
72
+ .put(fetchStructuresUploadEvents.failure(message))
73
+ .next()
74
+ .put(fetchStructuresUploadEvents.fulfill())
75
+ .next()
76
+ .isDone();
77
+ }).not.toThrow();
78
+ });
79
+ });
@@ -30,6 +30,7 @@ describe("sagas: uploadStructuresRequestSaga", () => {
30
30
  describe("sagas: uploadStructuresSaga", () => {
31
31
  const body = { structures: "content" };
32
32
  const payload = { data: body };
33
+ const status = "JUST_STARTED";
33
34
  const data = { message: [1, 2] };
34
35
  it("should put a success action when a response is returned", () => {
35
36
  expect(() => {
@@ -38,8 +39,8 @@ describe("sagas: uploadStructuresSaga", () => {
38
39
  .put(uploadStructures.request())
39
40
  .next()
40
41
  .call(apiJsonPost, API_STRUCTURES_UPLOAD, body, UPLOAD_JSON_OPTS)
41
- .next({ data })
42
- .put(uploadStructures.success({ data }))
42
+ .next({ status, data })
43
+ .put(uploadStructures.success({ status, data }))
43
44
  .next()
44
45
  .put(uploadStructures.fulfill())
45
46
  .next()
@@ -0,0 +1,29 @@
1
+ import { call, put, takeLatest } from "redux-saga/effects";
2
+ import { apiJson, JSON_OPTS } from "@truedat/core/services/api";
3
+ import { fetchStructuresUploadEvents as fetchStructuresUploadEvents } from "../routines";
4
+ import { API_STRUCTURES_UPLOAD_EVENTS } from "../api";
5
+
6
+ export function* fetchStructuresUploadEventsSaga() {
7
+ try {
8
+ const url = API_STRUCTURES_UPLOAD_EVENTS;
9
+ yield put(fetchStructuresUploadEvents.request());
10
+ const { data } = yield call(apiJson, url, JSON_OPTS);
11
+ yield put(fetchStructuresUploadEvents.success(data));
12
+ } catch (error) {
13
+ if (error.response) {
14
+ const { status, data } = error.response;
15
+ yield put(fetchStructuresUploadEvents.failure({ status, data }));
16
+ } else {
17
+ yield put(fetchStructuresUploadEvents.failure(error.message));
18
+ }
19
+ } finally {
20
+ yield put(fetchStructuresUploadEvents.fulfill());
21
+ }
22
+ }
23
+
24
+ export function* fetchStructuresUploadEventsRequestSaga() {
25
+ yield takeLatest(
26
+ fetchStructuresUploadEvents.TRIGGER,
27
+ fetchStructuresUploadEventsSaga
28
+ );
29
+ }
@@ -35,6 +35,7 @@ import { fetchStructureTypeRequestSaga } from "./fetchStructureType";
35
35
  import { fetchStructureTypesRequestSaga } from "./fetchStructureTypes";
36
36
  import { fetchUserSearchFiltersRequestSaga } from "./fetchUserSearchFilters";
37
37
  import { fetchStructuresRequestSaga } from "./fetchStructures";
38
+ import { fetchStructuresUploadEventsRequestSaga } from "./fetchStructuresUploadEvents";
38
39
  import { fetchSystemRequestSaga } from "./fetchSystem";
39
40
  import { fetchSystemStructuresRequestSaga } from "./fetchSystemStructures";
40
41
  import { fetchSystemsRequestSaga } from "./fetchSystems";
@@ -85,6 +86,7 @@ export {
85
86
  fetchStructureTagsRequestSaga,
86
87
  fetchStructureTypeRequestSaga,
87
88
  fetchStructureTypesRequestSaga,
89
+ fetchStructuresUploadEventsRequestSaga,
88
90
  fetchUserSearchFiltersRequestSaga,
89
91
  fetchStructuresRequestSaga,
90
92
  fetchSystemRequestSaga,
@@ -140,6 +142,7 @@ export default [
140
142
  fetchStructureTypesRequestSaga(),
141
143
  fetchUserSearchFiltersRequestSaga(),
142
144
  fetchStructuresRequestSaga(),
145
+ fetchStructuresUploadEventsRequestSaga(),
143
146
  fetchSystemRequestSaga(),
144
147
  fetchSystemStructuresRequestSaga(),
145
148
  fetchSystemsRequestSaga(),
@@ -7,14 +7,14 @@ export function* uploadStructuresSaga({ payload }) {
7
7
  try {
8
8
  const { data: body } = payload;
9
9
  yield put(uploadStructures.request());
10
- const { data } = yield call(
10
+ const { status, data } = yield call(
11
11
  apiJsonPost,
12
12
  API_STRUCTURES_UPLOAD,
13
13
  body,
14
14
  UPLOAD_JSON_OPTS
15
15
  );
16
16
 
17
- yield put(uploadStructures.success({ data }));
17
+ yield put(uploadStructures.success({ status, data }));
18
18
  } catch (error) {
19
19
  if (error.response) {
20
20
  const { status, data } = error.response;
@@ -0,0 +1,20 @@
1
+ import {
2
+ getStructuresUploadEventColumns,
3
+ defaultStructuresUploadEventColumns,
4
+ } from "..";
5
+
6
+ describe("selectors: getStructuresUploadEventColumns", () => {
7
+ it("should return custom structuresUploadEventColumns when present", () => {
8
+ const structuresUploadEventColumns = [{ name: "test" }];
9
+ const res = getStructuresUploadEventColumns({
10
+ structuresUploadEventColumns
11
+ });
12
+ expect(res).toHaveLength(1);
13
+ expect(res).toEqual(structuresUploadEventColumns);
14
+ });
15
+
16
+ it("should return default defaultRuleImplementationColumns when no customized", () => {
17
+ const res = getStructuresUploadEventColumns({});
18
+ expect(res).toHaveLength(defaultStructuresUploadEventColumns.length);
19
+ });
20
+ });