@truedat/bg 7.9.0 → 7.9.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/concepts/components/Concept.js +3 -4
- package/src/concepts/components/__tests__/__snapshots__/Concept.spec.js.snap +78 -0
- package/src/hooks/useDomains.js +17 -1
- package/src/taxonomy/api.js +2 -1
- package/src/taxonomy/components/DomainForm.js +2 -2
- package/src/taxonomy/components/EditDomain.js +10 -2
- package/src/taxonomy/components/__tests__/DomainForm.spec.js +7 -2
- package/src/taxonomy/components/__tests__/EditDomain.spec.js +8 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/bg",
|
|
3
|
-
"version": "7.9.
|
|
3
|
+
"version": "7.9.2",
|
|
4
4
|
"description": "Truedat Web Business Glossary",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -48,14 +48,14 @@
|
|
|
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.9.
|
|
51
|
+
"@truedat/test": "7.9.2",
|
|
52
52
|
"identity-obj-proxy": "^3.0.0",
|
|
53
53
|
"jest": "^29.7.0",
|
|
54
54
|
"redux-saga-test-plan": "^4.0.6"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@apollo/client": "^3.13.8",
|
|
58
|
-
"axios": "^1.
|
|
58
|
+
"axios": "^1.12.0",
|
|
59
59
|
"file-saver": "^2.0.5",
|
|
60
60
|
"graphql": "^16.11.0",
|
|
61
61
|
"is-hotkey": "^0.2.0",
|
|
@@ -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": "245c4c2824083bbae4422b92b552b667160f8e93"
|
|
85
85
|
}
|
|
@@ -95,7 +95,7 @@ export const Concept = ({ id, concept }) => {
|
|
|
95
95
|
)(locales);
|
|
96
96
|
|
|
97
97
|
const selectedContent = i18nConcept[selectedLang]?.content || concept.content;
|
|
98
|
-
|
|
98
|
+
|
|
99
99
|
return (
|
|
100
100
|
<>
|
|
101
101
|
<ConceptCrumbs />
|
|
@@ -124,10 +124,9 @@ export const Concept = ({ id, concept }) => {
|
|
|
124
124
|
</Segment>
|
|
125
125
|
<Routes>
|
|
126
126
|
<Route
|
|
127
|
-
|
|
128
|
-
path={CONCEPT_VERSION}
|
|
127
|
+
path= ""
|
|
129
128
|
element={
|
|
130
|
-
|
|
129
|
+
<Segment>
|
|
131
130
|
<Comments />
|
|
132
131
|
</Segment>
|
|
133
132
|
}
|
|
@@ -195,6 +195,45 @@ exports[`<Concept /> matches the latest snapshot 1`] = `
|
|
|
195
195
|
</div>
|
|
196
196
|
</div>
|
|
197
197
|
</div>
|
|
198
|
+
<div
|
|
199
|
+
class="ui segment"
|
|
200
|
+
>
|
|
201
|
+
<div
|
|
202
|
+
class="ui comments"
|
|
203
|
+
>
|
|
204
|
+
<h3
|
|
205
|
+
class="ui dividing header"
|
|
206
|
+
>
|
|
207
|
+
comments.header
|
|
208
|
+
</h3>
|
|
209
|
+
<form
|
|
210
|
+
class="ui reply form"
|
|
211
|
+
>
|
|
212
|
+
<div
|
|
213
|
+
class="field"
|
|
214
|
+
>
|
|
215
|
+
<textarea
|
|
216
|
+
rows="3"
|
|
217
|
+
/>
|
|
218
|
+
</div>
|
|
219
|
+
<div
|
|
220
|
+
class="actions"
|
|
221
|
+
>
|
|
222
|
+
<button
|
|
223
|
+
class="ui icon primary disabled left labeled button"
|
|
224
|
+
disabled=""
|
|
225
|
+
tabindex="-1"
|
|
226
|
+
>
|
|
227
|
+
<i
|
|
228
|
+
aria-hidden="true"
|
|
229
|
+
class="edit icon"
|
|
230
|
+
/>
|
|
231
|
+
comments.actions.new
|
|
232
|
+
</button>
|
|
233
|
+
</div>
|
|
234
|
+
</form>
|
|
235
|
+
</div>
|
|
236
|
+
</div>
|
|
198
237
|
</div>
|
|
199
238
|
<div
|
|
200
239
|
class="four wide column"
|
|
@@ -546,6 +585,45 @@ exports[`<Concept /> matches the latest snapshot with grantView activated 1`] =
|
|
|
546
585
|
</div>
|
|
547
586
|
</div>
|
|
548
587
|
</div>
|
|
588
|
+
<div
|
|
589
|
+
class="ui segment"
|
|
590
|
+
>
|
|
591
|
+
<div
|
|
592
|
+
class="ui comments"
|
|
593
|
+
>
|
|
594
|
+
<h3
|
|
595
|
+
class="ui dividing header"
|
|
596
|
+
>
|
|
597
|
+
comments.header
|
|
598
|
+
</h3>
|
|
599
|
+
<form
|
|
600
|
+
class="ui reply form"
|
|
601
|
+
>
|
|
602
|
+
<div
|
|
603
|
+
class="field"
|
|
604
|
+
>
|
|
605
|
+
<textarea
|
|
606
|
+
rows="3"
|
|
607
|
+
/>
|
|
608
|
+
</div>
|
|
609
|
+
<div
|
|
610
|
+
class="actions"
|
|
611
|
+
>
|
|
612
|
+
<button
|
|
613
|
+
class="ui icon primary disabled left labeled button"
|
|
614
|
+
disabled=""
|
|
615
|
+
tabindex="-1"
|
|
616
|
+
>
|
|
617
|
+
<i
|
|
618
|
+
aria-hidden="true"
|
|
619
|
+
class="edit icon"
|
|
620
|
+
/>
|
|
621
|
+
comments.actions.new
|
|
622
|
+
</button>
|
|
623
|
+
</div>
|
|
624
|
+
</form>
|
|
625
|
+
</div>
|
|
626
|
+
</div>
|
|
549
627
|
</div>
|
|
550
628
|
<div
|
|
551
629
|
class="four wide column"
|
package/src/hooks/useDomains.js
CHANGED
|
@@ -8,7 +8,11 @@ import {
|
|
|
8
8
|
apiJsonPatch,
|
|
9
9
|
apiJsonDelete,
|
|
10
10
|
} from "@truedat/core/services/api";
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
API_DOMAINS,
|
|
13
|
+
API_DOMAIN,
|
|
14
|
+
API_DOMAIN_PARENTABLE_IDS,
|
|
15
|
+
} from "../taxonomy/api";
|
|
12
16
|
|
|
13
17
|
export const useDomains = () => {
|
|
14
18
|
const toApiPath = compile(API_DOMAINS, "api");
|
|
@@ -34,6 +38,18 @@ export const useDomain = (id) => {
|
|
|
34
38
|
};
|
|
35
39
|
};
|
|
36
40
|
|
|
41
|
+
export const useDomainParentableIds = (id) => {
|
|
42
|
+
const toApiPath = compile(API_DOMAIN_PARENTABLE_IDS, "api");
|
|
43
|
+
const url = toApiPath({ id: `${id}` });
|
|
44
|
+
const { data, error } = useSWR(url, apiJson);
|
|
45
|
+
return {
|
|
46
|
+
data: data?.data?.data,
|
|
47
|
+
actions: data?.data?._actions,
|
|
48
|
+
error,
|
|
49
|
+
loading: !error && !data,
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
37
53
|
export const useDomainCreate = () => {
|
|
38
54
|
const toApiPath = compile(API_DOMAINS, "api");
|
|
39
55
|
const url = toApiPath();
|
package/src/taxonomy/api.js
CHANGED
|
@@ -46,7 +46,7 @@ const DEFAULTS = {
|
|
|
46
46
|
domain_group: null,
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
export const DomainForm = ({ domain = {}, onSubmit }) => {
|
|
49
|
+
export const DomainForm = ({ domain = {}, parentableIds = [], onSubmit }) => {
|
|
50
50
|
const { data: domains } = useDomains();
|
|
51
51
|
const { formatMessage } = useIntl();
|
|
52
52
|
const { handleSubmit, control, formState, watch } = useForm({
|
|
@@ -67,7 +67,6 @@ export const DomainForm = ({ domain = {}, onSubmit }) => {
|
|
|
67
67
|
domain?.domain_group?.status === "root" || !domain?.domain_group;
|
|
68
68
|
|
|
69
69
|
const { errors, isDirty, isValid } = formState;
|
|
70
|
-
const parentableIds = domain.parentable_ids || [];
|
|
71
70
|
const domainParentOptions =
|
|
72
71
|
domain?.id && domains ? getDomainParentOptions(parentableIds)(domains) : [];
|
|
73
72
|
|
|
@@ -232,6 +231,7 @@ export const DomainForm = ({ domain = {}, onSubmit }) => {
|
|
|
232
231
|
|
|
233
232
|
DomainForm.propTypes = {
|
|
234
233
|
domain: PropTypes.object,
|
|
234
|
+
parentableIds: PropTypes.array,
|
|
235
235
|
onSubmit: PropTypes.func.isRequired,
|
|
236
236
|
};
|
|
237
237
|
|
|
@@ -8,11 +8,15 @@ import { linkTo } from "@truedat/core/routes";
|
|
|
8
8
|
import { useQuery } from "@apollo/client";
|
|
9
9
|
import { DOMAINS_QUERY } from "@truedat/core/api/queries";
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
useDomainUpdate,
|
|
13
|
+
useDomainParentableIds,
|
|
14
|
+
} from "../../hooks/useDomains";
|
|
12
15
|
import DomainForm from "./DomainForm";
|
|
13
16
|
|
|
14
17
|
export const EditDomain = ({ domain }) => {
|
|
15
18
|
const { trigger: updateDomain } = useDomainUpdate(domain.id);
|
|
19
|
+
const { data: parentableIds } = useDomainParentableIds(domain.id);
|
|
16
20
|
|
|
17
21
|
const navigate = useNavigate();
|
|
18
22
|
const { client } = useQuery(DOMAINS_QUERY, {
|
|
@@ -36,7 +40,11 @@ export const EditDomain = ({ domain }) => {
|
|
|
36
40
|
<FormattedMessage id="domain.actions.edit.header" />
|
|
37
41
|
</Header.Content>
|
|
38
42
|
</Header>
|
|
39
|
-
<DomainForm
|
|
43
|
+
<DomainForm
|
|
44
|
+
onSubmit={handleUpdateDomain}
|
|
45
|
+
domain={domain}
|
|
46
|
+
parentableIds={parentableIds}
|
|
47
|
+
/>
|
|
40
48
|
</Container>
|
|
41
49
|
);
|
|
42
50
|
};
|
|
@@ -174,10 +174,15 @@ describe("<DomainForm />", () => {
|
|
|
174
174
|
|
|
175
175
|
it("should generate domain parent options", async () => {
|
|
176
176
|
useDomains.mockImplementation(() => ({ data }));
|
|
177
|
-
const domain = { id: 2
|
|
177
|
+
const domain = { id: 2 };
|
|
178
|
+
const parentableIds = [1, 5, 6, 7];
|
|
178
179
|
|
|
179
180
|
const rendered = render(
|
|
180
|
-
<DomainForm
|
|
181
|
+
<DomainForm
|
|
182
|
+
domain={domain}
|
|
183
|
+
parentableIds={parentableIds}
|
|
184
|
+
onSubmit={jest.fn()}
|
|
185
|
+
/>
|
|
181
186
|
);
|
|
182
187
|
await waitForLoad(rendered);
|
|
183
188
|
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { render, waitForLoad } from "@truedat/test/render";
|
|
2
2
|
import { domainsMock } from "@truedat/test/mocks";
|
|
3
3
|
import { EditDomain } from "../EditDomain";
|
|
4
|
+
import { useDomainParentableIds } from "../../../hooks/useDomains";
|
|
4
5
|
|
|
5
|
-
jest.mock("../../../hooks/useDomains")
|
|
6
|
+
jest.mock("../../../hooks/useDomains", () => ({
|
|
7
|
+
...jest.requireActual("../../../hooks/useDomains"),
|
|
8
|
+
useDomainParentableIds: jest.fn(() => {}),
|
|
9
|
+
}));
|
|
6
10
|
|
|
7
11
|
const renderOpts = {
|
|
8
12
|
mocks: [
|
|
@@ -14,6 +18,9 @@ const renderOpts = {
|
|
|
14
18
|
};
|
|
15
19
|
|
|
16
20
|
describe("<EditDomain />", () => {
|
|
21
|
+
useDomainParentableIds.mockImplementation(() => ({
|
|
22
|
+
data: [],
|
|
23
|
+
}));
|
|
17
24
|
const domain = { id: 1, name: "nn", description: "dd" };
|
|
18
25
|
|
|
19
26
|
it("matches the latest snapshot", async () => {
|