@truedat/bg 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 +3 -3
- package/src/concepts/components/ConceptEdit.js +1 -0
- package/src/concepts/components/ConceptForm.js +30 -42
- package/src/concepts/components/__tests__/ConceptEdit.spec.js +5 -0
- package/src/concepts/components/__tests__/ConceptForm.spec.js +5 -0
- package/src/concepts/components/__tests__/__snapshots__/ConceptEdit.spec.js.snap +11 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/bg",
|
|
3
|
-
"version": "8.8.
|
|
3
|
+
"version": "8.8.8",
|
|
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.8.
|
|
57
|
+
"@truedat/test": "8.8.8",
|
|
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": "850b1a20250c39f4781aea0174aeebd383898eea"
|
|
91
91
|
}
|
|
@@ -13,9 +13,6 @@ import {
|
|
|
13
13
|
Icon,
|
|
14
14
|
} from "semantic-ui-react";
|
|
15
15
|
import { useIntl, FormattedMessage } from "react-intl";
|
|
16
|
-
import { useAvailabilityCheck } from "@truedat/ai/hooks/useSuggestions";
|
|
17
|
-
import { apiJsonPost } from "@truedat/core/services/api";
|
|
18
|
-
import { API_SUGGESTIONS_REQUEST } from "@truedat/ai/api";
|
|
19
16
|
import {
|
|
20
17
|
DomainSelector,
|
|
21
18
|
LanguagesTabs,
|
|
@@ -38,6 +35,7 @@ const ConceptForm = ({
|
|
|
38
35
|
i18nConcept,
|
|
39
36
|
loading,
|
|
40
37
|
onSubmit,
|
|
38
|
+
resourceId,
|
|
41
39
|
setDomainId,
|
|
42
40
|
setI18nConcept,
|
|
43
41
|
setTemplate,
|
|
@@ -55,11 +53,9 @@ const ConceptForm = ({
|
|
|
55
53
|
} = useLanguage();
|
|
56
54
|
const [domains, setDomains] = useState();
|
|
57
55
|
const [domainsLoading, setDomainsLoading] = useState(true);
|
|
58
|
-
const [hasSuggestions, setHasSuggestions] = useState(false);
|
|
59
56
|
const [canTranslate, setCanTranslate] = useState(false);
|
|
60
57
|
const [showTranslationModal, setShowTranslationModal] = useState(false);
|
|
61
58
|
const isNonEmptyString = _.flow(_.trim, _.negate(_.isEmpty));
|
|
62
|
-
const { trigger: checkSuggestionAvailability } = useAvailabilityCheck();
|
|
63
59
|
const templateId = template?.id;
|
|
64
60
|
const { trigger: checkTranslationAvailability } = useTranslatableCheck();
|
|
65
61
|
const { translatable: translatableFields } =
|
|
@@ -96,13 +92,6 @@ const ConceptForm = ({
|
|
|
96
92
|
|
|
97
93
|
useEffect(() => {
|
|
98
94
|
if (!disable_td_ai && templateId && domainId) {
|
|
99
|
-
checkSuggestionAvailability({
|
|
100
|
-
template_id: templateId,
|
|
101
|
-
domain_ids: [domainId],
|
|
102
|
-
resource_type: "business_concept",
|
|
103
|
-
}).then((res) =>
|
|
104
|
-
setHasSuggestions(_.get("data.data.status", res) === "ok"),
|
|
105
|
-
);
|
|
106
95
|
checkCanTranslate();
|
|
107
96
|
}
|
|
108
97
|
}, [templateId, domainId]);
|
|
@@ -116,18 +105,18 @@ const ConceptForm = ({
|
|
|
116
105
|
setDomainsLoading(false);
|
|
117
106
|
};
|
|
118
107
|
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
108
|
+
const domainName = _.get("name", _.find({ id: domainId }, domains));
|
|
109
|
+
const suggestionParams = {
|
|
110
|
+
resource_type: "business_concept",
|
|
111
|
+
resource_body: {
|
|
112
|
+
name: i18nConcept?.[defaultLang]?.name || "",
|
|
113
|
+
domain: domainName,
|
|
114
|
+
type: template?.name,
|
|
115
|
+
},
|
|
116
|
+
domain_ids: [domainId],
|
|
117
|
+
template_id: templateId,
|
|
118
|
+
language: defaultLang,
|
|
119
|
+
resource_id: resourceId ?? null,
|
|
131
120
|
};
|
|
132
121
|
|
|
133
122
|
const applySuggestions = (suggestions) => {
|
|
@@ -225,24 +214,22 @@ const ConceptForm = ({
|
|
|
225
214
|
</Segment>
|
|
226
215
|
</>
|
|
227
216
|
)}
|
|
228
|
-
|
|
229
|
-
<Grid>
|
|
230
|
-
<Grid.
|
|
231
|
-
<
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
</Grid>
|
|
245
|
-
)}
|
|
217
|
+
<Grid>
|
|
218
|
+
<Grid.Row columns={isMultilingual ? 2 : 1}>
|
|
219
|
+
<Grid.Column>
|
|
220
|
+
<SuggestionsWidget
|
|
221
|
+
suggestionParams={suggestionParams}
|
|
222
|
+
template={template}
|
|
223
|
+
applySuggestions={applySuggestions}
|
|
224
|
+
isModification
|
|
225
|
+
enableRequestButton={!_.isEmpty(i18nConcept[defaultLang]?.name)}
|
|
226
|
+
disabledButtonMessage={formatMessage({
|
|
227
|
+
id: "template.form.validation.name_required",
|
|
228
|
+
})}
|
|
229
|
+
/>
|
|
230
|
+
</Grid.Column>
|
|
231
|
+
</Grid.Row>
|
|
232
|
+
</Grid>
|
|
246
233
|
</>
|
|
247
234
|
);
|
|
248
235
|
|
|
@@ -370,6 +357,7 @@ ConceptForm.propTypes = {
|
|
|
370
357
|
template: PropTypes.object,
|
|
371
358
|
i18nConcept: PropTypes.object,
|
|
372
359
|
onSubmit: PropTypes.func,
|
|
360
|
+
resourceId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
373
361
|
setDomainId: PropTypes.func,
|
|
374
362
|
setI18nConcept: PropTypes.func,
|
|
375
363
|
setTemplate: PropTypes.func,
|
|
@@ -26,6 +26,11 @@ jest.mock("@truedat/ai/hooks/useTranslations", () => {
|
|
|
26
26
|
};
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
+
jest.mock("@truedat/ai/components/suggestions/SuggestionsWidget", () => ({
|
|
30
|
+
__esModule: true,
|
|
31
|
+
default: () => null,
|
|
32
|
+
}));
|
|
33
|
+
|
|
29
34
|
const template = {
|
|
30
35
|
id: 1,
|
|
31
36
|
name: "template1",
|
|
@@ -50,6 +50,11 @@ jest.mock("@truedat/ai/hooks/useTranslations", () => ({
|
|
|
50
50
|
})),
|
|
51
51
|
}));
|
|
52
52
|
|
|
53
|
+
jest.mock("@truedat/ai/components/suggestions/SuggestionsWidget", () => ({
|
|
54
|
+
__esModule: true,
|
|
55
|
+
default: () => null,
|
|
56
|
+
}));
|
|
57
|
+
|
|
53
58
|
const props = {
|
|
54
59
|
actionKey: "create",
|
|
55
60
|
domainId: 1,
|
|
@@ -41,6 +41,17 @@ exports[`<ConceptEdit /> matches the latest snapshot 1`] = `
|
|
|
41
41
|
</div>
|
|
42
42
|
</div>
|
|
43
43
|
</div>
|
|
44
|
+
<div
|
|
45
|
+
class="ui grid"
|
|
46
|
+
>
|
|
47
|
+
<div
|
|
48
|
+
class="one column row"
|
|
49
|
+
>
|
|
50
|
+
<div
|
|
51
|
+
class="column"
|
|
52
|
+
/>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
44
55
|
<div
|
|
45
56
|
class="ui grid"
|
|
46
57
|
>
|