@truedat/dd 7.10.2 → 7.10.4

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": "7.10.2",
3
+ "version": "7.10.4",
4
4
  "description": "Truedat Web Data Dictionary",
5
5
  "sideEffects": false,
6
6
  "module": "src/index.js",
@@ -48,7 +48,7 @@
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.10.2",
51
+ "@truedat/test": "7.10.4",
52
52
  "identity-obj-proxy": "^3.0.0",
53
53
  "jest": "^29.7.0",
54
54
  "redux-saga-test-plan": "^4.0.6"
@@ -83,5 +83,5 @@
83
83
  "svg-pan-zoom": "^3.6.2",
84
84
  "swr": "^2.3.3"
85
85
  },
86
- "gitHead": "913c4f16345d35e38b0ed09c58d73b88955356f0"
86
+ "gitHead": "0dcedbfaed3964ee02a3d2c175e0f96e2fbc9316"
87
87
  }
@@ -253,7 +253,6 @@ export const DATA_STRUCTURE_VERSION_QUERY = gql`
253
253
  type
254
254
  group
255
255
  deleted_at
256
- metadata
257
256
  data_structure {
258
257
  alias
259
258
  confidential
@@ -420,7 +419,6 @@ export const DATA_STRUCTURE_VERSION_QUERY = gql`
420
419
  in
421
420
  out
422
421
  }
