@truedat/dd 8.8.7 → 8.8.8
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/dd",
|
|
3
|
-
"version": "8.8.
|
|
3
|
+
"version": "8.8.8",
|
|
4
4
|
"description": "Truedat Web Data Dictionary",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@testing-library/jest-dom": "^6.6.3",
|
|
52
52
|
"@testing-library/react": "^16.3.0",
|
|
53
53
|
"@testing-library/user-event": "^14.6.1",
|
|
54
|
-
"@truedat/test": "8.8.
|
|
54
|
+
"@truedat/test": "8.8.8",
|
|
55
55
|
"identity-obj-proxy": "^3.0.0",
|
|
56
56
|
"jest": "^29.7.0",
|
|
57
57
|
"redux-saga-test-plan": "^4.0.6"
|
|
@@ -86,5 +86,5 @@
|
|
|
86
86
|
"svg-pan-zoom": "^3.6.2",
|
|
87
87
|
"swr": "^2.3.3"
|
|
88
88
|
},
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "850b1a20250c39f4781aea0174aeebd383898eea"
|
|
90
90
|
}
|
|
@@ -7,7 +7,6 @@ import { useIntl } from "react-intl";
|
|
|
7
7
|
import { HistoryBackButton } from "@truedat/core/components";
|
|
8
8
|
import { selectTemplate, selectDomains } from "@truedat/df/routines";
|
|
9
9
|
import { applyTemplate, validateContent } from "@truedat/df/utils";
|
|
10
|
-
import { apiJson } from "@truedat/core/services/api";
|
|
11
10
|
import SuggestionsWidget from "@truedat/ai/components/suggestions/SuggestionsWidget";
|
|
12
11
|
import { doStructureNoteAction } from "../routines";
|
|
13
12
|
import { getLatestDfContent } from "../selectors/getSortedStructureNotes";
|
|
@@ -29,9 +28,6 @@ export const StructureNotesEdit = ({
|
|
|
29
28
|
latestDfContent,
|
|
30
29
|
}) => {
|
|
31
30
|
const [content, setContent] = useState(latestDfContent);
|
|
32
|
-
const aiSuggestionsUrl = _.prop("_actions.ai_suggestions.href")(
|
|
33
|
-
structureNotes,
|
|
34
|
-
);
|
|
35
31
|
|
|
36
32
|
const isModification = !_.isEmpty(latestDfContent);
|
|
37
33
|
|
|
@@ -76,22 +72,28 @@ export const StructureNotesEdit = ({
|
|
|
76
72
|
setContent({ ...content, ...suggestions });
|
|
77
73
|
};
|
|
78
74
|
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
75
|
+
const suggestionParams = {
|
|
76
|
+
resource_type: "data_structure",
|
|
77
|
+
resource_body: {
|
|
78
|
+
name: structure.name || "",
|
|
79
|
+
domain: _.get("domains[0].name")(structure) || "",
|
|
80
|
+
type: template?.name,
|
|
81
|
+
},
|
|
82
|
+
domain_ids: structure.domain_ids,
|
|
83
|
+
template_id: template?.id,
|
|
84
|
+
language: locale,
|
|
85
|
+
resource_id: structure.id ?? null,
|
|
82
86
|
};
|
|
83
87
|
|
|
84
88
|
return (
|
|
85
89
|
<Segment attached="bottom">
|
|
86
90
|
<TemplateLoader id="templateloader" />
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
/>
|
|
94
|
-
) : null}
|
|
91
|
+
<SuggestionsWidget
|
|
92
|
+
suggestionParams={suggestionParams}
|
|
93
|
+
template={template}
|
|
94
|
+
applySuggestions={applySuggestions}
|
|
95
|
+
isModification={isModification}
|
|
96
|
+
/>
|
|
95
97
|
<Form>
|
|
96
98
|
<DynamicForm
|
|
97
99
|
onChange={setContent}
|
|
@@ -2,12 +2,22 @@ import userEvent from "@testing-library/user-event";
|
|
|
2
2
|
import { waitFor } from "@testing-library/react";
|
|
3
3
|
import { render, waitForLoad } from "@truedat/test/render";
|
|
4
4
|
import { applyTemplate } from "@truedat/df/utils";
|
|
5
|
+
import SuggestionsWidget from "@truedat/ai/components/suggestions/SuggestionsWidget";
|
|
5
6
|
import { StructureNotesEdit } from "../StructureNotesEdit";
|
|
6
7
|
|
|
8
|
+
jest.mock("@truedat/ai/components/suggestions/SuggestionsWidget", () => ({
|
|
9
|
+
__esModule: true,
|
|
10
|
+
default: jest.fn(() => null),
|
|
11
|
+
}));
|
|
12
|
+
|
|
7
13
|
describe("<StructureNotesEdit />", () => {
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
jest.clearAllMocks();
|
|
16
|
+
});
|
|
17
|
+
|
|
8
18
|
it("matches the latest snapshot", async () => {
|
|
9
19
|
const props = {
|
|
10
|
-
structure: { id: 1 },
|
|
20
|
+
structure: { id: 1, domain_ids: [1] },
|
|
11
21
|
template: { id: 2 },
|
|
12
22
|
doStructureNoteAction: () => {},
|
|
13
23
|
selectTemplate: () => {},
|
|
@@ -24,17 +34,19 @@ describe("<StructureNotesEdit />", () => {
|
|
|
24
34
|
expect(rendered.container).toMatchSnapshot();
|
|
25
35
|
});
|
|
26
36
|
|
|
27
|
-
it("
|
|
37
|
+
it("passes data_structure suggestion params to the widget", async () => {
|
|
28
38
|
const props = {
|
|
29
|
-
structure: {
|
|
30
|
-
|
|
39
|
+
structure: {
|
|
40
|
+
id: 7,
|
|
41
|
+
name: "my structure",
|
|
42
|
+
domain_ids: [3],
|
|
43
|
+
domains: [{ name: "my domain" }],
|
|
44
|
+
},
|
|
45
|
+
template: { id: 2, name: "my template" },
|
|
31
46
|
doStructureNoteAction: () => {},
|
|
32
47
|
selectTemplate: () => {},
|
|
33
48
|
selectDomain: () => {},
|
|
34
49
|
structureNotes: {
|
|
35
|
-
_actions: {
|
|
36
|
-
ai_suggestions: { href: "suggestion" },
|
|
37
|
-
},
|
|
38
50
|
structureNotes: [],
|
|
39
51
|
},
|
|
40
52
|
latestDfContent: { foo: { value: "bar", origin: "user" } },
|
|
@@ -43,7 +55,19 @@ describe("<StructureNotesEdit />", () => {
|
|
|
43
55
|
};
|
|
44
56
|
const rendered = render(<StructureNotesEdit {...props} />);
|
|
45
57
|
await waitForLoad(rendered);
|
|
46
|
-
|
|
58
|
+
|
|
59
|
+
await waitFor(() => expect(SuggestionsWidget).toHaveBeenCalled());
|
|
60
|
+
expect(SuggestionsWidget.mock.calls[0][0].suggestionParams).toMatchObject({
|
|
61
|
+
resource_type: "data_structure",
|
|
62
|
+
resource_id: 7,
|
|
63
|
+
template_id: 2,
|
|
64
|
+
domain_ids: [3],
|
|
65
|
+
resource_body: {
|
|
66
|
+
name: "my structure",
|
|
67
|
+
domain: "my domain",
|
|
68
|
+
type: "my template",
|
|
69
|
+
},
|
|
70
|
+
});
|
|
47
71
|
});
|
|
48
72
|
|
|
49
73
|
it("calls doStructureNoteAction when submit is clicked", async () => {
|
|
@@ -25,53 +25,3 @@ exports[`<StructureNotesEdit /> matches the latest snapshot 1`] = `
|
|
|
25
25
|
</div>
|
|
26
26
|
</div>
|
|
27
27
|
`;
|
|
28
|
-
|
|
29
|
-
exports[`<StructureNotesEdit /> matches the latest snapshot with ai suggestion action 1`] = `
|
|
30
|
-
<div>
|
|
31
|
-
<div
|
|
32
|
-
class="ui bottom attached segment"
|
|
33
|
-
>
|
|
34
|
-
<div
|
|
35
|
-
class="ui segment"
|
|
36
|
-
>
|
|
37
|
-
<div
|
|
38
|
-
class="ui container"
|
|
39
|
-
style="display: flex; justify-content: space-between;"
|
|
40
|
-
>
|
|
41
|
-
<h4>
|
|
42
|
-
<i
|
|
43
|
-
aria-hidden="true"
|
|
44
|
-
class="lightbulb icon"
|
|
45
|
-
/>
|
|
46
|
-
structure_note.ai_suggestion.header
|
|
47
|
-
</h4>
|
|
48
|
-
<div
|
|
49
|
-
class="ui hidden divider"
|
|
50
|
-
/>
|
|
51
|
-
<button
|
|
52
|
-
class="ui button"
|
|
53
|
-
>
|
|
54
|
-
actions.ai_suggestion
|
|
55
|
-
</button>
|
|
56
|
-
</div>
|
|
57
|
-
</div>
|
|
58
|
-
<form
|
|
59
|
-
class="ui form"
|
|
60
|
-
>
|
|
61
|
-
<button
|
|
62
|
-
class="ui primary button"
|
|
63
|
-
>
|
|
64
|
-
actions.save
|
|
65
|
-
</button>
|
|
66
|
-
<a
|
|
67
|
-
class="ui secondary button td-icon-text-control"
|
|
68
|
-
data-discover="true"
|
|
69
|
-
href="/"
|
|
70
|
-
role="button"
|
|
71
|
-
>
|
|
72
|
-
actions.cancel
|
|
73
|
-
</a>
|
|
74
|
-
</form>
|
|
75
|
-
</div>
|
|
76
|
-
</div>
|
|
77
|
-
`;
|