@truedat/dd 4.43.6 → 4.44.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.
- package/CHANGELOG.md +6 -0
- package/package.json +6 -6
- package/src/api/fragments.js +10 -0
- package/src/api/mutations.js +28 -0
- package/src/api/queries.js +20 -0
- package/src/api.js +0 -4
- package/src/components/DictionaryRoutes.js +2 -10
- package/src/components/LinkStructureTagForm.js +2 -2
- package/src/components/LinkedStructureTag.js +16 -7
- package/src/components/StructureLinkTagButton.js +8 -11
- package/src/components/StructureSummary.js +1 -1
- package/src/components/StructureTag.js +59 -20
- package/src/components/StructureTagForm.js +30 -35
- package/src/components/StructureTags.js +7 -6
- package/src/components/StructureTagsCards.js +56 -59
- package/src/components/StructureTagsCrumbs.js +4 -4
- package/src/components/StructureTagsRoutes.js +33 -57
- package/src/components/StructuresRoutes.js +0 -3
- package/src/components/TagsHeader.js +14 -21
- package/src/components/__tests__/PendingStructureNoteRow.spec.js +5 -1
- package/src/components/__tests__/PendingStructureNotes.spec.js +2 -2
- package/src/components/__tests__/StructureTag.spec.js +4 -1
- package/src/components/__tests__/StructureTagForm.spec.js +40 -82
- package/src/components/__tests__/StructureTags.spec.js +7 -7
- package/src/components/__tests__/StructureTagsCards.spec.js +38 -36
- package/src/components/__tests__/StructuresUploadEventsTable.spec.js +36 -42
- package/src/components/__tests__/__snapshots__/DictionaryRoutes.spec.js.snap +3 -3
- package/src/components/__tests__/__snapshots__/PendingStructureNoteRow.spec.js.snap +33 -29
- package/src/components/__tests__/__snapshots__/StructureTag.spec.js.snap +13 -2
- package/src/components/__tests__/__snapshots__/StructureTagForm.spec.js.snap +7 -56
- package/src/components/__tests__/__snapshots__/StructureTags.spec.js.snap +32 -44
- package/src/components/__tests__/__snapshots__/StructureTagsCards.spec.js.snap +53 -118
- package/src/components/__tests__/__snapshots__/StructureTagsCrumbs.spec.js.snap +1 -1
- package/src/components/__tests__/__snapshots__/StructureTypes.spec.js.snap +1 -1
- package/src/components/__tests__/__snapshots__/StructureTypesCrumbs.spec.js.snap +1 -1
- package/src/components/__tests__/__snapshots__/StructureTypesTable.spec.js.snap +2 -2
- package/src/messages/en.js +1 -0
- package/src/messages/es.js +1 -0
- package/src/reducers/__tests__/editableStructureTags.spec.js +39 -0
- package/src/reducers/__tests__/structureTagsSaving.spec.js +40 -0
- package/src/reducers/__tests__/structuresUploadEventsLoading.spec.js +18 -4
- package/src/reducers/editableStructureTags.js +19 -0
- package/src/reducers/index.js +4 -9
- package/src/reducers/structureTagSaving.js +18 -0
- package/src/routines.js +3 -5
- package/src/sagas/__tests__/createStructureTag.spec.js +28 -13
- package/src/sagas/__tests__/deleteStructureTag.spec.js +27 -15
- package/src/sagas/__tests__/updateStructureTag.spec.js +26 -13
- package/src/sagas/createStructureTag.js +15 -13
- package/src/sagas/deleteStructureTag.js +13 -8
- package/src/sagas/index.js +0 -6
- package/src/sagas/updateStructureTag.js +8 -15
- package/src/selectors/__tests__/getStructuresUploadEventColumns.spec.js +1 -1
- package/src/components/StructureTagLoader.js +0 -28
- package/src/components/StructureTagsLoader.js +0 -26
- package/src/components/__tests__/StructureTagLoader.spec.js +0 -29
- package/src/components/__tests__/StructureTagsLoader.spec.js +0 -24
- package/src/components/__tests__/__snapshots__/StructureTagLoader.spec.js.snap +0 -3
- package/src/components/__tests__/__snapshots__/StructureTagsLoader.spec.js.snap +0 -3
- package/src/reducers/__tests__/structureTag.spec.js +0 -80
- package/src/reducers/__tests__/structureTagLoading.spec.js +0 -40
- package/src/reducers/__tests__/structureTags.spec.js +0 -32
- package/src/reducers/__tests__/structureTagsLoading.spec.js +0 -40
- package/src/reducers/structureTag.js +0 -38
- package/src/reducers/structureTagLoading.js +0 -16
- package/src/reducers/structureTags.js +0 -19
- package/src/reducers/structureTagsLoading.js +0 -16
- package/src/sagas/__tests__/deleteStructureType.spec.js +0 -70
- package/src/sagas/__tests__/fetchStructureTag.spec.js +0 -74
- package/src/sagas/__tests__/fetchStructureTags.spec.js +0 -72
- package/src/sagas/fetchStructureTag.js +0 -29
- package/src/sagas/fetchStructureTags.js +0 -25
package/src/reducers/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { creatingGrantRequestApproval } from "./creatingGrantRequestApproval";
|
|
|
4
4
|
import { csvGraphDownloading } from "./csvGraphDownloading";
|
|
5
5
|
import { ddMessage } from "./ddMessage";
|
|
6
6
|
import { deletingStructureTags } from "./deletingStructureTags";
|
|
7
|
+
import { editableStructureTags } from "./editableStructureTags";
|
|
7
8
|
import { grantActiveFilters } from "./grantActiveFilters";
|
|
8
9
|
import { grantCount } from "./grantCount";
|
|
9
10
|
import { grantDateFilter } from "./grantDateFilter";
|
|
@@ -65,10 +66,7 @@ import { structureRedirect } from "./structureRedirect";
|
|
|
65
66
|
import { structureSelectedFilter } from "./structureSelectedFilter";
|
|
66
67
|
import { structureSiblings } from "./structureSiblings";
|
|
67
68
|
import { structureSystem } from "./structureSystem";
|
|
68
|
-
import {
|
|
69
|
-
import { structureTagLoading } from "./structureTagLoading";
|
|
70
|
-
import { structureTags } from "./structureTags";
|
|
71
|
-
import { structureTagsLoading } from "./structureTagsLoading";
|
|
69
|
+
import { structureTagSaving } from "./structureTagSaving";
|
|
72
70
|
import { structureType } from "./structureType";
|
|
73
71
|
import { structureTypeLoading } from "./structureTypeLoading";
|
|
74
72
|
import { structureTypes } from "./structureTypes";
|
|
@@ -103,6 +101,7 @@ export {
|
|
|
103
101
|
csvGraphDownloading,
|
|
104
102
|
ddMessage,
|
|
105
103
|
deletingStructureTags,
|
|
104
|
+
editableStructureTags,
|
|
106
105
|
grantActiveFilters,
|
|
107
106
|
grantCount,
|
|
108
107
|
grantDateFilter,
|
|
@@ -165,11 +164,7 @@ export {
|
|
|
165
164
|
structureSelectedFilter,
|
|
166
165
|
structureSiblings,
|
|
167
166
|
structureSystem,
|
|
168
|
-
|
|
169
|
-
structureTagCreating,
|
|
170
|
-
structureTagLoading,
|
|
171
|
-
structureTags,
|
|
172
|
-
structureTagsLoading,
|
|
167
|
+
structureTagSaving,
|
|
173
168
|
structureType,
|
|
174
169
|
structureTypeLoading,
|
|
175
170
|
structureTypes,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { updateStructureTag, createStructureTag } from "../routines";
|
|
2
|
+
|
|
3
|
+
const structureTagSaving = (state = false, { type }) => {
|
|
4
|
+
switch (type) {
|
|
5
|
+
case updateStructureTag.TRIGGER:
|
|
6
|
+
return true;
|
|
7
|
+
case updateStructureTag.FULFILL:
|
|
8
|
+
return false;
|
|
9
|
+
case createStructureTag.TRIGGER:
|
|
10
|
+
return true;
|
|
11
|
+
case createStructureTag.FULFILL:
|
|
12
|
+
return false;
|
|
13
|
+
default:
|
|
14
|
+
return state;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { structureTagSaving };
|
package/src/routines.js
CHANGED
|
@@ -26,8 +26,6 @@ export const clearResources = createRoutine("CLEAR_RESOURCES");
|
|
|
26
26
|
export const clearStructure = createRoutine("CLEAR_STRUCTURE");
|
|
27
27
|
export const clearStructureFilters = createRoutine("CLEAR_STRUCTURE_FILTERS");
|
|
28
28
|
export const clearStructureNotes = createRoutine("CLEAR_STRUCTURE_NOTES");
|
|
29
|
-
export const clearStructureTag = createRoutine("CLEAR_STRUCTURE_TAG");
|
|
30
|
-
export const clearStructureTags = createRoutine("CLEAR_STRUCTURE_TAGS");
|
|
31
29
|
export const clearStructureType = createRoutine("CLEAR_STRUCTURE_TYPE");
|
|
32
30
|
export const clearStructureTypes = createRoutine("CLEAR_STRUCTURE_TYPES");
|
|
33
31
|
export const clearUserSearchFilters = createRoutine(
|
|
@@ -78,15 +76,15 @@ export const fetchStructure = createRoutine("FETCH_STRUCTURE");
|
|
|
78
76
|
export const fetchStructureFilters = createRoutine("FETCH_STRUCTURE_FILTERS");
|
|
79
77
|
export const fetchStructureGraph = createRoutine("FETCH_STRUCTURE_GRAPH");
|
|
80
78
|
export const fetchStructureNotes = createRoutine("FETCH_STRUCTURE_NOTES");
|
|
81
|
-
export const fetchStructureTag = createRoutine("FETCH_STRUCTURE_TAG");
|
|
82
|
-
export const fetchStructureTags = createRoutine("FETCH_STRUCTURE_TAGS");
|
|
83
79
|
export const fetchStructureType = createRoutine("FETCH_STRUCTURE_TYPE");
|
|
84
80
|
export const fetchStructureTypes = createRoutine("FETCH_STRUCTURE_TYPES");
|
|
85
81
|
export const fetchUserSearchFilters = createRoutine(
|
|
86
82
|
"FETCH_USER_SEARCH_FILTERS"
|
|
87
83
|
);
|
|
88
84
|
export const fetchStructures = createRoutine("FETCH_STRUCTURES");
|
|
89
|
-
export const fetchStructuresUploadEvents = createRoutine(
|
|
85
|
+
export const fetchStructuresUploadEvents = createRoutine(
|
|
86
|
+
"FETCH_STRUCTURES_UPLOAD_EVENTS"
|
|
87
|
+
);
|
|
90
88
|
export const fetchSystem = createRoutine("FETCH_SYSTEM");
|
|
91
89
|
export const fetchSystemStructures = createRoutine("FETCH_SYSTEM_STRUCTURES");
|
|
92
90
|
export const fetchSystems = createRoutine("FETCH_SYSTEMS");
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { testSaga } from "redux-saga-test-plan";
|
|
2
|
-
import { apiJsonPost, JSON_OPTS } from "@truedat/core/services/api";
|
|
3
2
|
import {
|
|
4
3
|
createStructureTagRequestSaga,
|
|
5
4
|
createStructureTagSaga,
|
|
5
|
+
onSuccess,
|
|
6
6
|
} from "../createStructureTag";
|
|
7
|
+
import { CREATE_STRUCTURE_TAG } from "../../api/mutations";
|
|
7
8
|
import { createStructureTag } from "../../routines";
|
|
8
|
-
import { API_STRUCTURE_TAGS } from "../../api";
|
|
9
9
|
|
|
10
|
-
describe("sagas:
|
|
10
|
+
describe("sagas: createStructureTagRequestSaga", () => {
|
|
11
11
|
it("should invoke createStructureTagSaga on createStructureTag.TRIGGER", () => {
|
|
12
12
|
expect(() => {
|
|
13
13
|
testSaga(createStructureTagRequestSaga)
|
|
@@ -27,21 +27,30 @@ describe("sagas: createStructureTagSaga", () => {
|
|
|
27
27
|
});
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
describe("sagas:
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
|
|
30
|
+
describe("sagas: createStructureTagSaga", () => {
|
|
31
|
+
const client = { mutate: jest.fn() };
|
|
32
|
+
const structureTag = {
|
|
33
|
+
name: "tag1",
|
|
34
|
+
domainIds: ["1", "2"],
|
|
34
35
|
};
|
|
36
|
+
const payload = structureTag;
|
|
37
|
+
const data = { foo: "bar" };
|
|
35
38
|
|
|
36
39
|
it("should put a success action when a response is returned", () => {
|
|
37
40
|
expect(() => {
|
|
38
41
|
testSaga(createStructureTagSaga, { payload })
|
|
39
42
|
.next()
|
|
40
|
-
.
|
|
43
|
+
.getContext("client")
|
|
44
|
+
.next(client)
|
|
45
|
+
.put(createStructureTag.request(payload))
|
|
41
46
|
.next()
|
|
42
|
-
.call(
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
.call(client.mutate, {
|
|
48
|
+
mutation: CREATE_STRUCTURE_TAG,
|
|
49
|
+
update: onSuccess,
|
|
50
|
+
variables: { structureTag },
|
|
51
|
+
})
|
|
52
|
+
.next({ data })
|
|
53
|
+
.put(createStructureTag.success(data))
|
|
45
54
|
.next()
|
|
46
55
|
.put(createStructureTag.fulfill())
|
|
47
56
|
.next()
|
|
@@ -56,9 +65,15 @@ describe("sagas: createSourceSaga", () => {
|
|
|
56
65
|
expect(() => {
|
|
57
66
|
testSaga(createStructureTagSaga, { payload })
|
|
58
67
|
.next()
|
|
59
|
-
.
|
|
68
|
+
.getContext("client")
|
|
69
|
+
.next(client)
|
|
70
|
+
.put(createStructureTag.request(payload))
|
|
60
71
|
.next()
|
|
61
|
-
.call(
|
|
72
|
+
.call(client.mutate, {
|
|
73
|
+
mutation: CREATE_STRUCTURE_TAG,
|
|
74
|
+
update: onSuccess,
|
|
75
|
+
variables: { structureTag },
|
|
76
|
+
})
|
|
62
77
|
.throw(error)
|
|
63
78
|
.put(createStructureTag.failure(message))
|
|
64
79
|
.next()
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { compile } from "path-to-regexp";
|
|
2
1
|
import { testSaga } from "redux-saga-test-plan";
|
|
3
|
-
import {
|
|
2
|
+
import { DELETE_STRUCTURE_TAG } from "../../api/mutations";
|
|
3
|
+
import { deleteStructureTag } from "../../routines";
|
|
4
4
|
import {
|
|
5
|
-
deleteStructureTagSaga,
|
|
6
5
|
deleteStructureTagRequestSaga,
|
|
6
|
+
deleteStructureTagSaga,
|
|
7
|
+
onSuccess,
|
|
7
8
|
} from "../deleteStructureTag";
|
|
8
|
-
import { deleteStructureTag } from "../../routines";
|
|
9
|
-
import { API_STRUCTURE_TAG } from "../../api";
|
|
10
9
|
|
|
11
10
|
describe("sagas: deleteStructureTagRequestSaga", () => {
|
|
12
|
-
it("should invoke deleteStructureTagSaga on
|
|
11
|
+
it("should invoke deleteStructureTagSaga on trigger", () => {
|
|
13
12
|
expect(() => {
|
|
14
13
|
testSaga(deleteStructureTagRequestSaga)
|
|
15
14
|
.next()
|
|
@@ -23,23 +22,29 @@ describe("sagas: deleteStructureTagRequestSaga", () => {
|
|
|
23
22
|
expect(() => {
|
|
24
23
|
testSaga(deleteStructureTagRequestSaga)
|
|
25
24
|
.next()
|
|
26
|
-
.takeLatest("FOO",
|
|
25
|
+
.takeLatest("FOO", deleteStructureTagSaga);
|
|
27
26
|
}).toThrow();
|
|
28
27
|
});
|
|
29
28
|
});
|
|
30
29
|
|
|
31
30
|
describe("sagas: deleteStructureTagSaga", () => {
|
|
32
|
-
const
|
|
33
|
-
const { id }
|
|
34
|
-
const
|
|
31
|
+
const id = 1;
|
|
32
|
+
const payload = { id };
|
|
33
|
+
const client = { mutate: jest.fn() };
|
|
35
34
|
|
|
36
35
|
it("should put a success action when a response is returned", () => {
|
|
37
36
|
expect(() => {
|
|
38
37
|
testSaga(deleteStructureTagSaga, { payload })
|
|
39
38
|
.next()
|
|
40
|
-
.
|
|
39
|
+
.getContext("client")
|
|
40
|
+
.next(client)
|
|
41
|
+
.put(deleteStructureTag.request(payload))
|
|
41
42
|
.next()
|
|
42
|
-
.call(
|
|
43
|
+
.call(client.mutate, {
|
|
44
|
+
mutation: DELETE_STRUCTURE_TAG,
|
|
45
|
+
update: onSuccess,
|
|
46
|
+
variables: payload,
|
|
47
|
+
})
|
|
43
48
|
.next({ data: payload })
|
|
44
49
|
.put(deleteStructureTag.success(payload))
|
|
45
50
|
.next()
|
|
@@ -49,16 +54,23 @@ describe("sagas: deleteStructureTagSaga", () => {
|
|
|
49
54
|
}).not.toThrow();
|
|
50
55
|
});
|
|
51
56
|
|
|
52
|
-
it("should put a failure action when the call
|
|
57
|
+
it("should put a failure action when the call throws an error", () => {
|
|
53
58
|
const message = "Request failed";
|
|
54
59
|
const error = { message };
|
|
60
|
+
const client = { mutate: jest.fn() };
|
|
55
61
|
|
|
56
62
|
expect(() => {
|
|
57
63
|
testSaga(deleteStructureTagSaga, { payload })
|
|
58
64
|
.next()
|
|
59
|
-
.
|
|
65
|
+
.getContext("client")
|
|
66
|
+
.next(client)
|
|
67
|
+
.put(deleteStructureTag.request(payload))
|
|
60
68
|
.next()
|
|
61
|
-
.call(
|
|
69
|
+
.call(client.mutate, {
|
|
70
|
+
mutation: DELETE_STRUCTURE_TAG,
|
|
71
|
+
update: onSuccess,
|
|
72
|
+
variables: payload,
|
|
73
|
+
})
|
|
62
74
|
.throw(error)
|
|
63
75
|
.put(deleteStructureTag.failure(message))
|
|
64
76
|
.next()
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import { compile } from "path-to-regexp";
|
|
2
1
|
import { testSaga } from "redux-saga-test-plan";
|
|
3
|
-
import { apiJsonPatch, JSON_OPTS } from "@truedat/core/services/api";
|
|
4
2
|
import {
|
|
5
3
|
updateStructureTagRequestSaga,
|
|
6
4
|
updateStructureTagSaga,
|
|
7
5
|
} from "../updateStructureTag";
|
|
6
|
+
import { UPDATE_STRUCTURE_TAG } from "../../api/mutations";
|
|
8
7
|
import { updateStructureTag } from "../../routines";
|
|
9
|
-
import { API_STRUCTURE_TAG } from "../../api";
|
|
10
8
|
|
|
11
9
|
describe("sagas: updateStructureTagRequestSaga", () => {
|
|
12
|
-
it("should invoke updateStructureTagSaga on
|
|
10
|
+
it("should invoke updateStructureTagSaga on updateStructureTag.TRIGGER", () => {
|
|
13
11
|
expect(() => {
|
|
14
12
|
testSaga(updateStructureTagRequestSaga)
|
|
15
13
|
.next()
|
|
@@ -23,26 +21,36 @@ describe("sagas: updateStructureTagRequestSaga", () => {
|
|
|
23
21
|
expect(() => {
|
|
24
22
|
testSaga(updateStructureTagRequestSaga)
|
|
25
23
|
.next()
|
|
26
|
-
.takeLatest("FOO",
|
|
24
|
+
.takeLatest("FOO", updateStructureTagRequestSaga);
|
|
27
25
|
}).toThrow();
|
|
28
26
|
});
|
|
29
27
|
});
|
|
30
28
|
|
|
31
29
|
describe("sagas: updateStructureTagSaga", () => {
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
const client = { mutate: jest.fn() };
|
|
31
|
+
const structureTag = {
|
|
32
|
+
id: "123",
|
|
33
|
+
name: "tag1",
|
|
34
|
+
domainIds: ["1", "2"],
|
|
35
|
+
};
|
|
36
|
+
const payload = structureTag;
|
|
37
|
+
const variables = { id: structureTag.id, structureTag };
|
|
38
|
+
const data = { foo: "bar" };
|
|
36
39
|
|
|
37
40
|
it("should put a success action when a response is returned", () => {
|
|
38
41
|
expect(() => {
|
|
39
42
|
testSaga(updateStructureTagSaga, { payload })
|
|
40
43
|
.next()
|
|
44
|
+
.getContext("client")
|
|
45
|
+
.next(client)
|
|
41
46
|
.put(updateStructureTag.request(payload))
|
|
42
47
|
.next()
|
|
43
|
-
.call(
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
.call(client.mutate, {
|
|
49
|
+
mutation: UPDATE_STRUCTURE_TAG,
|
|
50
|
+
variables,
|
|
51
|
+
})
|
|
52
|
+
.next({ data })
|
|
53
|
+
.put(updateStructureTag.success(data))
|
|
46
54
|
.next()
|
|
47
55
|
.put(updateStructureTag.fulfill())
|
|
48
56
|
.next()
|
|
@@ -57,9 +65,14 @@ describe("sagas: updateStructureTagSaga", () => {
|
|
|
57
65
|
expect(() => {
|
|
58
66
|
testSaga(updateStructureTagSaga, { payload })
|
|
59
67
|
.next()
|
|
68
|
+
.getContext("client")
|
|
69
|
+
.next(client)
|
|
60
70
|
.put(updateStructureTag.request(payload))
|
|
61
71
|
.next()
|
|
62
|
-
.call(
|
|
72
|
+
.call(client.mutate, {
|
|
73
|
+
mutation: UPDATE_STRUCTURE_TAG,
|
|
74
|
+
variables,
|
|
75
|
+
})
|
|
63
76
|
.throw(error)
|
|
64
77
|
.put(updateStructureTag.failure(message))
|
|
65
78
|
.next()
|
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import { call, put, takeLatest } from "redux-saga/effects";
|
|
2
|
-
import {
|
|
1
|
+
import { call, put, takeLatest, getContext } from "redux-saga/effects";
|
|
2
|
+
import { CREATE_STRUCTURE_TAG } from "../api/mutations";
|
|
3
3
|
import { createStructureTag } from "../routines";
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
export const onSuccess = (cache) => {
|
|
6
|
+
cache.evict({ id: "ROOT_QUERY", fieldName: "structureTags" });
|
|
7
|
+
cache.gc();
|
|
8
|
+
};
|
|
5
9
|
|
|
6
10
|
export function* createStructureTagSaga({ payload }) {
|
|
11
|
+
const client = yield getContext("client");
|
|
7
12
|
try {
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
yield put(createStructureTag.request(payload));
|
|
14
|
+
const { data } = yield call(client.mutate, {
|
|
15
|
+
mutation: CREATE_STRUCTURE_TAG,
|
|
16
|
+
update: onSuccess,
|
|
17
|
+
variables: { structureTag: payload },
|
|
18
|
+
});
|
|
12
19
|
yield put(createStructureTag.success(data));
|
|
13
20
|
} catch (error) {
|
|
14
|
-
|
|
15
|
-
const { status, data } = error.response;
|
|
16
|
-
yield put(createStructureTag.failure({ status, data }));
|
|
17
|
-
} else {
|
|
18
|
-
yield put(createStructureTag.failure(error.message));
|
|
19
|
-
}
|
|
21
|
+
yield put(createStructureTag.failure(error.message));
|
|
20
22
|
} finally {
|
|
21
23
|
yield put(createStructureTag.fulfill());
|
|
22
24
|
}
|
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { call, put, takeLatest } from "redux-saga/effects";
|
|
3
|
-
import { apiJsonDelete, JSON_OPTS } from "@truedat/core/services/api";
|
|
1
|
+
import { call, put, takeLatest, getContext } from "redux-saga/effects";
|
|
4
2
|
import { deleteStructureTag } from "../routines";
|
|
5
|
-
import {
|
|
3
|
+
import { DELETE_STRUCTURE_TAG } from "../api/mutations";
|
|
6
4
|
|
|
7
|
-
const
|
|
5
|
+
export const onSuccess = (cache, { data: { deleteStructureTag } }) => {
|
|
6
|
+
cache.evict({ id: cache.identify(deleteStructureTag) });
|
|
7
|
+
cache.gc();
|
|
8
|
+
};
|
|
8
9
|
|
|
9
10
|
export function* deleteStructureTagSaga({ payload }) {
|
|
11
|
+
const client = yield getContext("client");
|
|
10
12
|
try {
|
|
11
|
-
|
|
12
|
-
yield
|
|
13
|
-
|
|
13
|
+
yield put(deleteStructureTag.request(payload));
|
|
14
|
+
const { data } = yield call(client.mutate, {
|
|
15
|
+
mutation: DELETE_STRUCTURE_TAG,
|
|
16
|
+
update: onSuccess,
|
|
17
|
+
variables: payload,
|
|
18
|
+
});
|
|
14
19
|
yield put(deleteStructureTag.success(data));
|
|
15
20
|
} catch (error) {
|
|
16
21
|
if (error.response) {
|
package/src/sagas/index.js
CHANGED
|
@@ -29,8 +29,6 @@ import { fetchStructureFiltersRequestSaga } from "./fetchStructureFilters";
|
|
|
29
29
|
import { fetchStructureGraphRequestSaga } from "./fetchStructureGraph";
|
|
30
30
|
import { fetchStructureNotesRequestSaga } from "./fetchStructureNotes";
|
|
31
31
|
import { fetchStructureRequestSaga } from "./fetchStructure";
|
|
32
|
-
import { fetchStructureTagRequestSaga } from "./fetchStructureTag";
|
|
33
|
-
import { fetchStructureTagsRequestSaga } from "./fetchStructureTags";
|
|
34
32
|
import { fetchStructureTypeRequestSaga } from "./fetchStructureType";
|
|
35
33
|
import { fetchStructureTypesRequestSaga } from "./fetchStructureTypes";
|
|
36
34
|
import { fetchUserSearchFiltersRequestSaga } from "./fetchUserSearchFilters";
|
|
@@ -82,8 +80,6 @@ export {
|
|
|
82
80
|
fetchStructureGraphRequestSaga,
|
|
83
81
|
fetchStructureNotesRequestSaga,
|
|
84
82
|
fetchStructureRequestSaga,
|
|
85
|
-
fetchStructureTagRequestSaga,
|
|
86
|
-
fetchStructureTagsRequestSaga,
|
|
87
83
|
fetchStructureTypeRequestSaga,
|
|
88
84
|
fetchStructureTypesRequestSaga,
|
|
89
85
|
fetchStructuresUploadEventsRequestSaga,
|
|
@@ -136,8 +132,6 @@ export default [
|
|
|
136
132
|
fetchStructureGraphRequestSaga(),
|
|
137
133
|
fetchStructureNotesRequestSaga(),
|
|
138
134
|
fetchStructureRequestSaga(),
|
|
139
|
-
fetchStructureTagRequestSaga(),
|
|
140
|
-
fetchStructureTagsRequestSaga(),
|
|
141
135
|
fetchStructureTypeRequestSaga(),
|
|
142
136
|
fetchStructureTypesRequestSaga(),
|
|
143
137
|
fetchUserSearchFiltersRequestSaga(),
|
|
@@ -1,25 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { call, put, takeLatest } from "redux-saga/effects";
|
|
3
|
-
import { apiJsonPatch, JSON_OPTS } from "@truedat/core/services/api";
|
|
1
|
+
import { call, put, takeLatest, getContext } from "redux-saga/effects";
|
|
4
2
|
import { updateStructureTag } from "../routines";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
const structureTagPath = compile(API_STRUCTURE_TAG);
|
|
3
|
+
import { UPDATE_STRUCTURE_TAG } from "../api/mutations";
|
|
8
4
|
|
|
9
5
|
export function* updateStructureTagSaga({ payload }) {
|
|
6
|
+
const client = yield getContext("client");
|
|
10
7
|
try {
|
|
11
|
-
const url = structureTagPath(payload);
|
|
12
|
-
const requestData = { data_structure_tag: payload };
|
|
13
8
|
yield put(updateStructureTag.request(payload));
|
|
14
|
-
const { data } = yield call(
|
|
9
|
+
const { data } = yield call(client.mutate, {
|
|
10
|
+
mutation: UPDATE_STRUCTURE_TAG,
|
|
11
|
+
variables: { id: payload?.id, structureTag: payload },
|
|
12
|
+
});
|
|
15
13
|
yield put(updateStructureTag.success(data));
|
|
16
14
|
} catch (error) {
|
|
17
|
-
|
|
18
|
-
const { status, data } = error.response;
|
|
19
|
-
yield put(updateStructureTag.failure({ status, data }));
|
|
20
|
-
} else {
|
|
21
|
-
yield put(updateStructureTag.failure(error.message));
|
|
22
|
-
}
|
|
15
|
+
yield put(updateStructureTag.failure(error.message));
|
|
23
16
|
} finally {
|
|
24
17
|
yield put(updateStructureTag.fulfill());
|
|
25
18
|
}
|
|
@@ -7,7 +7,7 @@ describe("selectors: getStructuresUploadEventColumns", () => {
|
|
|
7
7
|
it("should return custom structuresUploadEventColumns when present", () => {
|
|
8
8
|
const structuresUploadEventColumns = [{ name: "test" }];
|
|
9
9
|
const res = getStructuresUploadEventColumns({
|
|
10
|
-
structuresUploadEventColumns
|
|
10
|
+
structuresUploadEventColumns,
|
|
11
11
|
});
|
|
12
12
|
expect(res).toHaveLength(1);
|
|
13
13
|
expect(res).toEqual(structuresUploadEventColumns);
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { useEffect } from "react";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
|
-
import { connect } from "react-redux";
|
|
4
|
-
import { useParams } from "react-router-dom";
|
|
5
|
-
import { clearStructureTag, fetchStructureTag } from "../routines";
|
|
6
|
-
|
|
7
|
-
export const StructureTagLoader = ({
|
|
8
|
-
clearStructureTag,
|
|
9
|
-
fetchStructureTag,
|
|
10
|
-
}) => {
|
|
11
|
-
const { id } = useParams();
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
fetchStructureTag({ id });
|
|
14
|
-
return () => {
|
|
15
|
-
clearStructureTag();
|
|
16
|
-
};
|
|
17
|
-
}, [clearStructureTag, fetchStructureTag, id]);
|
|
18
|
-
return null;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
StructureTagLoader.propTypes = {
|
|
22
|
-
clearStructureTag: PropTypes.func,
|
|
23
|
-
fetchStructureTag: PropTypes.func,
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export default connect(null, { clearStructureTag, fetchStructureTag })(
|
|
27
|
-
StructureTagLoader
|
|
28
|
-
);
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { useEffect } from "react";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
|
-
import { connect } from "react-redux";
|
|
4
|
-
import { clearStructureTags, fetchStructureTags } from "../routines";
|
|
5
|
-
|
|
6
|
-
export const StructureTagsLoader = ({
|
|
7
|
-
clearStructureTags,
|
|
8
|
-
fetchStructureTags,
|
|
9
|
-
}) => {
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
fetchStructureTags();
|
|
12
|
-
return () => {
|
|
13
|
-
clearStructureTags();
|
|
14
|
-
};
|
|
15
|
-
}, [clearStructureTags, fetchStructureTags]);
|
|
16
|
-
return null;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
StructureTagsLoader.propTypes = {
|
|
20
|
-
clearStructureTags: PropTypes.func,
|
|
21
|
-
fetchStructureTags: PropTypes.func,
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export default connect(null, { clearStructureTags, fetchStructureTags })(
|
|
25
|
-
StructureTagsLoader
|
|
26
|
-
);
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { shallow, mount } from "enzyme";
|
|
3
|
-
import { StructureTagLoader } from "../StructureTagLoader";
|
|
4
|
-
|
|
5
|
-
jest.mock("react-router-dom", () => ({
|
|
6
|
-
...jest.requireActual("react-router-dom"),
|
|
7
|
-
useParams: () => ({ id: 1 })
|
|
8
|
-
}));
|
|
9
|
-
|
|
10
|
-
describe("<StructureTagLoader />", () => {
|
|
11
|
-
it("matches the latest snapshot", () => {
|
|
12
|
-
const fetchStructureTag = jest.fn();
|
|
13
|
-
const props = { fetchStructureTag };
|
|
14
|
-
const wrapper = shallow(<StructureTagLoader {...props} />);
|
|
15
|
-
expect(wrapper).toMatchSnapshot();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it("calls fetchStructureTag when component mounts, clearStructureTag when component unmounts", () => {
|
|
19
|
-
const fetchStructureTag = jest.fn();
|
|
20
|
-
const clearStructureTag = jest.fn();
|
|
21
|
-
const props = { fetchStructureTag, clearStructureTag };
|
|
22
|
-
const wrapper = mount(<StructureTagLoader {...props} />);
|
|
23
|
-
expect(clearStructureTag.mock.calls.length).toBe(0);
|
|
24
|
-
expect(fetchStructureTag.mock.calls.length).toBe(1);
|
|
25
|
-
wrapper.unmount();
|
|
26
|
-
expect(clearStructureTag.mock.calls.length).toBe(1);
|
|
27
|
-
expect(fetchStructureTag.mock.calls.length).toBe(1);
|
|
28
|
-
});
|
|
29
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { shallow, mount } from "enzyme";
|
|
3
|
-
import { StructureTagsLoader } from "../StructureTagsLoader";
|
|
4
|
-
|
|
5
|
-
describe("<StructureTagsLoader />", () => {
|
|
6
|
-
it("matches the latest snapshot", () => {
|
|
7
|
-
const fetchStructureTags = jest.fn();
|
|
8
|
-
const props = { fetchStructureTags };
|
|
9
|
-
const wrapper = shallow(<StructureTagsLoader {...props} />);
|
|
10
|
-
expect(wrapper).toMatchSnapshot();
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it("calls fetchStructureTags when component mounts, clearStructureTags when component unmounts", () => {
|
|
14
|
-
const fetchStructureTags = jest.fn();
|
|
15
|
-
const clearStructureTags = jest.fn();
|
|
16
|
-
const props = { fetchStructureTags, clearStructureTags };
|
|
17
|
-
const wrapper = mount(<StructureTagsLoader {...props} />);
|
|
18
|
-
expect(clearStructureTags.mock.calls.length).toBe(0);
|
|
19
|
-
expect(fetchStructureTags.mock.calls.length).toBe(1);
|
|
20
|
-
wrapper.unmount();
|
|
21
|
-
expect(clearStructureTags.mock.calls.length).toBe(1);
|
|
22
|
-
expect(fetchStructureTags.mock.calls.length).toBe(1);
|
|
23
|
-
});
|
|
24
|
-
});
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
fetchStructureTag,
|
|
3
|
-
clearStructureTag,
|
|
4
|
-
createStructureTag
|
|
5
|
-
} from "../../routines";
|
|
6
|
-
import { structureTag, structureTagCreating } from "..";
|
|
7
|
-
|
|
8
|
-
const fooState = { foo: "bar" };
|
|
9
|
-
|
|
10
|
-
describe("reducers: structureTag", () => {
|
|
11
|
-
const initialState = {};
|
|
12
|
-
|
|
13
|
-
it("should provide the initial state", () => {
|
|
14
|
-
expect(structureTag(undefined, {})).toEqual(initialState);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it("should handle the fetchStructureTag.SUCCESS action", () => {
|
|
18
|
-
const data = {
|
|
19
|
-
id: 1,
|
|
20
|
-
structure_type: "doc",
|
|
21
|
-
template_id: 1,
|
|
22
|
-
translation: null
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
expect(
|
|
26
|
-
structureTag(fooState, {
|
|
27
|
-
type: fetchStructureTag.SUCCESS,
|
|
28
|
-
payload: { data }
|
|
29
|
-
})
|
|
30
|
-
).toMatchObject(data);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("should handle the clearStructureTag.TRIGGER action", () => {
|
|
34
|
-
expect(
|
|
35
|
-
structureTag(fooState, {
|
|
36
|
-
type: clearStructureTag.TRIGGER
|
|
37
|
-
})
|
|
38
|
-
).toMatchObject({});
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it("should ignore unknown actions", () => {
|
|
42
|
-
expect(structureTag(fooState, { type: "FOO" })).toBe(fooState);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
describe("reducers: structureTagCreating", () => {
|
|
47
|
-
const initialState = false;
|
|
48
|
-
|
|
49
|
-
it("should provide the initial state", () => {
|
|
50
|
-
expect(structureTagCreating(undefined, {})).toBe(initialState);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it("should handle the createStructureTag.TRIGGER action", () => {
|
|
54
|
-
expect(
|
|
55
|
-
structureTagCreating(fooState, {
|
|
56
|
-
type: createStructureTag.TRIGGER
|
|
57
|
-
})
|
|
58
|
-
).toBe(true);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("should handle the createStructureTag.SUCCESS action", () => {
|
|
62
|
-
expect(
|
|
63
|
-
structureTagCreating(fooState, {
|
|
64
|
-
type: createStructureTag.SUCCESS
|
|
65
|
-
})
|
|
66
|
-
).toBe(false);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it("should handle the createStructureTag.FAILURE action", () => {
|
|
70
|
-
expect(
|
|
71
|
-
structureTagCreating(fooState, {
|
|
72
|
-
type: createStructureTag.FAILURE
|
|
73
|
-
})
|
|
74
|
-
).toBe(false);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it("should ignore unknown actions", () => {
|
|
78
|
-
expect(structureTagCreating(fooState, { type: "FOO" })).toBe(fooState);
|
|
79
|
-
});
|
|
80
|
-
});
|