@truedat/bg 8.8.7 → 8.9.0

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": "8.8.7",
3
+ "version": "8.9.0",
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.7",
57
+ "@truedat/test": "8.9.0",
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": "ece3f2e166776ff7827198a134bad5a28b029dc7"
90
+ "gitHead": "beff9d7e01556d63d42e54c9f7b641503ee658b2"
91
91
  }
@@ -63,6 +63,7 @@ export const ConceptEdit = ({
63
63
  <ConceptForm
64
64
  actionKey={actionKey}
65
65
  domainId={domain?.id}
66
+ resourceId={concept.business_concept_id}
66
67
  template={template}
67
68
  i18nConcept={i18nConcept}
68
69
  loading={templateLoading || localesLoading}
@@ -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 requestAiSuggestion = (callback) => {
120
- const domainName = _.get("name", _.find({ id: domainId }, domains));
121
- apiJsonPost(API_SUGGESTIONS_REQUEST, {
122
- resource_type: "business_concept",
123
- resource_body: {
124
- name: i18nConcept?.[defaultLang]?.name || "",
125
- domain: domainName,
126
- type: template?.name,
127
- },
128
- domain_ids: [domainId],
129
- template_id: templateId,
130
- }).then(callback);
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
- {hasSuggestions && (
229
- <Grid>
230
- <Grid.Row columns={isMultilingual ? 2 : 1}>
231
- <Grid.Column>
232
- <SuggestionsWidget
233
- requestAiSuggestion={requestAiSuggestion}
234
- template={template}
235
- applySuggestions={applySuggestions}
236
- isModification
237
- enableRequestButton={!_.isEmpty(i18nConcept[defaultLang]?.name)}
238
- disabledButtonMessage={formatMessage({
239
- id: "template.form.validation.name_required",
240
- })}
241
- />
242
- </Grid.Column>
243
- </Grid.Row>
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
  >