@truedat/core 6.0.5 → 6.1.1
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/components/CatalogMenu.js +0 -3
- package/src/components/Pagination.js +1 -1
- package/src/components/__tests__/CatalogMenu.spec.js +56 -32
- package/src/components/__tests__/SideMenu.spec.js +37 -2
- package/src/components/__tests__/__snapshots__/CatalogMenu.spec.js.snap +62 -112
- package/src/components/__tests__/__snapshots__/SideMenu.spec.js.snap +465 -33
- package/src/search/FilterDropdown.js +76 -0
- package/src/search/FilterItem.js +49 -0
- package/src/search/FilterMultilevelDropdown.js +202 -0
- package/src/search/HierarchyFilterDropdown.js +95 -0
- package/src/search/SearchContext.js +234 -0
- package/src/search/SearchFilters.js +60 -0
- package/src/search/SearchSelectedFilters.js +55 -0
- package/src/search/SearchWidget.js +30 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/core",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.1",
|
|
4
4
|
"description": "Truedat Web Core",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"jsnext:main": "src/index.js",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@testing-library/jest-dom": "^5.16.5",
|
|
36
36
|
"@testing-library/react": "^12.0.0",
|
|
37
37
|
"@testing-library/user-event": "^13.2.1",
|
|
38
|
-
"@truedat/test": "6.
|
|
38
|
+
"@truedat/test": "6.1.1",
|
|
39
39
|
"babel-jest": "^28.1.0",
|
|
40
40
|
"babel-plugin-dynamic-import-node": "^2.3.3",
|
|
41
41
|
"babel-plugin-lodash": "^3.3.4",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"react-dom": ">= 16.8.6 < 17",
|
|
118
118
|
"semantic-ui-react": ">= 2.0.3 < 2.2"
|
|
119
119
|
},
|
|
120
|
-
"gitHead": "
|
|
120
|
+
"gitHead": "8ba2e1d68380956d654d6927a6117734f1c50076"
|
|
121
121
|
}
|
|
@@ -53,7 +53,6 @@ export const CatalogMenu = ({ catalogViewConfigs }) => {
|
|
|
53
53
|
"data_dictionary_structure_notes"
|
|
54
54
|
);
|
|
55
55
|
const { formatMessage } = useIntl();
|
|
56
|
-
|
|
57
56
|
const submenuItems = [
|
|
58
57
|
{ name: "structures", routes: [STRUCTURES, SYSTEMS] },
|
|
59
58
|
...catalogViewConfigItems(formatMessage)(catalogViewConfigs),
|
|
@@ -73,10 +72,8 @@ CatalogMenu.propTypes = {
|
|
|
73
72
|
};
|
|
74
73
|
|
|
75
74
|
export const CatalogMenuLoader = (props) => {
|
|
76
|
-
const adminAuthorized = useAuthorized();
|
|
77
75
|
const { loading, error, data } = useQuery(CATALOG_VIEW_CONFIGS_QUERY, {
|
|
78
76
|
fetchPolicy: "cache-and-network",
|
|
79
|
-
skip: !adminAuthorized,
|
|
80
77
|
});
|
|
81
78
|
|
|
82
79
|
if (error) return null;
|
|
@@ -3,71 +3,95 @@ import React from "react";
|
|
|
3
3
|
import { render } from "@truedat/test/render";
|
|
4
4
|
import { within } from "@testing-library/react";
|
|
5
5
|
import { MemoryRouter } from "react-router-dom";
|
|
6
|
+
import { waitForElementToBeRemoved } from "@testing-library/react";
|
|
7
|
+
|
|
6
8
|
import { linkTo } from "@truedat/core/routes";
|
|
7
|
-
import {
|
|
9
|
+
import { CATALOG_VIEW_CONFIGS_QUERY } from "@truedat/dd/api/queries";
|
|
10
|
+
import CatalogMenu from "../CatalogMenu";
|
|
8
11
|
|
|
9
12
|
jest.mock("../../hooks", () => ({
|
|
10
13
|
...jest.requireActual("../../hooks"),
|
|
11
14
|
useAuthorized: jest.fn(() => true),
|
|
15
|
+
useAuthorizedItems: jest.fn((items) => items),
|
|
12
16
|
}));
|
|
13
17
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
const mocks = [
|
|
19
|
+
{
|
|
20
|
+
request: { query: CATALOG_VIEW_CONFIGS_QUERY },
|
|
21
|
+
result: {
|
|
22
|
+
data: {
|
|
23
|
+
catalogViewConfigs: [
|
|
24
|
+
{
|
|
25
|
+
id: "1",
|
|
26
|
+
fieldType: "metadata",
|
|
27
|
+
fieldName: "region",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: "2",
|
|
31
|
+
fieldType: "note",
|
|
32
|
+
fieldName: "layer",
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
},
|
|
19
36
|
},
|
|
20
37
|
},
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
const commonRenderOpts = {
|
|
41
|
+
mocks,
|
|
42
|
+
state: { sidebarVisible: true },
|
|
21
43
|
};
|
|
22
44
|
|
|
23
45
|
describe("<CatalogMenu />", () => {
|
|
24
|
-
it("matches the latest snapshot", () => {
|
|
25
|
-
const { container } = render(
|
|
46
|
+
it("matches the latest snapshot", async () => {
|
|
47
|
+
const { container } = render(
|
|
48
|
+
<MemoryRouter initialEntries={[linkTo.STRUCTURE({ id: 1234 })]}>
|
|
49
|
+
<CatalogMenu />
|
|
50
|
+
</MemoryRouter>,
|
|
51
|
+
commonRenderOpts
|
|
52
|
+
);
|
|
53
|
+
const loader = container.querySelector(".loader");
|
|
54
|
+
await waitForElementToBeRemoved(loader);
|
|
26
55
|
expect(container).toMatchSnapshot();
|
|
27
56
|
});
|
|
28
57
|
|
|
29
|
-
it("Path active route", () => {
|
|
58
|
+
it("Path active route", async () => {
|
|
30
59
|
const { container } = render(
|
|
31
60
|
<MemoryRouter initialEntries={[linkTo.STRUCTURE({ id: 1234 })]}>
|
|
32
61
|
<CatalogMenu />
|
|
33
62
|
</MemoryRouter>,
|
|
34
63
|
commonRenderOpts
|
|
35
64
|
);
|
|
65
|
+
const loader = container.querySelector(".loader");
|
|
66
|
+
await waitForElementToBeRemoved(loader);
|
|
36
67
|
|
|
37
|
-
const activeMenus = container.querySelectorAll(
|
|
68
|
+
const activeMenus = container.querySelectorAll("a.active");
|
|
38
69
|
expect(activeMenus.length).toBe(1);
|
|
39
|
-
expect(within(activeMenus[0]).getByText("
|
|
70
|
+
expect(within(activeMenus[0]).getByText("Structures")).toBeInTheDocument();
|
|
40
71
|
});
|
|
41
72
|
|
|
42
|
-
it("Navigation filter has priority over path for active menu and submenu", () => {
|
|
43
|
-
const renderOpts = {
|
|
44
|
-
...commonRenderOpts,
|
|
73
|
+
it("Navigation filter has priority over path for active menu and submenu", async () => {
|
|
74
|
+
const renderOpts = _.merge(commonRenderOpts, {
|
|
45
75
|
state: {
|
|
46
76
|
navFilter: { "metadata.region": "eu-west-1" },
|
|
47
77
|
},
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const catalogViewConfigs = [
|
|
51
|
-
{
|
|
52
|
-
id: "1",
|
|
53
|
-
fieldType: "metadata",
|
|
54
|
-
fieldName: "region",
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
id: "2",
|
|
58
|
-
fieldType: "note",
|
|
59
|
-
fieldName: "layer",
|
|
60
|
-
},
|
|
61
|
-
];
|
|
78
|
+
});
|
|
62
79
|
|
|
63
80
|
const { getByText, container } = render(
|
|
64
|
-
<MemoryRouter
|
|
65
|
-
|
|
81
|
+
<MemoryRouter
|
|
82
|
+
initialEntries={[
|
|
83
|
+
linkTo.BUCKETS_VIEW({ propertyPath: `metadata.region` }),
|
|
84
|
+
]}
|
|
85
|
+
>
|
|
86
|
+
<CatalogMenu />
|
|
66
87
|
</MemoryRouter>,
|
|
67
88
|
renderOpts
|
|
68
89
|
);
|
|
69
90
|
|
|
70
|
-
const
|
|
91
|
+
const loader = container.querySelector(".loader");
|
|
92
|
+
await waitForElementToBeRemoved(loader);
|
|
93
|
+
|
|
94
|
+
const structuresMenu = getByText("Structures").closest("a");
|
|
71
95
|
const metadataBucketMenu = getByText("metadata.region").closest("a");
|
|
72
96
|
const noteBucketMenu = getByText("note.layer").closest("a");
|
|
73
97
|
|
|
@@ -75,7 +99,7 @@ describe("<CatalogMenu />", () => {
|
|
|
75
99
|
expect(metadataBucketMenu).toBeInTheDocument();
|
|
76
100
|
expect(noteBucketMenu).toBeInTheDocument();
|
|
77
101
|
|
|
78
|
-
const activeMenus = container.querySelectorAll(
|
|
102
|
+
const activeMenus = container.querySelectorAll("a.active");
|
|
79
103
|
expect(activeMenus.length).toBe(1);
|
|
80
104
|
expect(
|
|
81
105
|
within(activeMenus[0]).getByText("metadata.region")
|
|
@@ -1,17 +1,52 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { render } from "@truedat/test/render";
|
|
3
|
+
import { waitForElementToBeRemoved } from "@testing-library/react";
|
|
4
|
+
import { CATALOG_VIEW_CONFIGS_QUERY } from "@truedat/dd/api/queries";
|
|
3
5
|
import SideMenu from "../SideMenu";
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
jest.mock("@truedat/core/hooks", () => ({
|
|
8
|
+
useActiveRoutes: jest.fn(() => true),
|
|
9
|
+
useAuthorized: jest.fn(() => true),
|
|
10
|
+
useAuthorizedItems: jest.fn((items) => items),
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
const mocks = [
|
|
14
|
+
{
|
|
15
|
+
request: { query: CATALOG_VIEW_CONFIGS_QUERY },
|
|
16
|
+
result: {
|
|
17
|
+
data: {
|
|
18
|
+
catalogViewConfigs: [
|
|
19
|
+
{
|
|
20
|
+
id: "1",
|
|
21
|
+
fieldType: "metadata",
|
|
22
|
+
fieldName: "region",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: "2",
|
|
26
|
+
fieldType: "note",
|
|
27
|
+
fieldName: "layer",
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
const renderOpts = {
|
|
36
|
+
mocks,
|
|
37
|
+
state: { sidebarVisible: true },
|
|
38
|
+
};
|
|
6
39
|
|
|
7
40
|
describe("<SideMenu />", () => {
|
|
8
|
-
it("matches the latest snapshot", () => {
|
|
41
|
+
it("matches the latest snapshot", async () => {
|
|
9
42
|
const { container } = render(
|
|
10
43
|
<SideMenu>
|
|
11
44
|
<p>Hello</p>
|
|
12
45
|
</SideMenu>,
|
|
13
46
|
renderOpts
|
|
14
47
|
);
|
|
48
|
+
const loader = container.querySelector(".loader");
|
|
49
|
+
await waitForElementToBeRemoved(loader);
|
|
15
50
|
expect(container).toMatchSnapshot();
|
|
16
51
|
});
|
|
17
52
|
});
|
|
@@ -2,125 +2,75 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`<CatalogMenu /> matches the latest snapshot 1`] = `
|
|
4
4
|
<div>
|
|
5
|
-
<div
|
|
5
|
+
<div
|
|
6
|
+
class="active item selectable"
|
|
7
|
+
>
|
|
8
|
+
<a
|
|
9
|
+
href="/structures"
|
|
10
|
+
>
|
|
11
|
+
<i
|
|
12
|
+
aria-hidden="true"
|
|
13
|
+
class="block layout large icon"
|
|
14
|
+
/>
|
|
15
|
+
Catalog
|
|
16
|
+
</a>
|
|
6
17
|
<div
|
|
7
|
-
|
|
8
|
-
class="ui item dropdown"
|
|
9
|
-
role="listbox"
|
|
10
|
-
tabindex="0"
|
|
18
|
+
class="menu"
|
|
11
19
|
>
|
|
12
20
|
<a
|
|
13
|
-
class="
|
|
21
|
+
class="active link item"
|
|
14
22
|
href="/structures"
|
|
15
23
|
>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
24
|
+
Structures
|
|
25
|
+
</a>
|
|
26
|
+
<a
|
|
27
|
+
class="link item"
|
|
28
|
+
href="/buckets/metadata.region"
|
|
29
|
+
>
|
|
30
|
+
metadata.region
|
|
31
|
+
</a>
|
|
32
|
+
<a
|
|
33
|
+
class="link item"
|
|
34
|
+
href="/buckets/note.layer"
|
|
35
|
+
>
|
|
36
|
+
note.layer
|
|
37
|
+
</a>
|
|
38
|
+
<a
|
|
39
|
+
class="link item"
|
|
40
|
+
href="/referenceDatasets"
|
|
41
|
+
>
|
|
42
|
+
Reference Data
|
|
43
|
+
</a>
|
|
44
|
+
<a
|
|
45
|
+
class="link item"
|
|
46
|
+
href="/structureNotes"
|
|
47
|
+
>
|
|
48
|
+
Pending notes
|
|
49
|
+
</a>
|
|
50
|
+
<a
|
|
51
|
+
class="link item"
|
|
52
|
+
href="/bulkUpdateTemplateContentEvents"
|
|
53
|
+
>
|
|
54
|
+
My loads
|
|
55
|
+
</a>
|
|
56
|
+
<a
|
|
57
|
+
class="link item"
|
|
58
|
+
href="/bucketViewConfigs"
|
|
59
|
+
>
|
|
60
|
+
Catalog views
|
|
61
|
+
</a>
|
|
62
|
+
<a
|
|
63
|
+
class="link item"
|
|
64
|
+
href="/structureTypes"
|
|
65
|
+
>
|
|
66
|
+
Structure Types
|
|
20
67
|
</a>
|
|
21
|
-
<
|
|
22
|
-
class="
|
|
68
|
+
<a
|
|
69
|
+
class="link item"
|
|
70
|
+
href="/structureTags"
|
|
23
71
|
>
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
>
|
|
27
|
-
catalog
|
|
28
|
-
</div>
|
|
29
|
-
<div
|
|
30
|
-
class="divider"
|
|
31
|
-
/>
|
|
32
|
-
<a
|
|
33
|
-
aria-checked="false"
|
|
34
|
-
class="item"
|
|
35
|
-
href="/structures"
|
|
36
|
-
name="structures"
|
|
37
|
-
role="option"
|
|
38
|
-
>
|
|
39
|
-
<span
|
|
40
|
-
class="text"
|
|
41
|
-
>
|
|
42
|
-
structures
|
|
43
|
-
</span>
|
|
44
|
-
</a>
|
|
45
|
-
<a
|
|
46
|
-
aria-checked="false"
|
|
47
|
-
class="item"
|
|
48
|
-
href="/referenceDatasets"
|
|
49
|
-
name="referenceData"
|
|
50
|
-
role="option"
|
|
51
|
-
>
|
|
52
|
-
<span
|
|
53
|
-
class="text"
|
|
54
|
-
>
|
|
55
|
-
referenceData
|
|
56
|
-
</span>
|
|
57
|
-
</a>
|
|
58
|
-
<a
|
|
59
|
-
aria-checked="false"
|
|
60
|
-
class="item"
|
|
61
|
-
href="/structureNotes"
|
|
62
|
-
name="pending_structure_notes"
|
|
63
|
-
role="option"
|
|
64
|
-
>
|
|
65
|
-
<span
|
|
66
|
-
class="text"
|
|
67
|
-
>
|
|
68
|
-
pending_structure_notes
|
|
69
|
-
</span>
|
|
70
|
-
</a>
|
|
71
|
-
<a
|
|
72
|
-
aria-checked="false"
|
|
73
|
-
class="item"
|
|
74
|
-
href="/bulkUpdateTemplateContentEvents"
|
|
75
|
-
name="structures_upload_events"
|
|
76
|
-
role="option"
|
|
77
|
-
>
|
|
78
|
-
<span
|
|
79
|
-
class="text"
|
|
80
|
-
>
|
|
81
|
-
structures_upload_events
|
|
82
|
-
</span>
|
|
83
|
-
</a>
|
|
84
|
-
<a
|
|
85
|
-
aria-checked="false"
|
|
86
|
-
class="item"
|
|
87
|
-
href="/bucketViewConfigs"
|
|
88
|
-
name="catalogViewConfigs"
|
|
89
|
-
role="option"
|
|
90
|
-
>
|
|
91
|
-
<span
|
|
92
|
-
class="text"
|
|
93
|
-
>
|
|
94
|
-
catalogViewConfigs
|
|
95
|
-
</span>
|
|
96
|
-
</a>
|
|
97
|
-
<a
|
|
98
|
-
aria-checked="false"
|
|
99
|
-
class="item"
|
|
100
|
-
href="/structureTypes"
|
|
101
|
-
name="structureTypes"
|
|
102
|
-
role="option"
|
|
103
|
-
>
|
|
104
|
-
<span
|
|
105
|
-
class="text"
|
|
106
|
-
>
|
|
107
|
-
structureTypes
|
|
108
|
-
</span>
|
|
109
|
-
</a>
|
|
110
|
-
<a
|
|
111
|
-
aria-checked="false"
|
|
112
|
-
class="item"
|
|
113
|
-
href="/structureTags"
|
|
114
|
-
name="structureTags"
|
|
115
|
-
role="option"
|
|
116
|
-
>
|
|
117
|
-
<span
|
|
118
|
-
class="text"
|
|
119
|
-
>
|
|
120
|
-
structureTags
|
|
121
|
-
</span>
|
|
122
|
-
</a>
|
|
123
|
-
</div>
|
|
72
|
+
Structure Tags
|
|
73
|
+
</a>
|
|
124
74
|
</div>
|
|
125
75
|
</div>
|
|
126
76
|
</div>
|