@truedat/dd 7.10.2 → 7.10.3
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/api/queries.js +10 -2
- package/src/components/StructureMetadata.js +30 -25
- package/src/components/TagsRoutes.js +0 -6
- package/src/components/__tests__/StructureMetadata.spec.js +21 -3
- package/src/reducers/index.js +0 -2
- package/src/selectors/getTabVisibility.js +2 -2
- package/src/selectors/metadataViewsSelector.js +6 -6
- package/src/reducers/structureMetadata.js +0 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/dd",
|
|
3
|
-
"version": "7.10.
|
|
3
|
+
"version": "7.10.3",
|
|
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.
|
|
51
|
+
"@truedat/test": "7.10.3",
|
|
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": "
|
|
86
|
+
"gitHead": "1233e6ea0f6fa0c7d7483ae79df7e79a2733bc53"
|
|
87
87
|
}
|
package/src/api/queries.js
CHANGED
|
@@ -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
|
|
4
|
-
import {
|
|
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 = (
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
|
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
|
-
) :
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
options: PropTypes.array,
|
|
80
|
+
) : <Message
|
|
81
|
+
warning
|
|
82
|
+
header={formatMessage({ id: "structure.notes.empty" })}
|
|
83
|
+
/>;
|
|
75
84
|
};
|
|
76
85
|
|
|
77
|
-
|
|
78
|
-
options: metadataViewsSelector(state),
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
export default connect(mapStateToProps)(StructureMetadata);
|
|
86
|
+
export default StructureMetadata;
|
|
@@ -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
|
|
34
|
-
const { container } = render(<StructureMetadata {...props} />, renderOpts);
|
|
52
|
+
const { container } = render(<StructureMetadata />, renderOpts);
|
|
35
53
|
expect(container).toMatchSnapshot();
|
|
36
54
|
});
|
|
37
55
|
});
|
package/src/reducers/index.js
CHANGED
|
@@ -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,
|
|
@@ -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:
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
};
|