@truedat/bg 7.14.2 → 7.14.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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/bg",
|
|
3
|
-
"version": "7.14.
|
|
3
|
+
"version": "7.14.4",
|
|
4
4
|
"description": "Truedat Web Business Glossary",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@testing-library/jest-dom": "^6.6.3",
|
|
49
49
|
"@testing-library/react": "^16.3.0",
|
|
50
50
|
"@testing-library/user-event": "^14.6.1",
|
|
51
|
-
"@truedat/test": "7.14.
|
|
51
|
+
"@truedat/test": "7.14.3",
|
|
52
52
|
"identity-obj-proxy": "^3.0.0",
|
|
53
53
|
"jest": "^29.7.0",
|
|
54
54
|
"redux-saga-test-plan": "^4.0.6"
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"semantic-ui-react": "^3.0.0-beta.2",
|
|
82
82
|
"swr": "^2.3.3"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "ff4102dd37ec8de3894938db2f3ed8a482adf2ca"
|
|
85
85
|
}
|
|
@@ -38,13 +38,6 @@ export const ConceptTabs = ({
|
|
|
38
38
|
const rulesActive = useActiveRoute(CONCEPT_RULES);
|
|
39
39
|
const implementationsActive = useActiveRoute(CONCEPT_LINKS_IMPLEMENTATIONS);
|
|
40
40
|
const structureLinksActive = useActiveRoute(CONCEPT_LINKS_STRUCTURES);
|
|
41
|
-
|
|
42
|
-
console.clear();
|
|
43
|
-
console.log("enableQualityRules", enableQualityRules);
|
|
44
|
-
console.log("manageQualityRule", manageQualityRule);
|
|
45
|
-
console.log("viewQualityRule", viewQualityRule);
|
|
46
|
-
console.log("isAdmin", isAdmin);
|
|
47
|
-
console.log("rule_count", concept.rule_count);
|
|
48
41
|
|
|
49
42
|
return _.isEmpty(concept) ? null : (
|
|
50
43
|
<Menu attached="top" pointing secondary tabular>
|
|
@@ -90,15 +83,15 @@ export const ConceptTabs = ({
|
|
|
90
83
|
{(!emptyImplementationLinks ||
|
|
91
84
|
createImplementation ||
|
|
92
85
|
createRawImplementation) && (
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
86
|
+
<Menu.Item
|
|
87
|
+
active={implementationsActive}
|
|
88
|
+
as={Link}
|
|
89
|
+
to={linkTo.CONCEPT_LINKS_IMPLEMENTATIONS(concept)}
|
|
90
|
+
replace
|
|
91
|
+
>
|
|
92
|
+
<FormattedMessage id="tabs.bg.qualityImplementations" />
|
|
93
|
+
</Menu.Item>
|
|
94
|
+
)}
|
|
102
95
|
<Menu.Item
|
|
103
96
|
active={archiveActive}
|
|
104
97
|
as={Link}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
2
|
+
import { useEffect, useState, useRef } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import { connect } from "react-redux";
|
|
5
5
|
import {
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
EMPTY,
|
|
25
25
|
} from "@truedat/lm/services/relationGraphTraversal";
|
|
26
26
|
import { RelationGraphDepth } from "@truedat/lm/components";
|
|
27
|
+
import { config } from "@truedat/core/truedatConfig";
|
|
27
28
|
import { getConceptToConceptRelations } from "../selectors/getConceptRelations";
|
|
28
29
|
|
|
29
30
|
import ConceptRelationActions from "./ConceptRelationActions";
|
|
@@ -57,9 +58,32 @@ export const ConceptRelations = ({
|
|
|
57
58
|
|
|
58
59
|
const navigate = useNavigate();
|
|
59
60
|
const location = useLocation();
|
|
61
|
+
const hasAppliedConfig = useRef(false);
|
|
62
|
+
|
|
60
63
|
const [graphRender, setGraphRender] = useState(
|
|
61
64
|
_.propOr(true, "state.show_graph")(location) && !_.isEmpty(conceptRelations)
|
|
62
65
|
);
|
|
66
|
+
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (_.isEmpty(conceptRelations) || hasAppliedConfig.current) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const locationShowGraph = _.prop("state.show_graph")(location);
|
|
73
|
+
if (!_.isUndefined(locationShowGraph)) {
|
|
74
|
+
setGraphRender(locationShowGraph);
|
|
75
|
+
} else {
|
|
76
|
+
const renderMode = config?.RelatedConceptsActiveRenderMode;
|
|
77
|
+
// If renderMode is undefined, keep the default value (true)
|
|
78
|
+
if (renderMode === "list") {
|
|
79
|
+
setGraphRender(false);
|
|
80
|
+
} else if (renderMode === "graph") {
|
|
81
|
+
setGraphRender(true);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
hasAppliedConfig.current = true;
|
|
85
|
+
}, [conceptRelations, location]);
|
|
86
|
+
|
|
63
87
|
const navigateToConcept = ({ resource_id }, emptyEdges) => {
|
|
64
88
|
navigate(
|
|
65
89
|
linkTo.CONCEPT_LINKS_CONCEPTS({
|
|
@@ -1,23 +1,186 @@
|
|
|
1
1
|
import { render, waitForLoad } from "@truedat/test/render";
|
|
2
2
|
import { ConceptRelations } from "../ConceptRelations";
|
|
3
|
+
import { setConfig } from "@truedat/core/truedatConfig";
|
|
4
|
+
|
|
5
|
+
const mockUseLocation = jest.fn(() => ({ pathname: "/bar" }));
|
|
6
|
+
const mockUseNavigate = jest.fn(() => jest.fn());
|
|
3
7
|
|
|
4
8
|
jest.mock("react-router", () => ({
|
|
5
9
|
...jest.requireActual("react-router"),
|
|
6
|
-
useLocation: () => (
|
|
7
|
-
useNavigate: () =>
|
|
10
|
+
useLocation: () => mockUseLocation(),
|
|
11
|
+
useNavigate: () => mockUseNavigate(),
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
jest.mock("@truedat/lm/components", () => ({
|
|
15
|
+
RelationGraph: () => <div data-testid="relation-graph">RelationGraph</div>,
|
|
16
|
+
RelationGraphDepth: () => (
|
|
17
|
+
<div data-testid="relation-graph-depth">RelationGraphDepth</div>
|
|
18
|
+
),
|
|
8
19
|
}));
|
|
9
20
|
|
|
10
21
|
describe("<ConceptRelations />", () => {
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
setConfig({});
|
|
24
|
+
mockUseLocation.mockReturnValue({ pathname: "/bar" });
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
afterEach(() => {
|
|
28
|
+
setConfig({});
|
|
29
|
+
jest.clearAllMocks();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const baseState = {
|
|
33
|
+
concept: { business_concept_id: 1 },
|
|
34
|
+
conceptActions: {},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const baseProps = {
|
|
38
|
+
concept: { business_concept_id: 1 },
|
|
39
|
+
conceptRelations: [
|
|
40
|
+
{
|
|
41
|
+
id: 1,
|
|
42
|
+
name: "Related Concept",
|
|
43
|
+
tags: [],
|
|
44
|
+
context: {},
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
relationsGraph: {
|
|
48
|
+
nodes: [{ id: "business_concept:1" }],
|
|
49
|
+
edges: [],
|
|
50
|
+
},
|
|
51
|
+
initialDepth: Infinity,
|
|
52
|
+
visible: true,
|
|
53
|
+
};
|
|
54
|
+
|
|
11
55
|
it("matches the latest snapshot", async () => {
|
|
12
56
|
const props = {
|
|
13
|
-
|
|
14
|
-
conceptRelationsLoading: false,
|
|
57
|
+
...baseProps,
|
|
15
58
|
conceptRelations: [],
|
|
16
59
|
relationsGraph: {},
|
|
17
60
|
};
|
|
18
61
|
|
|
19
|
-
const rendered = render(<ConceptRelations {...props}
|
|
62
|
+
const rendered = render(<ConceptRelations {...props} />, {
|
|
63
|
+
state: baseState,
|
|
64
|
+
});
|
|
20
65
|
await waitForLoad(rendered);
|
|
21
66
|
expect(rendered.container).toMatchSnapshot();
|
|
22
67
|
});
|
|
68
|
+
|
|
69
|
+
it("activates graph button when RelatedConceptsActiveRenderMode is graph", async () => {
|
|
70
|
+
setConfig({ RelatedConceptsActiveRenderMode: "graph" });
|
|
71
|
+
|
|
72
|
+
const rendered = render(<ConceptRelations {...baseProps} />, {
|
|
73
|
+
state: baseState,
|
|
74
|
+
});
|
|
75
|
+
await waitForLoad(rendered);
|
|
76
|
+
|
|
77
|
+
expect(
|
|
78
|
+
rendered.container.querySelector('button[data-tooltip*="maps"]')
|
|
79
|
+
).toHaveClass("active");
|
|
80
|
+
expect(
|
|
81
|
+
rendered.container.querySelector('button[data-tooltip*="list"]')
|
|
82
|
+
).not.toHaveClass("active");
|
|
83
|
+
expect(rendered.getByTestId("relation-graph")).toBeInTheDocument();
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("activates list button when RelatedConceptsActiveRenderMode is list", async () => {
|
|
87
|
+
setConfig({ RelatedConceptsActiveRenderMode: "list" });
|
|
88
|
+
|
|
89
|
+
const rendered = render(<ConceptRelations {...baseProps} />, {
|
|
90
|
+
state: baseState,
|
|
91
|
+
});
|
|
92
|
+
await waitForLoad(rendered);
|
|
93
|
+
|
|
94
|
+
expect(
|
|
95
|
+
rendered.container.querySelector('button[data-tooltip*="list"]')
|
|
96
|
+
).toHaveClass("active");
|
|
97
|
+
expect(
|
|
98
|
+
rendered.container.querySelector('button[data-tooltip*="maps"]')
|
|
99
|
+
).not.toHaveClass("active");
|
|
100
|
+
expect(rendered.queryByTestId("relation-graph")).not.toBeInTheDocument();
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it("shows graph view by default when RelatedConceptsActiveRenderMode is not set", async () => {
|
|
104
|
+
setConfig({});
|
|
105
|
+
|
|
106
|
+
const rendered = render(<ConceptRelations {...baseProps} />, {
|
|
107
|
+
state: baseState,
|
|
108
|
+
});
|
|
109
|
+
await waitForLoad(rendered);
|
|
110
|
+
|
|
111
|
+
expect(
|
|
112
|
+
rendered.container.querySelector('button[data-tooltip*="maps"]')
|
|
113
|
+
).toHaveClass("active");
|
|
114
|
+
expect(
|
|
115
|
+
rendered.container.querySelector('button[data-tooltip*="list"]')
|
|
116
|
+
).not.toHaveClass("active");
|
|
117
|
+
expect(rendered.getByTestId("relation-graph")).toBeInTheDocument();
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it("prioritizes location.state.show_graph over RelatedConceptsActiveRenderMode", async () => {
|
|
121
|
+
setConfig({ RelatedConceptsActiveRenderMode: "graph" });
|
|
122
|
+
mockUseLocation.mockReturnValue({
|
|
123
|
+
pathname: "/bar",
|
|
124
|
+
state: { show_graph: false },
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const rendered = render(<ConceptRelations {...baseProps} />, {
|
|
128
|
+
state: baseState,
|
|
129
|
+
});
|
|
130
|
+
await waitForLoad(rendered);
|
|
131
|
+
|
|
132
|
+
expect(
|
|
133
|
+
rendered.container.querySelector('button[data-tooltip*="list"]')
|
|
134
|
+
).toHaveClass("active");
|
|
135
|
+
expect(
|
|
136
|
+
rendered.container.querySelector('button[data-tooltip*="maps"]')
|
|
137
|
+
).not.toHaveClass("active");
|
|
138
|
+
expect(rendered.queryByTestId("relation-graph")).not.toBeInTheDocument();
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it("prioritizes location.state.show_graph true over RelatedConceptsActiveRenderMode list", async () => {
|
|
142
|
+
setConfig({ RelatedConceptsActiveRenderMode: "list" });
|
|
143
|
+
mockUseLocation.mockReturnValue({
|
|
144
|
+
pathname: "/bar",
|
|
145
|
+
state: { show_graph: true },
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
const rendered = render(<ConceptRelations {...baseProps} />, {
|
|
149
|
+
state: baseState,
|
|
150
|
+
});
|
|
151
|
+
await waitForLoad(rendered);
|
|
152
|
+
|
|
153
|
+
expect(
|
|
154
|
+
rendered.container.querySelector('button[data-tooltip*="maps"]')
|
|
155
|
+
).toHaveClass("active");
|
|
156
|
+
expect(
|
|
157
|
+
rendered.container.querySelector('button[data-tooltip*="list"]')
|
|
158
|
+
).not.toHaveClass("active");
|
|
159
|
+
expect(rendered.getByTestId("relation-graph")).toBeInTheDocument();
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it("applies configuration when conceptRelations loads after initial render", async () => {
|
|
163
|
+
setConfig({ RelatedConceptsActiveRenderMode: "list" });
|
|
164
|
+
|
|
165
|
+
const propsWithoutRelations = {
|
|
166
|
+
...baseProps,
|
|
167
|
+
conceptRelations: [],
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const rendered = render(<ConceptRelations {...propsWithoutRelations} />, {
|
|
171
|
+
state: baseState,
|
|
172
|
+
});
|
|
173
|
+
await waitForLoad(rendered);
|
|
174
|
+
|
|
175
|
+
expect(
|
|
176
|
+
rendered.container.querySelector('button[data-tooltip*="maps"]')
|
|
177
|
+
).not.toBeInTheDocument();
|
|
178
|
+
|
|
179
|
+
rendered.rerender(<ConceptRelations {...baseProps} />);
|
|
180
|
+
await waitForLoad(rendered);
|
|
181
|
+
|
|
182
|
+
expect(
|
|
183
|
+
rendered.container.querySelector('button[data-tooltip*="list"]')
|
|
184
|
+
).toHaveClass("active");
|
|
185
|
+
});
|
|
23
186
|
});
|