@truedat/bg 8.7.2 → 8.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/bg",
|
|
3
|
-
"version": "8.7.
|
|
3
|
+
"version": "8.7.3",
|
|
4
4
|
"description": "Truedat Web Business Glossary",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"**/*.css",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@testing-library/jest-dom": "^6.6.3",
|
|
55
55
|
"@testing-library/react": "^16.3.0",
|
|
56
56
|
"@testing-library/user-event": "^14.6.1",
|
|
57
|
-
"@truedat/test": "8.7.
|
|
57
|
+
"@truedat/test": "8.7.3",
|
|
58
58
|
"identity-obj-proxy": "^3.0.0",
|
|
59
59
|
"jest": "^29.7.0",
|
|
60
60
|
"redux-saga-test-plan": "^4.0.6"
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"semantic-ui-react": "^3.0.0-beta.2",
|
|
88
88
|
"swr": "^2.3.3"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "fcd75ad6b4e43440c4889fb3d968f4cd84fc672d"
|
|
91
91
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { deleteRelation } from "@truedat/lm/routines";
|
|
2
|
+
import { clearConcept, fetchConcept, conceptLinkAction } from "../../routines";
|
|
3
|
+
import { conceptLinks } from "..";
|
|
4
|
+
|
|
5
|
+
const fooState = { foo: "bar" };
|
|
6
|
+
|
|
7
|
+
describe("reducers: conceptLinks", () => {
|
|
8
|
+
const initialState = [];
|
|
9
|
+
|
|
10
|
+
it("should provide the initial state", () => {
|
|
11
|
+
expect(conceptLinks(undefined, {})).toEqual(initialState);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("should handle the clearConcept.TRIGGER action", () => {
|
|
15
|
+
expect(conceptLinks(fooState, { type: clearConcept.TRIGGER })).toEqual(
|
|
16
|
+
initialState,
|
|
17
|
+
);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("should handle the fetchConcept.TRIGGER action", () => {
|
|
21
|
+
expect(conceptLinks(fooState, { type: fetchConcept.TRIGGER })).toEqual(
|
|
22
|
+
initialState,
|
|
23
|
+
);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("should handle the fetchConcept.SUCCESS action", () => {
|
|
27
|
+
const links = [{ id: "1" }, { id: "2" }];
|
|
28
|
+
const payload = { data: { _embedded: { links } } };
|
|
29
|
+
|
|
30
|
+
expect(
|
|
31
|
+
conceptLinks(fooState, { type: fetchConcept.SUCCESS, payload }),
|
|
32
|
+
).toEqual(links);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("should remove link on conceptLinkAction.SUCCESS DELETE action", () => {
|
|
36
|
+
const href = "/api/business_concept_versions/20/links/1";
|
|
37
|
+
const links = [
|
|
38
|
+
{ id: "1", _actions: { delete: { href } } },
|
|
39
|
+
{
|
|
40
|
+
id: "2",
|
|
41
|
+
_actions: {
|
|
42
|
+
delete: { href: "/api/business_concept_versions/20/links/2" },
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
expect(
|
|
48
|
+
conceptLinks(links, {
|
|
49
|
+
type: conceptLinkAction.SUCCESS,
|
|
50
|
+
meta: { method: "DELETE", href },
|
|
51
|
+
}),
|
|
52
|
+
).toEqual([links[1]]);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("should remove link on deleteRelation.SUCCESS action", () => {
|
|
56
|
+
const links = [{ id: "1" }, { id: "2" }];
|
|
57
|
+
|
|
58
|
+
expect(
|
|
59
|
+
conceptLinks(links, {
|
|
60
|
+
type: deleteRelation.SUCCESS,
|
|
61
|
+
meta: { id: 1 },
|
|
62
|
+
}),
|
|
63
|
+
).toEqual([{ id: "2" }]);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("should ignore unknown actions", () => {
|
|
67
|
+
expect(conceptLinks(fooState, { type: "FOO" })).toBe(fooState);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
|
+
import { deleteRelation } from "@truedat/lm/routines";
|
|
2
3
|
import { clearConcept, fetchConcept, conceptLinkAction } from "../routines";
|
|
3
4
|
|
|
4
5
|
const initialState = [];
|
|
@@ -16,6 +17,10 @@ const conceptLinks = (state = initialState, { type, payload, meta }) => {
|
|
|
16
17
|
return method === "DELETE"
|
|
17
18
|
? _.reject(_.pathEq("_actions.delete.href")(href))(state)
|
|
18
19
|
: state;
|
|
20
|
+
case deleteRelation.SUCCESS: {
|
|
21
|
+
const { id } = meta;
|
|
22
|
+
return _.reject((link) => `${link.id}` === `${id}`)(state);
|
|
23
|
+
}
|
|
19
24
|
default:
|
|
20
25
|
return state;
|
|
21
26
|
}
|
|
@@ -111,13 +111,26 @@ const orderedLinks = (links) =>
|
|
|
111
111
|
const conceptLinks = (links, columns) =>
|
|
112
112
|
_.flow(
|
|
113
113
|
orderedLinks,
|
|
114
|
-
_.filter(
|
|
114
|
+
_.filter(
|
|
115
|
+
({ deleted_at, disabled_at }) =>
|
|
116
|
+
_.isEmpty(deleted_at) && _.isEmpty(disabled_at),
|
|
117
|
+
),
|
|
115
118
|
_.groupBy("\uffee"),
|
|
116
119
|
_.toPairs,
|
|
117
120
|
_.sortBy(([k]) => k),
|
|
118
121
|
_.map((pair) => withHeaders(pair, columns)),
|
|
119
122
|
)(links);
|
|
120
123
|
|
|
124
|
+
const conceptDisabledLinks = (links, columns) => {
|
|
125
|
+
const disabled = _.flow(
|
|
126
|
+
orderedLinks,
|
|
127
|
+
_.filter(({ disabled_at }) => _.negate(_.isEmpty)(disabled_at)),
|
|
128
|
+
)(links);
|
|
129
|
+
return _.isEmpty(disabled)
|
|
130
|
+
? []
|
|
131
|
+
: [withHeaders(["disabled", disabled], columns)];
|
|
132
|
+
};
|
|
133
|
+
|
|
121
134
|
const conceptDeletedLinks = (links, columns) => {
|
|
122
135
|
const deleted = _.flow(
|
|
123
136
|
orderedLinks,
|
|
@@ -135,6 +148,7 @@ export const getConceptLinks = createSelector(
|
|
|
135
148
|
|
|
136
149
|
return [
|
|
137
150
|
...conceptLinks(linksWithDataStructureType, columns),
|
|
151
|
+
...conceptDisabledLinks(linksWithDataStructureType, columns),
|
|
138
152
|
...conceptDeletedLinks(linksWithDataStructureType, columns),
|
|
139
153
|
];
|
|
140
154
|
},
|