@truedat/dd 4.48.11 → 4.49.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 +5 -5
- package/src/api/fragments.js +2 -2
- package/src/api/mutations.js +33 -11
- package/src/api/queries.js +37 -10
- package/src/api.js +0 -4
- package/src/components/DictionaryRoutes.js +4 -4
- package/src/components/StructureSummary.js +12 -22
- package/src/components/StructureTag.js +83 -54
- package/src/components/StructureTagForm.js +149 -89
- package/src/components/StructureTags.js +57 -27
- package/src/components/Tag.js +62 -0
- package/src/components/TagCards.js +85 -0
- package/src/components/TagCrumbs.js +25 -0
- package/src/components/TagForm.js +101 -0
- package/src/components/TagStructureButton.js +58 -0
- package/src/components/Tags.js +33 -0
- package/src/components/TagsRoutes.js +39 -0
- package/src/components/__tests__/StructureSummary.spec.js +0 -7
- package/src/components/__tests__/StructureTag.spec.js +79 -5
- package/src/components/__tests__/StructureTagForm.spec.js +99 -50
- package/src/components/__tests__/Tag.spec.js +11 -0
- package/src/components/__tests__/{StructureTagsCards.spec.js → TagCards.spec.js} +10 -10
- package/src/components/__tests__/TagCrumbs.spec.js +10 -0
- package/src/components/__tests__/TagForm.spec.js +72 -0
- package/src/components/__tests__/Tags.spec.js +10 -0
- package/src/components/__tests__/__snapshots__/StructureSummary.spec.js.snap +18 -42
- package/src/components/__tests__/__snapshots__/StructureTag.spec.js.snap +10 -30
- package/src/components/__tests__/__snapshots__/StructureTagForm.spec.js.snap +255 -51
- package/src/components/__tests__/__snapshots__/Tag.spec.js.snap +36 -0
- package/src/components/__tests__/__snapshots__/{StructureTagsCards.spec.js.snap → TagCards.spec.js.snap} +1 -1
- package/src/components/__tests__/__snapshots__/TagCrumbs.spec.js.snap +102 -0
- package/src/components/__tests__/__snapshots__/TagForm.spec.js.snap +70 -0
- package/src/components/__tests__/__snapshots__/{StructureTags.spec.js.snap → Tags.spec.js.snap} +1 -1
- package/src/messages/en.js +25 -30
- package/src/messages/es.js +25 -30
- package/src/reducers/__tests__/{editableStructureTags.spec.js → availableTags.spec.js} +7 -11
- package/src/reducers/__tests__/structureTagSaving.spec.js +36 -0
- package/src/reducers/__tests__/tagSaving.spec.js +32 -0
- package/src/reducers/{editableStructureTags.js → availableTags.js} +2 -2
- package/src/reducers/index.js +6 -12
- package/src/reducers/structureRedirect.js +7 -7
- package/src/reducers/structureTagSaving.js +12 -10
- package/src/reducers/tagSaving.js +18 -0
- package/src/routines.js +5 -6
- package/src/sagas/__tests__/createTag.spec.js +81 -0
- package/src/sagas/__tests__/deleteStructureTag.spec.js +11 -12
- package/src/sagas/__tests__/deleteTag.spec.js +76 -0
- package/src/sagas/__tests__/tagStructure.spec.js +86 -0
- package/src/sagas/__tests__/updateTag.spec.js +81 -0
- package/src/sagas/createTag.js +29 -0
- package/src/sagas/deleteStructureTag.js +12 -9
- package/src/sagas/deleteTag.js +34 -0
- package/src/sagas/index.js +15 -18
- package/src/sagas/tagStructure.js +37 -0
- package/src/sagas/updateTag.js +23 -0
- package/src/components/LinkStructureTagForm.js +0 -163
- package/src/components/LinkedStructureTag.js +0 -124
- package/src/components/StructureLinkTagButton.js +0 -47
- package/src/components/StructureTagsCards.js +0 -92
- package/src/components/StructureTagsCrumbs.js +0 -44
- package/src/components/StructureTagsRoutes.js +0 -45
- package/src/components/TagsHeader.js +0 -32
- package/src/components/__tests__/LinkStructureTagForm.spec.js +0 -184
- package/src/components/__tests__/LinkedStructureTag.spec.js +0 -133
- package/src/components/__tests__/StructureTags.spec.js +0 -14
- package/src/components/__tests__/StructureTagsCrumbs.spec.js +0 -13
- package/src/components/__tests__/__snapshots__/LinkStructureTagForm.spec.js.snap +0 -456
- package/src/components/__tests__/__snapshots__/LinkedStructureTag.spec.js.snap +0 -16
- package/src/components/__tests__/__snapshots__/StructureTagsCrumbs.spec.js.snap +0 -36
- package/src/reducers/__tests__/deletingStructureTags.spec.js +0 -30
- package/src/reducers/__tests__/linkedStructureTags.spec.js +0 -69
- package/src/reducers/__tests__/linkedStructureTagsLoading.spec.js +0 -32
- package/src/reducers/__tests__/linkingStructureTags.spec.js +0 -30
- package/src/reducers/__tests__/structureTagsSaving.spec.js +0 -40
- package/src/reducers/deletingStructureTags.js +0 -16
- package/src/reducers/linkedStructureTags.js +0 -28
- package/src/reducers/linkedStructureTagsLoading.js +0 -16
- package/src/reducers/linkingStructureTags.js +0 -16
- package/src/sagas/__tests__/createStructureTag.spec.js +0 -85
- package/src/sagas/__tests__/deleteLinkStructureTag.spec.js +0 -96
- package/src/sagas/__tests__/fetchLinksStructureTags.spec.js +0 -105
- package/src/sagas/__tests__/linkStructureTag.spec.js +0 -102
- package/src/sagas/__tests__/updateStructureTag.spec.js +0 -84
- package/src/sagas/createStructureTag.js +0 -29
- package/src/sagas/deleteLinkStructureTag.js +0 -29
- package/src/sagas/fetchLinksStructureTags.js +0 -31
- package/src/sagas/linkStructureTag.js +0 -30
- package/src/sagas/updateStructureTag.js +0 -23
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { testSaga } from "redux-saga-test-plan";
|
|
2
|
+
import {
|
|
3
|
+
tagStructureSaga,
|
|
4
|
+
tagStructureRequestSaga,
|
|
5
|
+
onSuccess,
|
|
6
|
+
} from "../tagStructure";
|
|
7
|
+
import { tagStructure } from "../../routines";
|
|
8
|
+
import { TAG_STRUCTURE } from "../../api/mutations";
|
|
9
|
+
|
|
10
|
+
describe("sagas: tagStructureRequestSaga", () => {
|
|
11
|
+
it("should invoke tagStructureSaga on tagStructure.TRIGGER", () => {
|
|
12
|
+
expect(() => {
|
|
13
|
+
testSaga(tagStructureRequestSaga)
|
|
14
|
+
.next()
|
|
15
|
+
.takeLatest(tagStructure.TRIGGER, tagStructureSaga)
|
|
16
|
+
.finish()
|
|
17
|
+
.isDone();
|
|
18
|
+
}).not.toThrow();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("should throw exception if an unhandled action is received", () => {
|
|
22
|
+
expect(() => {
|
|
23
|
+
testSaga(tagStructureRequestSaga)
|
|
24
|
+
.next()
|
|
25
|
+
.takeLatest("FOO", tagStructureSaga);
|
|
26
|
+
}).toThrow();
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
describe("sagas: tagStructureSaga", () => {
|
|
31
|
+
const payload = {
|
|
32
|
+
tagId: 1,
|
|
33
|
+
dataStructureId: 1,
|
|
34
|
+
comment: "foo",
|
|
35
|
+
inherit: false,
|
|
36
|
+
};
|
|
37
|
+
const data = { id: 1 };
|
|
38
|
+
const client = { mutate: jest.fn() };
|
|
39
|
+
|
|
40
|
+
it("should put a success action when a response is returned", () => {
|
|
41
|
+
expect(() => {
|
|
42
|
+
testSaga(tagStructureSaga, { payload })
|
|
43
|
+
.next()
|
|
44
|
+
.getContext("client")
|
|
45
|
+
.next(client)
|
|
46
|
+
.put(tagStructure.request(payload))
|
|
47
|
+
.next()
|
|
48
|
+
.call(client.mutate, {
|
|
49
|
+
mutation: TAG_STRUCTURE,
|
|
50
|
+
update: onSuccess,
|
|
51
|
+
variables: { structureTag: payload },
|
|
52
|
+
})
|
|
53
|
+
.next({ data })
|
|
54
|
+
.put(tagStructure.success(data))
|
|
55
|
+
.next()
|
|
56
|
+
.put(tagStructure.fulfill())
|
|
57
|
+
.next()
|
|
58
|
+
.isDone();
|
|
59
|
+
}).not.toThrow();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("should put a failure action when the call returns an error with message", () => {
|
|
63
|
+
const message = "Request failed";
|
|
64
|
+
const error = { message };
|
|
65
|
+
|
|
66
|
+
expect(() => {
|
|
67
|
+
testSaga(tagStructureSaga, { payload })
|
|
68
|
+
.next()
|
|
69
|
+
.getContext("client")
|
|
70
|
+
.next(client)
|
|
71
|
+
.put(tagStructure.request(payload))
|
|
72
|
+
.next()
|
|
73
|
+
.call(client.mutate, {
|
|
74
|
+
mutation: TAG_STRUCTURE,
|
|
75
|
+
update: onSuccess,
|
|
76
|
+
variables: { structureTag: payload },
|
|
77
|
+
})
|
|
78
|
+
.throw(error)
|
|
79
|
+
.put(tagStructure.failure(message))
|
|
80
|
+
.next()
|
|
81
|
+
.put(tagStructure.fulfill())
|
|
82
|
+
.next()
|
|
83
|
+
.isDone();
|
|
84
|
+
}).not.toThrow();
|
|
85
|
+
});
|
|
86
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { testSaga } from "redux-saga-test-plan";
|
|
2
|
+
import { updateTagRequestSaga, updateTagSaga } from "../updateTag";
|
|
3
|
+
import { UPDATE_TAG } from "../../api/mutations";
|
|
4
|
+
import { updateTag } from "../../routines";
|
|
5
|
+
|
|
6
|
+
describe("sagas: updateTagRequestSaga", () => {
|
|
7
|
+
it("should invoke updateTagSaga on updateTag.TRIGGER", () => {
|
|
8
|
+
expect(() => {
|
|
9
|
+
testSaga(updateTagRequestSaga)
|
|
10
|
+
.next()
|
|
11
|
+
.takeLatest(updateTag.TRIGGER, updateTagSaga)
|
|
12
|
+
.finish()
|
|
13
|
+
.isDone();
|
|
14
|
+
}).not.toThrow();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("should throw exception if an unhandled action is received", () => {
|
|
18
|
+
expect(() => {
|
|
19
|
+
testSaga(updateTagRequestSaga)
|
|
20
|
+
.next()
|
|
21
|
+
.takeLatest("FOO", updateTagRequestSaga);
|
|
22
|
+
}).toThrow();
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe("sagas: updateTagSaga", () => {
|
|
27
|
+
const client = { mutate: jest.fn() };
|
|
28
|
+
const tag = {
|
|
29
|
+
id: "123",
|
|
30
|
+
name: "tag1",
|
|
31
|
+
domainIds: ["1", "2"],
|
|
32
|
+
};
|
|
33
|
+
const payload = tag;
|
|
34
|
+
const variables = { id: tag.id, tag };
|
|
35
|
+
const data = { foo: "bar" };
|
|
36
|
+
|
|
37
|
+
it("should put a success action when a response is returned", () => {
|
|
38
|
+
expect(() => {
|
|
39
|
+
testSaga(updateTagSaga, { payload })
|
|
40
|
+
.next()
|
|
41
|
+
.getContext("client")
|
|
42
|
+
.next(client)
|
|
43
|
+
.put(updateTag.request(payload))
|
|
44
|
+
.next()
|
|
45
|
+
.call(client.mutate, {
|
|
46
|
+
mutation: UPDATE_TAG,
|
|
47
|
+
variables,
|
|
48
|
+
})
|
|
49
|
+
.next({ data })
|
|
50
|
+
.put(updateTag.success(data))
|
|
51
|
+
.next()
|
|
52
|
+
.put(updateTag.fulfill())
|
|
53
|
+
.next()
|
|
54
|
+
.isDone();
|
|
55
|
+
}).not.toThrow();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("should put a failure action when the call returns an error", () => {
|
|
59
|
+
const message = "Request failed";
|
|
60
|
+
const error = { message };
|
|
61
|
+
|
|
62
|
+
expect(() => {
|
|
63
|
+
testSaga(updateTagSaga, { payload })
|
|
64
|
+
.next()
|
|
65
|
+
.getContext("client")
|
|
66
|
+
.next(client)
|
|
67
|
+
.put(updateTag.request(payload))
|
|
68
|
+
.next()
|
|
69
|
+
.call(client.mutate, {
|
|
70
|
+
mutation: UPDATE_TAG,
|
|
71
|
+
variables,
|
|
72
|
+
})
|
|
73
|
+
.throw(error)
|
|
74
|
+
.put(updateTag.failure(message))
|
|
75
|
+
.next()
|
|
76
|
+
.put(updateTag.fulfill())
|
|
77
|
+
.next()
|
|
78
|
+
.isDone();
|
|
79
|
+
}).not.toThrow();
|
|
80
|
+
});
|
|
81
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { call, put, takeLatest, getContext } from "redux-saga/effects";
|
|
2
|
+
import { CREATE_TAG } from "../api/mutations";
|
|
3
|
+
import { createTag } from "../routines";
|
|
4
|
+
|
|
5
|
+
export const onSuccess = (cache) => {
|
|
6
|
+
cache.evict({ id: "ROOT_QUERY", fieldName: "tags" });
|
|
7
|
+
cache.gc();
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function* createTagSaga({ payload }) {
|
|
11
|
+
const client = yield getContext("client");
|
|
12
|
+
try {
|
|
13
|
+
yield put(createTag.request(payload));
|
|
14
|
+
const { data } = yield call(client.mutate, {
|
|
15
|
+
mutation: CREATE_TAG,
|
|
16
|
+
update: onSuccess,
|
|
17
|
+
variables: { tag: payload },
|
|
18
|
+
});
|
|
19
|
+
yield put(createTag.success(data));
|
|
20
|
+
} catch (error) {
|
|
21
|
+
yield put(createTag.failure(error.message));
|
|
22
|
+
} finally {
|
|
23
|
+
yield put(createTag.fulfill());
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function* createTagRequestSaga() {
|
|
28
|
+
yield takeLatest(createTag.TRIGGER, createTagSaga);
|
|
29
|
+
}
|
|
@@ -4,26 +4,29 @@ import { DELETE_STRUCTURE_TAG } from "../api/mutations";
|
|
|
4
4
|
|
|
5
5
|
export const onSuccess = (cache, { data: { deleteStructureTag } }) => {
|
|
6
6
|
cache.evict({ id: cache.identify(deleteStructureTag) });
|
|
7
|
+
cache.evict({
|
|
8
|
+
id: cache.identify(deleteStructureTag?.dataStructure),
|
|
9
|
+
fieldName: "structureTags",
|
|
10
|
+
});
|
|
11
|
+
cache.evict({
|
|
12
|
+
id: cache.identify(deleteStructureTag?.dataStructure),
|
|
13
|
+
fieldName: "availableTags",
|
|
14
|
+
});
|
|
7
15
|
cache.gc();
|
|
8
16
|
};
|
|
9
17
|
|
|
10
|
-
export function* deleteStructureTagSaga({ payload }) {
|
|
18
|
+
export function* deleteStructureTagSaga({ payload: id }) {
|
|
11
19
|
const client = yield getContext("client");
|
|
12
20
|
try {
|
|
13
|
-
yield put(deleteStructureTag.request(
|
|
21
|
+
yield put(deleteStructureTag.request(id));
|
|
14
22
|
const { data } = yield call(client.mutate, {
|
|
15
23
|
mutation: DELETE_STRUCTURE_TAG,
|
|
16
24
|
update: onSuccess,
|
|
17
|
-
variables:
|
|
25
|
+
variables: { id },
|
|
18
26
|
});
|
|
19
27
|
yield put(deleteStructureTag.success(data));
|
|
20
28
|
} catch (error) {
|
|
21
|
-
|
|
22
|
-
const { status, data } = error.response;
|
|
23
|
-
yield put(deleteStructureTag.failure({ status, data }));
|
|
24
|
-
} else {
|
|
25
|
-
yield put(deleteStructureTag.failure(error.message));
|
|
26
|
-
}
|
|
29
|
+
yield put(deleteStructureTag.failure(error.message));
|
|
27
30
|
} finally {
|
|
28
31
|
yield put(deleteStructureTag.fulfill());
|
|
29
32
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { call, put, takeLatest, getContext } from "redux-saga/effects";
|
|
2
|
+
import { deleteTag } from "../routines";
|
|
3
|
+
import { DELETE_TAG } from "../api/mutations";
|
|
4
|
+
|
|
5
|
+
export const onSuccess = (cache, { data: { deleteTag } }) => {
|
|
6
|
+
cache.evict({ id: cache.identify(deleteTag) });
|
|
7
|
+
cache.gc();
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function* deleteTagSaga({ payload }) {
|
|
11
|
+
const client = yield getContext("client");
|
|
12
|
+
try {
|
|
13
|
+
yield put(deleteTag.request(payload));
|
|
14
|
+
const { data } = yield call(client.mutate, {
|
|
15
|
+
mutation: DELETE_TAG,
|
|
16
|
+
update: onSuccess,
|
|
17
|
+
variables: payload,
|
|
18
|
+
});
|
|
19
|
+
yield put(deleteTag.success(data));
|
|
20
|
+
} catch (error) {
|
|
21
|
+
if (error.response) {
|
|
22
|
+
const { status, data } = error.response;
|
|
23
|
+
yield put(deleteTag.failure({ status, data }));
|
|
24
|
+
} else {
|
|
25
|
+
yield put(deleteTag.failure(error.message));
|
|
26
|
+
}
|
|
27
|
+
} finally {
|
|
28
|
+
yield put(deleteTag.fulfill());
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function* deleteTagRequestSaga() {
|
|
33
|
+
yield takeLatest(deleteTag.TRIGGER, deleteTagSaga);
|
|
34
|
+
}
|
package/src/sagas/index.js
CHANGED
|
@@ -4,12 +4,12 @@ import { createGraphRequestSaga } from "./createGraph";
|
|
|
4
4
|
import { createProfileGroupRequestSaga } from "./createProfileGroup";
|
|
5
5
|
import { createReferenceDatasetRequestSaga } from "./createReferenceDataset";
|
|
6
6
|
import { createStructureGraphRequestSaga } from "./createStructureGraph";
|
|
7
|
-
import { createStructureTagRequestSaga } from "./createStructureTag";
|
|
8
7
|
import { createSystemRequestSaga } from "./createSystem";
|
|
9
|
-
import {
|
|
8
|
+
import { createTagRequestSaga } from "./createTag";
|
|
9
|
+
import { deleteStructureTagRequestSaga } from "./deleteStructureTag";
|
|
10
10
|
import { deleteReferenceDatasetRequestSaga } from "./deleteReferenceDataset";
|
|
11
11
|
import { deleteStructureRequestSaga } from "./deleteStructure";
|
|
12
|
-
import {
|
|
12
|
+
import { deleteTagRequestSaga } from "./deleteTag";
|
|
13
13
|
import { deleteUserSearchFilterRequestSaga } from "./deleteUserSearchFilter";
|
|
14
14
|
import { doStructureNoteActionRequestSaga } from "./doStructureNoteAction";
|
|
15
15
|
import { downloadCsvGraphRequestSaga } from "./downloadCsvGraph";
|
|
@@ -23,7 +23,6 @@ import { fetchGrantRequestsRequestSaga } from "./fetchGrantRequests";
|
|
|
23
23
|
import { fetchGrantsRequestSaga } from "./fetchGrants";
|
|
24
24
|
import { fetchGraphRequestSaga } from "./fetchGraph";
|
|
25
25
|
import { fetchLineageEventsRequestSaga } from "./fetchLineageEvents";
|
|
26
|
-
import { fetchLinksStructureTagsRequestSaga } from "./fetchLinksStructureTags";
|
|
27
26
|
import { fetchNodesRequestSaga } from "./fetchNodes";
|
|
28
27
|
import { fetchProfileExecutionRequestSaga } from "./fetchProfileExecution";
|
|
29
28
|
import { fetchProfileGroupRequestSaga } from "./fetchProfileGroup";
|
|
@@ -40,17 +39,17 @@ import { fetchSystemStructuresRequestSaga } from "./fetchSystemStructures";
|
|
|
40
39
|
import { fetchSystemsRequestSaga } from "./fetchSystems";
|
|
41
40
|
import { fetchUnitDomainsRequestSaga } from "./fetchUnitDomains";
|
|
42
41
|
import { fetchUserSearchFiltersRequestSaga } from "./fetchUserSearchFilters";
|
|
43
|
-
import {
|
|
42
|
+
import { tagStructureRequestSaga } from "./tagStructure";
|
|
44
43
|
import { operateGrantRequestToCartRequestSaga } from "./operateGrantRequestCart";
|
|
45
44
|
import { requestGrantRemovalRequestSaga } from "./requestGrantRemoval";
|
|
46
45
|
import { saveUserSearchFiltersRequestSaga } from "./saveUserSearchFilters";
|
|
47
46
|
import { updateReferenceDatasetRequestSaga } from "./updateReferenceDataset";
|
|
48
47
|
import { updateStructureRequestSaga } from "./updateStructure";
|
|
49
|
-
import { updateStructureTagRequestSaga } from "./updateStructureTag";
|
|
50
48
|
import { updateStructureTypeRequestSaga } from "./updateStructureType";
|
|
51
49
|
import { updateSystemRequestSaga } from "./updateSystem";
|
|
52
50
|
import { uploadStructuresDomainsRequestSaga } from "./uploadStructuresDomains";
|
|
53
51
|
import { uploadStructuresRequestSaga } from "./uploadStructures";
|
|
52
|
+
import { updateTagRequestSaga } from "./updateTag";
|
|
54
53
|
|
|
55
54
|
export {
|
|
56
55
|
bulkUpdateStructuresRequestsSaga,
|
|
@@ -59,12 +58,12 @@ export {
|
|
|
59
58
|
createProfileGroupRequestSaga,
|
|
60
59
|
createReferenceDatasetRequestSaga,
|
|
61
60
|
createStructureGraphRequestSaga,
|
|
62
|
-
createStructureTagRequestSaga,
|
|
63
61
|
createSystemRequestSaga,
|
|
64
|
-
|
|
62
|
+
createTagRequestSaga,
|
|
63
|
+
deleteStructureTagRequestSaga,
|
|
65
64
|
deleteReferenceDatasetRequestSaga,
|
|
66
65
|
deleteStructureRequestSaga,
|
|
67
|
-
|
|
66
|
+
deleteTagRequestSaga,
|
|
68
67
|
deleteUserSearchFilterRequestSaga,
|
|
69
68
|
doStructureNoteActionRequestSaga,
|
|
70
69
|
downloadCsvGraphRequestSaga,
|
|
@@ -78,7 +77,6 @@ export {
|
|
|
78
77
|
fetchGrantsRequestSaga,
|
|
79
78
|
fetchGraphRequestSaga,
|
|
80
79
|
fetchLineageEventsRequestSaga,
|
|
81
|
-
fetchLinksStructureTagsRequestSaga,
|
|
82
80
|
fetchNodesRequestSaga,
|
|
83
81
|
fetchProfileExecutionRequestSaga,
|
|
84
82
|
fetchProfileGroupRequestSaga,
|
|
@@ -95,17 +93,17 @@ export {
|
|
|
95
93
|
fetchSystemsRequestSaga,
|
|
96
94
|
fetchUnitDomainsRequestSaga,
|
|
97
95
|
fetchUserSearchFiltersRequestSaga,
|
|
98
|
-
|
|
96
|
+
tagStructureRequestSaga,
|
|
99
97
|
operateGrantRequestToCartRequestSaga,
|
|
100
98
|
requestGrantRemovalRequestSaga,
|
|
101
99
|
saveUserSearchFiltersRequestSaga,
|
|
102
100
|
updateReferenceDatasetRequestSaga,
|
|
103
101
|
updateStructureRequestSaga,
|
|
104
|
-
updateStructureTagRequestSaga,
|
|
105
102
|
updateStructureTypeRequestSaga,
|
|
106
103
|
updateSystemRequestSaga,
|
|
107
104
|
uploadStructuresDomainsRequestSaga,
|
|
108
105
|
uploadStructuresRequestSaga,
|
|
106
|
+
updateTagRequestSaga,
|
|
109
107
|
};
|
|
110
108
|
|
|
111
109
|
export default [
|
|
@@ -115,12 +113,12 @@ export default [
|
|
|
115
113
|
createProfileGroupRequestSaga(),
|
|
116
114
|
createReferenceDatasetRequestSaga(),
|
|
117
115
|
createStructureGraphRequestSaga(),
|
|
118
|
-
|
|
116
|
+
createTagRequestSaga(),
|
|
119
117
|
createSystemRequestSaga(),
|
|
120
|
-
|
|
118
|
+
deleteStructureTagRequestSaga(),
|
|
121
119
|
deleteReferenceDatasetRequestSaga(),
|
|
122
120
|
deleteStructureRequestSaga(),
|
|
123
|
-
|
|
121
|
+
deleteTagRequestSaga(),
|
|
124
122
|
deleteUserSearchFilterRequestSaga(),
|
|
125
123
|
doStructureNoteActionRequestSaga(),
|
|
126
124
|
downloadCsvGraphRequestSaga(),
|
|
@@ -134,7 +132,6 @@ export default [
|
|
|
134
132
|
fetchGrantsRequestSaga(),
|
|
135
133
|
fetchGraphRequestSaga(),
|
|
136
134
|
fetchLineageEventsRequestSaga(),
|
|
137
|
-
fetchLinksStructureTagsRequestSaga(),
|
|
138
135
|
fetchNodesRequestSaga(),
|
|
139
136
|
fetchProfileExecutionRequestSaga(),
|
|
140
137
|
fetchProfileGroupRequestSaga(),
|
|
@@ -151,13 +148,13 @@ export default [
|
|
|
151
148
|
fetchSystemsRequestSaga(),
|
|
152
149
|
fetchUnitDomainsRequestSaga(),
|
|
153
150
|
fetchUserSearchFiltersRequestSaga(),
|
|
154
|
-
|
|
151
|
+
tagStructureRequestSaga(),
|
|
155
152
|
operateGrantRequestToCartRequestSaga(),
|
|
156
153
|
requestGrantRemovalRequestSaga(),
|
|
157
154
|
saveUserSearchFiltersRequestSaga(),
|
|
158
155
|
updateReferenceDatasetRequestSaga(),
|
|
159
156
|
updateStructureRequestSaga(),
|
|
160
|
-
|
|
157
|
+
updateTagRequestSaga(),
|
|
161
158
|
updateStructureTypeRequestSaga(),
|
|
162
159
|
updateSystemRequestSaga(),
|
|
163
160
|
uploadStructuresDomainsRequestSaga(),
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { call, put, takeLatest, getContext } from "redux-saga/effects";
|
|
2
|
+
import { tagStructure } from "../routines";
|
|
3
|
+
import { TAG_STRUCTURE } from "../api/mutations";
|
|
4
|
+
|
|
5
|
+
export const onSuccess = (cache, { data: { tagStructure } }) => {
|
|
6
|
+
cache.evict({ id: cache.identify(tagStructure) });
|
|
7
|
+
cache.evict({
|
|
8
|
+
id: cache.identify(tagStructure?.dataStructure),
|
|
9
|
+
fieldName: "structureTags",
|
|
10
|
+
});
|
|
11
|
+
cache.evict({
|
|
12
|
+
id: cache.identify(tagStructure?.dataStructure),
|
|
13
|
+
fieldName: "availableTags",
|
|
14
|
+
});
|
|
15
|
+
cache.gc();
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export function* tagStructureSaga({ payload }) {
|
|
19
|
+
const client = yield getContext("client");
|
|
20
|
+
try {
|
|
21
|
+
yield put(tagStructure.request(payload));
|
|
22
|
+
const { data } = yield call(client.mutate, {
|
|
23
|
+
mutation: TAG_STRUCTURE,
|
|
24
|
+
update: onSuccess,
|
|
25
|
+
variables: { structureTag: payload },
|
|
26
|
+
});
|
|
27
|
+
yield put(tagStructure.success(data));
|
|
28
|
+
} catch (error) {
|
|
29
|
+
yield put(tagStructure.failure(error.message));
|
|
30
|
+
} finally {
|
|
31
|
+
yield put(tagStructure.fulfill());
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function* tagStructureRequestSaga() {
|
|
36
|
+
yield takeLatest(tagStructure.TRIGGER, tagStructureSaga);
|
|
37
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { call, put, takeLatest, getContext } from "redux-saga/effects";
|
|
2
|
+
import { updateTag } from "../routines";
|
|
3
|
+
import { UPDATE_TAG } from "../api/mutations";
|
|
4
|
+
|
|
5
|
+
export function* updateTagSaga({ payload }) {
|
|
6
|
+
const client = yield getContext("client");
|
|
7
|
+
try {
|
|
8
|
+
yield put(updateTag.request(payload));
|
|
9
|
+
const { data } = yield call(client.mutate, {
|
|
10
|
+
mutation: UPDATE_TAG,
|
|
11
|
+
variables: { id: payload?.id, tag: payload },
|
|
12
|
+
});
|
|
13
|
+
yield put(updateTag.success(data));
|
|
14
|
+
} catch (error) {
|
|
15
|
+
yield put(updateTag.failure(error.message));
|
|
16
|
+
} finally {
|
|
17
|
+
yield put(updateTag.fulfill());
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function* updateTagRequestSaga() {
|
|
22
|
+
yield takeLatest(updateTag.TRIGGER, updateTagSaga);
|
|
23
|
+
}
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import _ from "lodash/fp";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { useForm, Controller } from "react-hook-form";
|
|
4
|
-
import { Button, Container, Form } from "semantic-ui-react";
|
|
5
|
-
import { connect } from "react-redux";
|
|
6
|
-
import PropTypes from "prop-types";
|
|
7
|
-
import { useIntl } from "react-intl";
|
|
8
|
-
import { accentInsensitivePathOrder } from "@truedat/core/services/sort";
|
|
9
|
-
import { deleteLinkStructureTag, linkStructureTag } from "../routines";
|
|
10
|
-
|
|
11
|
-
export const LinkStructureTagForm = ({
|
|
12
|
-
deleteLinkStructureTag,
|
|
13
|
-
comment,
|
|
14
|
-
linkedStructureTags,
|
|
15
|
-
linkId,
|
|
16
|
-
linkStructureTag,
|
|
17
|
-
structureId,
|
|
18
|
-
structureTags,
|
|
19
|
-
tagId,
|
|
20
|
-
}) => {
|
|
21
|
-
const { formatMessage } = useIntl();
|
|
22
|
-
const allTags = _.map("id")(structureTags);
|
|
23
|
-
const availableTags = _.negate(_.isNil)(tagId)
|
|
24
|
-
? allTags
|
|
25
|
-
: _.difference(
|
|
26
|
-
allTags,
|
|
27
|
-
_.map(_.path("_embedded.data_structure_tag.id"))(linkedStructureTags)
|
|
28
|
-
);
|
|
29
|
-
const options = _.flow(
|
|
30
|
-
_.filter(({ id }) => _.includes(id)(availableTags)),
|
|
31
|
-
_.sortBy(accentInsensitivePathOrder("name")),
|
|
32
|
-
_.map(({ id, name, description }) => ({
|
|
33
|
-
value: id,
|
|
34
|
-
text: name,
|
|
35
|
-
description: description,
|
|
36
|
-
}))
|
|
37
|
-
)(structureTags);
|
|
38
|
-
const defaultTag = _.negate(_.isNil)(tagId)
|
|
39
|
-
? tagId
|
|
40
|
-
: _.size(options) === 1
|
|
41
|
-
? _.head(options).value
|
|
42
|
-
: null;
|
|
43
|
-
const submitTitle = _.isNil(tagId)
|
|
44
|
-
? "structure.tag.add"
|
|
45
|
-
: "structure.tag.edit";
|
|
46
|
-
const onSubmit = (params) => {
|
|
47
|
-
const payload = {
|
|
48
|
-
structureId,
|
|
49
|
-
tagId: params.tag,
|
|
50
|
-
tag: { comment: params.comment },
|
|
51
|
-
};
|
|
52
|
-
linkStructureTag(payload);
|
|
53
|
-
};
|
|
54
|
-
const doDelete = () => deleteLinkStructureTag({ structureId, tagId });
|
|
55
|
-
const { handleSubmit, control, formState } = useForm({
|
|
56
|
-
mode: "all",
|
|
57
|
-
defaultValues: {
|
|
58
|
-
comment: comment || "",
|
|
59
|
-
tag: defaultTag,
|
|
60
|
-
},
|
|
61
|
-
});
|
|
62
|
-
const { isDirty, isValid } = formState;
|
|
63
|
-
return (
|
|
64
|
-
<Container className="link-structure-tag-form">
|
|
65
|
-
<Form onSubmit={handleSubmit(onSubmit)}>
|
|
66
|
-
<Controller
|
|
67
|
-
control={control}
|
|
68
|
-
name="tag"
|
|
69
|
-
rules={{ required: true }}
|
|
70
|
-
render={({
|
|
71
|
-
field: { onBlur, onChange, value },
|
|
72
|
-
fieldState: { error },
|
|
73
|
-
}) => (
|
|
74
|
-
<Form.Dropdown
|
|
75
|
-
name="tag"
|
|
76
|
-
disabled={_.negate(_.isNil)(tagId)}
|
|
77
|
-
error={!!error}
|
|
78
|
-
placeholder={formatMessage({
|
|
79
|
-
id: "structure.tag.dropdown.placeholder",
|
|
80
|
-
})}
|
|
81
|
-
label={formatMessage({ id: "structure.tag.dropdown.label" })}
|
|
82
|
-
onBlur={onBlur}
|
|
83
|
-
onChange={(_e, { value }) => onChange(value)}
|
|
84
|
-
clearable
|
|
85
|
-
search
|
|
86
|
-
selection
|
|
87
|
-
options={options}
|
|
88
|
-
value={value}
|
|
89
|
-
/>
|
|
90
|
-
)}
|
|
91
|
-
/>
|
|
92
|
-
<Controller
|
|
93
|
-
control={control}
|
|
94
|
-
name="comment"
|
|
95
|
-
render={({
|
|
96
|
-
field: { onBlur, onChange, value },
|
|
97
|
-
fieldState: { error },
|
|
98
|
-
}) => (
|
|
99
|
-
<Form.TextArea
|
|
100
|
-
data-testid="comment-id"
|
|
101
|
-
error={!!error}
|
|
102
|
-
name="comment"
|
|
103
|
-
label={formatMessage({ id: "structure.tag.textArea.label" })}
|
|
104
|
-
placeholder={formatMessage({
|
|
105
|
-
id: "structure.tag.textArea.placeholder",
|
|
106
|
-
})}
|
|
107
|
-
onBlur={onBlur}
|
|
108
|
-
onChange={(_e, { value }) => onChange(value)}
|
|
109
|
-
value={value}
|
|
110
|
-
/>
|
|
111
|
-
)}
|
|
112
|
-
/>
|
|
113
|
-
<div className="actions">
|
|
114
|
-
<Button
|
|
115
|
-
type="submit"
|
|
116
|
-
disabled={(!isDirty && options.length > 1) || !isValid}
|
|
117
|
-
primary
|
|
118
|
-
content={formatMessage({ id: submitTitle })}
|
|
119
|
-
/>
|
|
120
|
-
{_.negate(_.isNil)(linkId) && (
|
|
121
|
-
<Button
|
|
122
|
-
type="button"
|
|
123
|
-
onClick={doDelete}
|
|
124
|
-
secondary
|
|
125
|
-
content={formatMessage({ id: "structure.tag.delete" })}
|
|
126
|
-
/>
|
|
127
|
-
)}
|
|
128
|
-
</div>
|
|
129
|
-
</Form>
|
|
130
|
-
</Container>
|
|
131
|
-
);
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
LinkStructureTagForm.propTypes = {
|
|
135
|
-
deleteLinkStructureTag: PropTypes.func,
|
|
136
|
-
comment: PropTypes.string,
|
|
137
|
-
linkedStructureTags: PropTypes.array,
|
|
138
|
-
linkId: PropTypes.number,
|
|
139
|
-
linkStructureTag: PropTypes.func,
|
|
140
|
-
structureId: PropTypes.number,
|
|
141
|
-
structureTags: PropTypes.array,
|
|
142
|
-
tagId: PropTypes.number,
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
const mapStateToProps = ({
|
|
146
|
-
linkedStructureTags,
|
|
147
|
-
structure,
|
|
148
|
-
editableStructureTags,
|
|
149
|
-
}) => ({
|
|
150
|
-
linkedStructureTags,
|
|
151
|
-
structureId: _.prop("id")(structure),
|
|
152
|
-
structureTags: editableStructureTags,
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
const mapDispatchToProps = {
|
|
156
|
-
deleteLinkStructureTag,
|
|
157
|
-
linkStructureTag,
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
export default connect(
|
|
161
|
-
mapStateToProps,
|
|
162
|
-
mapDispatchToProps
|
|
163
|
-
)(LinkStructureTagForm);
|