@truedat/lm 5.8.1 → 5.8.2
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 +4 -4
- package/src/components/ConceptLinkTags.js +0 -1
- package/src/components/ConceptStructureLinkForm.js +4 -7
- package/src/components/TagTypeDropdownSelector.js +21 -4
- package/src/reducers/__tests__/handlingRelation.spec.js +34 -0
- package/src/reducers/__tests__/relations.spec.js +1 -5
- package/src/reducers/handlingRelation.js +18 -0
- package/src/reducers/index.js +3 -3
- package/src/reducers/relations.js +12 -5
- package/src/styles/ConceptLinkTags.less +10 -0
- package/src/reducers/__tests__/creatingRelation.spec.js +0 -25
- package/src/reducers/creatingRelation.js +0 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/lm",
|
|
3
|
-
"version": "5.8.
|
|
3
|
+
"version": "5.8.2",
|
|
4
4
|
"description": "Truedat Link Manager",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"jsnext:main": "src/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@testing-library/jest-dom": "^5.16.5",
|
|
35
35
|
"@testing-library/react": "^12.0.0",
|
|
36
36
|
"@testing-library/user-event": "^13.2.1",
|
|
37
|
-
"@truedat/test": "5.8.
|
|
37
|
+
"@truedat/test": "5.8.2",
|
|
38
38
|
"babel-jest": "^28.1.0",
|
|
39
39
|
"babel-plugin-dynamic-import-node": "^2.3.3",
|
|
40
40
|
"babel-plugin-lodash": "^3.3.4",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
]
|
|
87
87
|
},
|
|
88
88
|
"dependencies": {
|
|
89
|
-
"@truedat/core": "5.8.
|
|
89
|
+
"@truedat/core": "5.8.2",
|
|
90
90
|
"path-to-regexp": "^1.7.0",
|
|
91
91
|
"prop-types": "^15.8.1",
|
|
92
92
|
"react-graph-vis": "1.0.6",
|
|
@@ -107,5 +107,5 @@
|
|
|
107
107
|
"react-dom": ">= 16.8.6 < 17",
|
|
108
108
|
"semantic-ui-react": ">= 2.0.3 < 2.2"
|
|
109
109
|
},
|
|
110
|
-
"gitHead": "
|
|
110
|
+
"gitHead": "4eddd0a75147c3ce81b15c491edea1e414a33897"
|
|
111
111
|
}
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
clearSelectedRelationTags,
|
|
13
13
|
clearStructures,
|
|
14
14
|
} from "../routines";
|
|
15
|
-
import
|
|
15
|
+
import TagTypeDropdownSelector from "./TagTypeDropdownSelector";
|
|
16
16
|
|
|
17
17
|
const StructureSelector = React.lazy(() =>
|
|
18
18
|
import("@truedat/dd/components/StructureSelector")
|
|
@@ -56,12 +56,9 @@ export const ConceptStructureLinkForm = ({
|
|
|
56
56
|
return (
|
|
57
57
|
<>
|
|
58
58
|
<Divider hidden />
|
|
59
|
-
{!_.isEmpty(tagOptions)
|
|
60
|
-
<
|
|
61
|
-
|
|
62
|
-
options={tagOptions}
|
|
63
|
-
/>
|
|
64
|
-
)}
|
|
59
|
+
{!_.isEmpty(tagOptions) ? (
|
|
60
|
+
<TagTypeDropdownSelector options={tagOptions} />
|
|
61
|
+
) : null}
|
|
65
62
|
<StructureSelector
|
|
66
63
|
selectedStructure={selectedStructure}
|
|
67
64
|
onSelect={handleSelect}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
|
-
import React from "react";
|
|
2
|
+
import React, { useEffect, useState } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import { Form, Dropdown } from "semantic-ui-react";
|
|
5
5
|
import { FormattedMessage, useIntl } from "react-intl";
|
|
@@ -26,20 +26,37 @@ export const TagTypeDropdownSelector = ({
|
|
|
26
26
|
setSelectedRelationTags,
|
|
27
27
|
}) => {
|
|
28
28
|
const { formatMessage } = useIntl();
|
|
29
|
+
const [clearDropdown, setClearDropdown] = useState(false);
|
|
30
|
+
const [relationTag, setRelationTag] = useState(null);
|
|
31
|
+
|
|
32
|
+
useEffect(
|
|
33
|
+
() => {
|
|
34
|
+
setSelectedRelationTags({ selectedRelationTags: [] });
|
|
35
|
+
setClearDropdown(true);
|
|
36
|
+
},
|
|
37
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
38
|
+
[options]
|
|
39
|
+
);
|
|
29
40
|
|
|
30
41
|
const onChange = (_e, { value }) => {
|
|
31
42
|
setSelectedRelationTags({
|
|
32
43
|
selectedRelationTags: value === "" ? [] : [value],
|
|
33
44
|
});
|
|
45
|
+
setRelationTag(value);
|
|
46
|
+
setClearDropdown(false);
|
|
34
47
|
};
|
|
35
48
|
return (
|
|
36
49
|
<Form.Field>
|
|
37
|
-
<
|
|
38
|
-
<
|
|
39
|
-
|
|
50
|
+
<b>
|
|
51
|
+
<label>
|
|
52
|
+
<FormattedMessage id="relations.relationType" />
|
|
53
|
+
</label>
|
|
54
|
+
</b>
|
|
40
55
|
<div>
|
|
41
56
|
{options && (
|
|
42
57
|
<Dropdown
|
|
58
|
+
className="concept-link-dropdown"
|
|
59
|
+
value={clearDropdown ? "" : relationTag}
|
|
43
60
|
clearable
|
|
44
61
|
selection
|
|
45
62
|
options={formatOption(formatMessage)(options)}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createRelation, deleteRelation } from "../../routines";
|
|
2
|
+
import { handlingRelation } from "..";
|
|
3
|
+
|
|
4
|
+
const fooState = { foo: "bar" };
|
|
5
|
+
const payload = { data: fooState };
|
|
6
|
+
|
|
7
|
+
describe("reducers: handlingRelation", () => {
|
|
8
|
+
const initialState = false;
|
|
9
|
+
|
|
10
|
+
it("should provide the initial state", () => {
|
|
11
|
+
expect(handlingRelation(undefined, {})).toEqual(initialState);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("should handle the createRelation.SUCCESS action", () => {
|
|
15
|
+
expect(
|
|
16
|
+
handlingRelation(fooState, { type: createRelation.SUCCESS, payload })
|
|
17
|
+
).toEqual(fooState);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("should handle the createRelation.FAILURE action", () => {
|
|
21
|
+
expect(
|
|
22
|
+
handlingRelation(fooState, { type: createRelation.FAILURE })
|
|
23
|
+
).toEqual(false);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("should handle the deleteRelation.SUCCESS action", () => {
|
|
27
|
+
expect(
|
|
28
|
+
handlingRelation(fooState, {
|
|
29
|
+
type: deleteRelation.SUCCESS,
|
|
30
|
+
meta: { id: "1" },
|
|
31
|
+
})
|
|
32
|
+
).toEqual({ id: "1" });
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -35,11 +35,7 @@ describe("reducers: relations", () => {
|
|
|
35
35
|
it("should handle the deleteRelation.SUCCESS action", () => {
|
|
36
36
|
expect(
|
|
37
37
|
relations(data, { type: deleteRelation.SUCCESS, meta: { id: "1" } })
|
|
38
|
-
).toEqual(
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it("should handle the deleteRelation.FAILURE action", () => {
|
|
42
|
-
expect(relations(data, { type: deleteRelation.FAILURE })).toEqual(false);
|
|
38
|
+
).toEqual([]);
|
|
43
39
|
});
|
|
44
40
|
|
|
45
41
|
it("should handle the clearRelations.TRIGGER action", () => {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createRelation, deleteRelation } from "../routines";
|
|
2
|
+
|
|
3
|
+
export const handlingRelation = (state = false, { type, payload, meta }) => {
|
|
4
|
+
switch (type) {
|
|
5
|
+
case createRelation.SUCCESS:
|
|
6
|
+
return payload.data;
|
|
7
|
+
case createRelation.FAILURE:
|
|
8
|
+
return false;
|
|
9
|
+
case deleteRelation.SUCCESS: {
|
|
10
|
+
return meta;
|
|
11
|
+
}
|
|
12
|
+
case deleteRelation.FAILURE: {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
default:
|
|
16
|
+
return state;
|
|
17
|
+
}
|
|
18
|
+
};
|
package/src/reducers/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { handlingRelation } from "./handlingRelation";
|
|
2
2
|
import { selectedRelationTags } from "./selectedRelationTags";
|
|
3
3
|
import { relations } from "./relations";
|
|
4
4
|
import { relationsActions } from "./relationsActions";
|
|
@@ -10,7 +10,7 @@ import { relationTags } from "./relationTags";
|
|
|
10
10
|
import { relationTagsLoading } from "./relationTagsLoading";
|
|
11
11
|
|
|
12
12
|
export {
|
|
13
|
-
|
|
13
|
+
handlingRelation,
|
|
14
14
|
selectedRelationTags,
|
|
15
15
|
relations,
|
|
16
16
|
relationsActions,
|
|
@@ -19,5 +19,5 @@ export {
|
|
|
19
19
|
relationsLoading,
|
|
20
20
|
relationRedirect,
|
|
21
21
|
relationTags,
|
|
22
|
-
relationTagsLoading
|
|
22
|
+
relationTagsLoading,
|
|
23
23
|
};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
fetchRelations,
|
|
4
|
+
clearRelations,
|
|
5
|
+
createRelation,
|
|
6
|
+
deleteRelation,
|
|
7
|
+
} from "../routines";
|
|
3
8
|
|
|
4
9
|
const initialState = [];
|
|
5
10
|
|
|
@@ -19,11 +24,13 @@ const relations = (state = initialState, { type, payload, meta }) => {
|
|
|
19
24
|
return initialState;
|
|
20
25
|
case fetchRelations.SUCCESS:
|
|
21
26
|
return _.flow(_.propOr([], "data"), _.map(pickFields))(payload);
|
|
27
|
+
|
|
28
|
+
case createRelation.SUCCESS:
|
|
29
|
+
return [...state, payload.data];
|
|
30
|
+
|
|
22
31
|
case deleteRelation.SUCCESS: {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
case deleteRelation.FAILURE: {
|
|
26
|
-
return false;
|
|
32
|
+
const { id } = meta;
|
|
33
|
+
return _.reject(_.propEq("id", id))(state);
|
|
27
34
|
}
|
|
28
35
|
case clearRelations.TRIGGER:
|
|
29
36
|
return initialState;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { createRelation } from "../../routines";
|
|
2
|
-
import { creatingRelation } from "..";
|
|
3
|
-
|
|
4
|
-
const fooState = { foo: "bar" };
|
|
5
|
-
const payload = { data: fooState };
|
|
6
|
-
|
|
7
|
-
describe("reducers: creatingRelation", () => {
|
|
8
|
-
const initialState = false;
|
|
9
|
-
|
|
10
|
-
it("should provide the initial state", () => {
|
|
11
|
-
expect(creatingRelation(undefined, {})).toEqual(initialState);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it("should handle the createRelation.SUCCESS action", () => {
|
|
15
|
-
expect(
|
|
16
|
-
creatingRelation(fooState, { type: createRelation.SUCCESS, payload })
|
|
17
|
-
).toEqual(fooState);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it("should handle the createRelation.FAILURE action", () => {
|
|
21
|
-
expect(
|
|
22
|
-
creatingRelation(fooState, { type: createRelation.FAILURE })
|
|
23
|
-
).toEqual(false);
|
|
24
|
-
});
|
|
25
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { createRelation } from "../routines";
|
|
2
|
-
|
|
3
|
-
export const creatingRelation = (state = false, { type, payload }) => {
|
|
4
|
-
switch (type) {
|
|
5
|
-
case createRelation.SUCCESS:
|
|
6
|
-
return payload.data;
|
|
7
|
-
case createRelation.FAILURE:
|
|
8
|
-
return false;
|
|
9
|
-
default:
|
|
10
|
-
return state;
|
|
11
|
-
}
|
|
12
|
-
};
|