@truedat/bg 8.5.4 → 8.5.7

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.5.4",
3
+ "version": "8.5.7",
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.5.4",
57
+ "@truedat/test": "8.5.7",
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": "75272567eb3ec948a5cdeb8346ef9cacac58267f"
90
+ "gitHead": "871357888d97c203cf009a04878e0277cff6af9b"
91
91
  }
@@ -1,12 +1,13 @@
1
1
  import _ from "lodash/fp";
2
- import { Fragment, useState } from "react";
2
+ import { Fragment } from "react";
3
3
  import PropTypes from "prop-types";
4
4
  import { useIntl } from "react-intl";
5
5
  import { connect } from "react-redux";
6
- import { Button, Form, Popup } from "semantic-ui-react";
6
+ import { Button } from "semantic-ui-react";
7
7
  import { Link, useParams, useNavigate } from "react-router";
8
8
  import { linkTo } from "@truedat/core/routes";
9
9
  import { Checkbox } from "semantic-ui-react";
10
+ import SuggestLinkButton from "@truedat/ai/components/SuggestLinkButton";
10
11
 
11
12
  import ConceptLinkstRequestGrantButton from "./ConceptLinkstRequestGrantButton";
12
13
 
@@ -20,35 +21,6 @@ export const ConceptLinksActions = ({
20
21
  const { formatMessage } = useIntl();
21
22
  const params = useParams();
22
23
  const navigate = useNavigate();
23
- const [suggestOpen, setSuggestOpen] = useState(false);
24
- const [prompt, setPrompt] = useState("");
25
-
26
- const handleSuggestSubmit = () => {
27
- setSuggestOpen(false);
28
- navigate(linkTo.CONCEPT_LINKS_STRUCTURES_SUGGEST(params), {
29
- state: { prompt },
30
- });
31
- };
32
-
33
- const suggestPopupContent = (
34
- <Form style={{ minWidth: "300px" }}>
35
- <Form.Field>
36
- <label>{formatMessage({ id: "links.suggest.prompt.label" })}</label>
37
- <Form.Input
38
- value={prompt}
39
- onChange={(_, { value }) => setPrompt(value)}
40
- placeholder={formatMessage({
41
- id: "links.suggest.prompt.placeholder",
42
- })}
43
- />
44
- </Form.Field>
45
- <Button
46
- primary
47
- content={formatMessage({ id: "links.suggest.submit" })}
48
- onClick={handleSuggestSubmit}
49
- />
50
- </Form>
51
- );
52
24
 
53
25
  return createLinkUrl ? (
54
26
  <div style={{ float: "right" }}>
@@ -66,20 +38,11 @@ export const ConceptLinksActions = ({
66
38
  </Fragment>
67
39
  ) : null}
68
40
  {canSuggestLinks && (
69
- <Popup
70
- on="click"
71
- open={suggestOpen}
72
- onOpen={() => setSuggestOpen(true)}
73
- onClose={() => setSuggestOpen(false)}
74
- content={suggestPopupContent}
75
- position="bottom center"
76
- trigger={
77
- <Button
78
- secondary
79
- active={suggestOpen}
80
- icon="lightbulb outline"
81
- content={formatMessage({ id: "links.actions.suggest" })}
82
- />
41
+ <SuggestLinkButton
42
+ onSubmit={(prompt) =>
43
+ navigate(linkTo.CONCEPT_LINKS_STRUCTURES_SUGGEST(params), {
44
+ state: { prompt },
45
+ })
83
46
  }
84
47
  />
85
48
  )}
@@ -2,6 +2,10 @@ import { useSearchContext } from "@truedat/core/search/SearchContext";
2
2
  import { render, waitForLoad } from "@truedat/test/render";
3
3
  import ConceptLinksActions from "../ConceptLinksActions";
4
4
 
5
+ jest.mock("@truedat/ai/components/SuggestLinkButton", () =>
6
+ jest.fn(() => <div>MockSuggestLinkButton</div>)
7
+ );
8
+
5
9
  jest.mock("@truedat/core/search/SearchContext", () => {
6
10
  const originalModule = jest.requireActual(
7
11
  "@truedat/core/search/SearchContext"
@@ -61,4 +65,26 @@ describe("<ConceptLinksActions />", () => {
61
65
  await waitForLoad(rendered);
62
66
  expect(rendered.container).toMatchSnapshot();
63
67
  });
68
+
69
+ it("renders SuggestLinkButton when suggest_structure_link action is present", async () => {
70
+ useSearchContext.mockReturnValue({ searchData: { data: [] } });
71
+
72
+ const suggestRenderOpts = {
73
+ ...renderOpts,
74
+ state: {
75
+ ...renderOpts.state,
76
+ conceptActions: {
77
+ create_structure_link: true,
78
+ suggest_structure_link: true,
79
+ },
80
+ },
81
+ };
82
+
83
+ const rendered = render(
84
+ <ConceptLinksActions onGrantViewChange={jest.fn()} />,
85
+ suggestRenderOpts
86
+ );
87
+ await waitForLoad(rendered);
88
+ expect(rendered.getByText("MockSuggestLinkButton")).toBeInTheDocument();
89
+ });
64
90
  });