423
-
424
422
  data_fields {
425
423
  alias
426
424
  classes
@@ -485,6 +483,16 @@ export const DATA_STRUCTURE_VERSION_QUERY = gql`
485
483
  }
486
484
  `;
487
485
 
486
+ export const DATA_STRUCTURE_VERSION_METADATA_QUERY = gql`
487
+ query DataStructureVersion(
488
+ $dataStructureId: ID!
489
+ $version: String!
490
+ ) {
491
+ dataStructureVersion(dataStructureId: $dataStructureId, version: $version) {
492
+ metadata
493
+ }
494
+ }
495
+ `;
488
496
  export const TASKS_QUERY = gql`
489
497
  query Tasks {
490
498
  tasks {
@@ -1,14 +1,24 @@
1
1
  import _ from "lodash/fp";
2
2
  import { useEffect, useState } from "react";
3
- import PropTypes from "prop-types";
4
- import { connect } from "react-redux";
5
- import { Accordion, Menu } from "semantic-ui-react";
3
+ import { useParams } from "react-router";
4
+ import { useSelector } from "react-redux";
5
+ import { Accordion, Loader, Menu, Message } from "semantic-ui-react";
6
6
  import { useIntl } from "react-intl";
7
+ import { useQuery } from "@apollo/client";
7
8
  import { metadataViewsSelector } from "../selectors/metadataViewsSelector";
9
+ import { DATA_STRUCTURE_VERSION_METADATA_QUERY } from "../api/queries";
8
10
 
9
- export const StructureMetadata = ({ options }) => {
11
+ export const StructureMetadata = () => {
10
12
  const [selectedOption, setSelectedOption] = useState(null);
11
13
  const { formatMessage } = useIntl();
14
+ const { id } = useParams();
15
+
16
+ const { loading, data } = useQuery(DATA_STRUCTURE_VERSION_METADATA_QUERY, {
17
+ fetchPolicy: "network-only",
18
+ variables: { dataStructureId: id, version: "latest" },
19
+ });
20
+ const metadata = data?.dataStructureVersion?.metadata;
21
+ const options = useSelector((state) => metadataViewsSelector({ structure: state.structure, structureMetadata: metadata }))
12
22
 
13
23
  useEffect(() => {
14
24
  if (!selectedOption && !_.isEmpty(options)) {
@@ -19,16 +29,16 @@ export const StructureMetadata = ({ options }) => {
19
29
  const formatContent = (value) =>
20
30
  _.isObject(value)
21
31
  ? {
22
- content: (
23
- <div>
24
- <Accordion.Accordion
25
- exclusive={false}
26
- defaultActiveIndex={_.range(0, _.size(value))}
27
- panels={toPanels(value)}
28
- />
29
- </div>
30
- ),
31
- }
32
+ content: (
33
+ <div>
34
+ <Accordion.Accordion
35
+ exclusive={false}
36
+ defaultActiveIndex={_.range(0, _.size(value))}
37
+ panels={toPanels(value)}
38
+ />
39
+ </div>
40
+ ),
41
+ }
32
42
  : _.toString(value);
33
43
 
34
44
  const toPanels = _.flow(
@@ -54,7 +64,7 @@ export const StructureMetadata = ({ options }) => {
54
64
  const fields = selectedOption?.fields;
55
65
  const defaultActiveIndex = _.range(0, _.size(fields));
56
66
 
57
- return selectedOption ? (
67
+ return loading ? <Loader active={loading} /> : !_.isEmpty(fields) ? (
58
68
  <>
59
69
  {items?.length > 1 ? (
60
70
  <Menu pointing attached="top" secondary items={items} />
@@ -67,15 +77,10 @@ export const StructureMetadata = ({ options }) => {
67
77
  styled
68
78
  />
69
79
  </>
70
- ) : null;
71
- };
72
-
73
- StructureMetadata.propTypes = {
74
- options: PropTypes.array,
80
+ ) : <Message
81
+ warning
82
+ header={formatMessage({ id: "structure.notes.empty" })}
83
+ />;
75
84
  };
76
85
 
77
- const mapStateToProps = (state) => ({
78
- options: metadataViewsSelector(state),
79
- });
80
-
81
- export default connect(mapStateToProps)(StructureMetadata);
86
+ export default StructureMetadata;
@@ -13,7 +13,7 @@ const SimilarityColumn = (similarity) => {
13
13
  const { formatMessage } = useIntl();
14
14
  return (
15
15
  <Popup
16
- content={formatMessage({ id: "structure.similarity.cosine.popup" })}
16
+ content={formatMessage({ id: "suggestions.similarity.cosine.popup" })}
17
17
  trigger={<span>{similarity.toFixed(3)}</span>}
18
18
  />
19
19
  );
@@ -36,6 +36,10 @@ const StructureRelationForm = lazy(
36
36
  () => import("@truedat/lm/components/StructureRelationForm")
37
37
  );
38
38
 
39
+ const StructureSuggestionLinkForm = lazy(
40
+ () => import("@truedat/lm/components/StructureSuggestionLinkForm")
41
+ );
42
+
39
43
  const RuleImplementationsTable = lazy(
40
44
  () => import("@truedat/dq/components/RuleImplementationsTable")
41
45
  );
@@ -69,6 +73,7 @@ export const StructureTabPane = ({ path }) => {
69
73
  {activeTab === "links" && (
70
74
  <Routes>
71
75
  <Route path="new" element={<StructureRelationForm />} />
76
+ <Route path="suggest" element={<StructureSuggestionLinkForm />} />
72
77
  <Route index element={<StructureLinks />} />
73
78
  </Routes>
74
79
  )}
@@ -1,12 +1,6 @@
1
1
  import React from "react";
2
2
  import { Route, useParams, Routes } from "react-router";
3
3
  import { useQuery } from "@apollo/client";
4
- import { ProtectedRoute } from "@truedat/core/router";
5
- import {
6
- STRUCTURE_TAGS,
7
- STRUCTURE_TAG_EDIT,
8
- STRUCTURE_TAGS_NEW,
9
- } from "@truedat/core/routes";
10
4
  import { TAG_QUERY } from "../api/queries";
11
5
  import Tag from "./Tag";
12
6
  import Tags from "./Tags";
@@ -1,6 +1,12 @@
1
1
  import { render } from "@truedat/test/render";
2
+ import { useQuery } from "@apollo/client";
2
3
  import StructureMetadata from "../StructureMetadata";
3
4
 
5
+ jest.mock("@apollo/client", () => ({
6
+ ...jest.requireActual("@apollo/client"),
7
+ useQuery: jest.fn(),
8
+ }));
9
+
4
10
  const structureMetadata = {
5
11
  foo: "foo",
6
12
  bar: "bar",
@@ -23,15 +29,27 @@ const renderOpts = {
23
29
  en: {},
24
30
  },
25
31
  state: {
26
- structureMetadata,
27
32
  structure,
28
33
  },
29
34
  };
30
35
 
36
+
37
+
31
38
  describe("<StructureMetadata />", () => {
39
+ beforeEach(() => {
40
+ useQuery.mockReturnValue({
41
+ loading: false,
42
+ error: null,
43
+ data: {
44
+ dataStructureVersion: {
45
+ metadata: structureMetadata
46
+ }
47
+ },
48
+ });
49
+ });
50
+
32
51
  it("matches the latest snapshot", () => {
33
- const props = { metadata: { foo: { bar: "baz" } } };
34
- const { container } = render(<StructureMetadata {...props} />, renderOpts);
52
+ const { container } = render(<StructureMetadata />, renderOpts);
35
53
  expect(container).toMatchSnapshot();
36
54
  });
37
55
  });
@@ -49,7 +49,6 @@ import { structureLineageGraph } from "./structureLineageGraph";
49
49
  import { structureLineageId } from "./structureLineageId";
50
50
  import { structureLinks } from "./structureLinks";
51
51
  import { structureLoading } from "./structureLoading";
52
- import { structureMetadata } from "./structureMetadata";
53
52
  import { structureNotes } from "./structureNotes";
54
53
  import { structureParents } from "./structureParents";
55
54
  import { structureProfile } from "./structureProfile";
@@ -130,7 +129,6 @@ export {
130
129
  structureLineageId,
131
130
  structureLinks,
132
131
  structureLoading,
133
- structureMetadata,
134
132
  structureNotes,
135
133
  structureParents,
136
134
  structureProfile,
@@ -15,6 +15,7 @@ import {
15
15
  STRUCTURE_RULES,
16
16
  STRUCTURE_LINKS,
17
17
  STRUCTURE_LINKS_NEW,
18
+ STRUCTURE_LINKS_CONCEPTS_SUGGEST,
18
19
  STRUCTURE_VERSIONS,
19
20
  STRUCTURE_VERSION_VERSIONS,
20
21
  STRUCTURE_GRANTS,
@@ -62,6 +63,7 @@ export const getActiveTab = ({ tabVisibility, path, tabsOrder, customTabs }) =>
62
63
  [_.eq(STRUCTURE_RULES), _.constant("rules")],
63
64
  [_.eq(STRUCTURE_LINKS), _.constant("links")],
64
65
  [_.eq(STRUCTURE_LINKS_NEW), _.constant("links")],
66
+ [_.eq(STRUCTURE_LINKS_CONCEPTS_SUGGEST), _.constant("links")],
65
67
  [_.eq(STRUCTURE_VERSIONS), _.constant("versions")],
66
68
  [_.eq(STRUCTURE_VERSION_VERSIONS), _.constant("versions")],
67
69
  [_.eq(STRUCTURE_EVENTS), _.constant("events")],
@@ -1,7 +1,6 @@
1
1
  import _ from "lodash/fp";
2
2
  import { createSelector } from "reselect";
3
3
  import { getStructureToConceptLinks } from "./getStructureLinks";
4
- import { metadataViewsSelector } from "./metadataViewsSelector";
5
4
 
6
5
  const notEmpty = _.negate(_.isEmpty);
7
6
  const notEmptyPath = (path) => _.flow(_.path(path), notEmpty);
@@ -58,6 +57,7 @@ const eventsTabVisible = _.flow(
58
57
  _.isEqual("latest")
59
58
  );
60
59
  const grantsTabVisible = _.flow(_.path("structure.grants"), notEmpty);
60
+ const metatadaVisible = (state) => !_.isEmpty(_.path(["structure", "structure_type", "metadata_views"])(state))
61
61
 
62
62
  export const getTabVisibility = createSelector([state => state], (state) => ({
63
63
  fields: fieldsTabVisible(state),
@@ -65,7 +65,7 @@ export const getTabVisibility = createSelector([state => state], (state) => ({
65
65
  links: linksTabVisible(state),
66
66
  structureLinks: structureLinksTabVisible(state),
67
67
  notes: notesTabVisible(state),
68
- metadata: !_.isEmpty(metadataViewsSelector(state)),
68
+ metadata: metatadaVisible(state),
69
69
  versions: versionsTabVisible(state),
70
70
  events: eventsTabVisible(state),
71
71
  rules: rulesTabVisible(state),
@@ -11,10 +11,10 @@ export const metadataViewsSelector = createSelector(
11
11
  _.isEmpty(metadataViews) || _.isEmpty(structureMetadata)
12
12
  ? []
13
13
  : _.flow(
14
- _.map(({ fields, name }) => ({
15
- name,
16
- fields: pickFields(fields)(structureMetadata),
17
- })),
18
- _.reject(({ fields }) => _.isEmpty(fields))
19
- )(metadataViews)
14
+ _.map(({ fields, name }) => ({
15
+ name,
16
+ fields: pickFields(fields)(structureMetadata),
17
+ })),
18
+ _.reject(({ fields }) => _.isEmpty(fields))
19
+ )(metadataViews)
20
20
  );
@@ -1,18 +0,0 @@
1
- import { clearStructure, fetchStructure, updateStructure } from "../routines";
2
-
3
- export const initialState = {};
4
-
5
- export const structureMetadata = (state = initialState, { type, payload }) => {
6
- switch (type) {
7
- case clearStructure.TRIGGER:
8
- return initialState;
9
- case fetchStructure.TRIGGER:
10
- return initialState;
11
- case fetchStructure.SUCCESS:
12
- return payload?.data?.metadata || initialState;
13
- case updateStructure.SUCCESS:
14
- return payload?.data?.metadata || initialState;
15
- default:
16
- return state;
17
- }
18
- };