@databiosphere/findable-ui 33.0.0 → 34.1.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.
Files changed (213) hide show
  1. package/.release-please-manifest.json +1 -1
  2. package/CHANGELOG.md +18 -0
  3. package/jest.config.js +4 -0
  4. package/lib/common/entities.d.ts +3 -1
  5. package/lib/components/DataDictionary/components/Entities/entities.d.ts +1 -1
  6. package/lib/components/DataDictionary/components/Entities/entities.js +3 -2
  7. package/lib/components/DataDictionary/components/Entities/types.d.ts +3 -4
  8. package/lib/components/DataDictionary/components/Entity/entity.d.ts +1 -1
  9. package/lib/components/DataDictionary/components/Entity/entity.js +12 -6
  10. package/lib/components/DataDictionary/components/Entity/entity.styles.js +7 -1
  11. package/lib/components/DataDictionary/components/Entity/types.d.ts +4 -4
  12. package/lib/components/DataDictionary/components/Entity/utils.d.ts +9 -0
  13. package/lib/components/DataDictionary/components/Entity/utils.js +18 -0
  14. package/lib/components/DataDictionary/components/Filters/components/ColumnFilters/columnFilters.d.ts +4 -0
  15. package/lib/components/DataDictionary/components/Filters/components/ColumnFilters/columnFilters.js +9 -0
  16. package/lib/components/DataDictionary/components/Filters/components/ColumnFilters/types.d.ts +5 -0
  17. package/lib/components/DataDictionary/components/Filters/components/ColumnFilters/types.js +1 -0
  18. package/lib/components/DataDictionary/components/Filters/filters.d.ts +4 -0
  19. package/lib/components/DataDictionary/components/Filters/filters.js +7 -0
  20. package/lib/components/DataDictionary/components/Filters/filters.styles.d.ts +7 -0
  21. package/lib/components/DataDictionary/components/Filters/filters.styles.js +13 -0
  22. package/lib/components/DataDictionary/components/Filters/stories/constants.d.ts +4 -0
  23. package/lib/components/DataDictionary/components/Filters/stories/constants.js +25 -0
  24. package/lib/components/DataDictionary/components/Filters/stories/filters.stories.d.ts +6 -0
  25. package/lib/components/DataDictionary/components/Filters/stories/filters.stories.js +31 -0
  26. package/lib/components/DataDictionary/components/Filters/stories/hook.d.ts +5 -0
  27. package/lib/components/DataDictionary/components/Filters/stories/hook.js +5 -0
  28. package/lib/components/DataDictionary/components/Filters/stories/types.d.ts +4 -0
  29. package/lib/components/DataDictionary/components/Filters/stories/types.js +1 -0
  30. package/lib/components/DataDictionary/components/Filters/types.d.ts +5 -0
  31. package/lib/components/DataDictionary/components/Filters/types.js +1 -0
  32. package/lib/components/DataDictionary/components/Layout/components/EntitiesLayout/entitiesLayout.styles.js +3 -1
  33. package/lib/components/DataDictionary/components/Layout/components/FiltersLayout/filtersLayout.d.ts +2 -0
  34. package/lib/components/DataDictionary/components/Layout/components/FiltersLayout/filtersLayout.js +5 -0
  35. package/lib/components/DataDictionary/components/Layout/components/FiltersLayout/filtersLayout.styles.d.ts +5 -0
  36. package/lib/components/DataDictionary/components/Layout/components/FiltersLayout/filtersLayout.styles.js +24 -0
  37. package/lib/components/DataDictionary/components/Layout/components/FiltersLayout/types.d.ts +5 -0
  38. package/lib/components/DataDictionary/components/Layout/components/FiltersLayout/types.js +1 -0
  39. package/lib/components/DataDictionary/components/Layout/components/OutlineLayout/outlineLayout.styles.js +1 -1
  40. package/lib/components/DataDictionary/components/Layout/components/TitleLayout/titleLayout.styles.js +1 -0
  41. package/lib/components/DataDictionary/components/Layout/constants.d.ts +4 -0
  42. package/lib/components/DataDictionary/components/Layout/constants.js +4 -0
  43. package/lib/components/DataDictionary/components/Outline/utils.d.ts +5 -5
  44. package/lib/components/DataDictionary/components/Outline/utils.js +23 -6
  45. package/lib/components/DataDictionary/components/Table/hook.d.ts +3 -3
  46. package/lib/components/DataDictionary/components/Table/hook.js +11 -3
  47. package/lib/components/DataDictionary/components/Table/options/columnFilters/constants.d.ts +2 -0
  48. package/lib/components/DataDictionary/components/Table/options/columnFilters/constants.js +8 -0
  49. package/lib/components/DataDictionary/components/Table/options/columnFilters/hook.d.ts +6 -0
  50. package/lib/components/DataDictionary/components/Table/options/columnFilters/hook.js +14 -0
  51. package/lib/components/DataDictionary/components/Table/options/expanded/constants.d.ts +2 -0
  52. package/lib/components/DataDictionary/components/Table/options/expanded/constants.js +5 -0
  53. package/lib/components/DataDictionary/components/Table/options/faceted/constants.d.ts +2 -0
  54. package/lib/components/DataDictionary/components/Table/options/faceted/constants.js +6 -0
  55. package/lib/components/DataDictionary/components/Table/options/grouping/constants.d.ts +2 -0
  56. package/lib/components/DataDictionary/components/Table/options/grouping/constants.js +5 -0
  57. package/lib/components/DataDictionary/components/Table/options/hook.d.ts +1 -1
  58. package/lib/components/DataDictionary/components/Table/options/hook.js +17 -0
  59. package/lib/components/DataDictionary/components/Table/options/visibility/constants.d.ts +2 -0
  60. package/lib/components/DataDictionary/components/Table/options/visibility/constants.js +3 -0
  61. package/lib/components/DataDictionary/components/Table/table.d.ts +1 -1
  62. package/lib/components/DataDictionary/components/Table/table.js +2 -2
  63. package/lib/components/DataDictionary/components/Table/types.d.ts +4 -1
  64. package/lib/components/DataDictionary/components/Table/utils.d.ts +18 -0
  65. package/lib/components/DataDictionary/components/Table/utils.js +27 -0
  66. package/lib/components/DataDictionary/dataDictionary.d.ts +1 -1
  67. package/lib/components/DataDictionary/dataDictionary.js +8 -6
  68. package/lib/components/DataDictionary/hooks/UseDataDictionary/hook.js +16 -5
  69. package/lib/components/DataDictionary/hooks/UseDataDictionary/types.d.ts +5 -4
  70. package/lib/components/DataDictionary/types.d.ts +1 -0
  71. package/lib/components/Detail/components/Table/components/TableBody/tableBody.d.ts +8 -2
  72. package/lib/components/Detail/components/Table/components/TableBody/tableBody.js +2 -2
  73. package/lib/components/Detail/components/Table/components/TableRows/components/CollapsableRows/collapsableRows.d.ts +8 -2
  74. package/lib/components/Detail/components/Table/components/TableRows/components/CollapsableRows/collapsableRows.js +2 -2
  75. package/lib/components/Detail/components/Table/components/TableRows/tableRows.d.ts +8 -2
  76. package/lib/components/Detail/components/Table/components/TableRows/tableRows.js +2 -2
  77. package/lib/components/Filter/components/FilterLabel/filterLabel.styles.d.ts +1 -1
  78. package/lib/components/Filter/components/FilterList/filterList.styles.d.ts +2 -0
  79. package/lib/components/Filter/components/FilterList/filterList.styles.js +28 -15
  80. package/lib/components/Filter/components/SearchAllFiltersSearch/searchAllFiltersSearch.styles.d.ts +1 -1
  81. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/Button/button.styles.d.ts +1 -1
  82. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/Button/button.styles.d.ts +1 -1
  83. package/lib/components/Layout/components/Outline/components/ContentsTab/contentsTab.styles.d.ts +1 -1
  84. package/lib/components/Layout/components/Outline/outline.styles.d.ts +1 -1
  85. package/lib/components/Login/components/Button/button.styles.d.ts +1 -1
  86. package/lib/components/Table/common/utils.d.ts +6 -0
  87. package/lib/components/Table/common/utils.js +14 -0
  88. package/lib/components/Table/components/TableFeatures/ColumnFilter/columnFilter.d.ts +7 -0
  89. package/lib/components/Table/components/TableFeatures/ColumnFilter/columnFilter.js +33 -0
  90. package/lib/components/Table/components/TableFeatures/ColumnFilter/columnFilter.styles.d.ts +3 -0
  91. package/lib/components/Table/components/TableFeatures/ColumnFilter/columnFilter.styles.js +19 -0
  92. package/lib/components/Table/components/TableFeatures/ColumnFilter/constants.d.ts +2 -0
  93. package/lib/components/Table/components/TableFeatures/ColumnFilter/constants.js +14 -0
  94. package/lib/components/Table/components/TableFeatures/ColumnFilter/types.d.ts +7 -0
  95. package/lib/components/Table/components/TableFeatures/ColumnFilter/types.js +1 -0
  96. package/lib/components/Table/components/TableFeatures/ColumnFilter/utils.d.ts +6 -0
  97. package/lib/components/Table/components/TableFeatures/ColumnFilter/utils.js +23 -0
  98. package/lib/components/Table/featureOptions/facetedColumn/utils.d.ts +6 -0
  99. package/lib/components/Table/featureOptions/facetedColumn/utils.js +9 -0
  100. package/lib/components/common/ButtonGroup/constants.d.ts +2 -0
  101. package/lib/components/common/ButtonGroup/constants.js +11 -0
  102. package/lib/components/common/Tabs/tabs.styles.d.ts +1 -1
  103. package/lib/mocks/@storybook/addon-actions.d.ts +9 -0
  104. package/lib/mocks/@storybook/addon-actions.js +9 -0
  105. package/lib/providers/exploreState/entities.d.ts +1 -1
  106. package/lib/providers/exploreState.js +10 -10
  107. package/lib/providers/exploreStateSync/hooks/UseMetaCommands/handlers.d.ts +10 -0
  108. package/lib/providers/exploreStateSync/hooks/UseMetaCommands/handlers.js +18 -0
  109. package/lib/providers/exploreStateSync/hooks/UseMetaCommands/hook.d.ts +1 -0
  110. package/lib/providers/exploreStateSync/hooks/UseMetaCommands/hook.js +33 -0
  111. package/lib/providers/exploreStateSync/hooks/UseMetaCommands/types.d.ts +11 -0
  112. package/lib/providers/exploreStateSync/hooks/UseMetaCommands/types.js +5 -0
  113. package/lib/providers/exploreStateSync/hooks/UseMetaCommands/utils.d.ts +34 -0
  114. package/lib/providers/exploreStateSync/hooks/UseMetaCommands/utils.js +59 -0
  115. package/lib/providers/exploreStateSync/provider.d.ts +19 -0
  116. package/lib/providers/exploreStateSync/provider.js +22 -0
  117. package/lib/styles/common/mui/buttonGroup.d.ts +13 -0
  118. package/lib/styles/common/mui/buttonGroup.js +34 -0
  119. package/lib/styles/common/mui/typography.js +2 -0
  120. package/lib/tests/mui/constants.d.ts +1 -0
  121. package/lib/tests/mui/constants.js +1 -0
  122. package/lib/tests/utils.d.ts +6 -0
  123. package/lib/tests/utils.js +8 -0
  124. package/lib/theme/common/components.d.ts +0 -6
  125. package/lib/theme/common/components.js +17 -31
  126. package/lib/theme/components/index.d.ts +1 -0
  127. package/lib/theme/components/index.js +1 -0
  128. package/lib/theme/components/muiButtonGroup.d.ts +2 -0
  129. package/lib/theme/components/muiButtonGroup.js +76 -0
  130. package/lib/theme/theme.js +1 -1
  131. package/lib/views/ExploreView/exploreView.js +2 -1
  132. package/package.json +1 -1
  133. package/src/common/entities.ts +3 -1
  134. package/src/components/DataDictionary/components/Entities/entities.tsx +5 -9
  135. package/src/components/DataDictionary/components/Entities/types.ts +3 -4
  136. package/src/components/DataDictionary/components/Entity/entity.styles.ts +9 -1
  137. package/src/components/DataDictionary/components/Entity/entity.tsx +18 -8
  138. package/src/components/DataDictionary/components/Entity/types.ts +4 -4
  139. package/src/components/DataDictionary/components/Entity/utils.ts +25 -0
  140. package/src/components/DataDictionary/components/Filters/components/ColumnFilters/columnFilters.tsx +21 -0
  141. package/src/components/DataDictionary/components/Filters/components/ColumnFilters/types.ts +6 -0
  142. package/src/components/DataDictionary/components/Filters/filters.styles.ts +14 -0
  143. package/src/components/DataDictionary/components/Filters/filters.tsx +16 -0
  144. package/src/components/DataDictionary/components/Filters/stories/constants.ts +31 -0
  145. package/src/components/DataDictionary/components/Filters/stories/filters.stories.tsx +42 -0
  146. package/src/components/DataDictionary/components/Filters/stories/hook.ts +9 -0
  147. package/src/components/DataDictionary/components/Filters/stories/types.ts +3 -0
  148. package/src/components/DataDictionary/components/Filters/types.ts +6 -0
  149. package/src/components/DataDictionary/components/Layout/components/EntitiesLayout/entitiesLayout.styles.ts +4 -1
  150. package/src/components/DataDictionary/components/Layout/components/FiltersLayout/filtersLayout.styles.ts +27 -0
  151. package/src/components/DataDictionary/components/Layout/components/FiltersLayout/filtersLayout.tsx +10 -0
  152. package/src/components/DataDictionary/components/Layout/components/FiltersLayout/types.ts +6 -0
  153. package/src/components/DataDictionary/components/Layout/components/OutlineLayout/outlineLayout.styles.ts +1 -1
  154. package/src/components/DataDictionary/components/Layout/components/TitleLayout/titleLayout.styles.ts +1 -0
  155. package/src/components/DataDictionary/components/Layout/constants.ts +4 -0
  156. package/src/components/DataDictionary/components/Outline/utils.ts +35 -13
  157. package/src/components/DataDictionary/components/Table/hook.ts +17 -5
  158. package/src/components/DataDictionary/components/Table/options/columnFilters/constants.ts +16 -0
  159. package/src/components/DataDictionary/components/Table/options/columnFilters/hook.ts +32 -0
  160. package/src/components/DataDictionary/components/Table/options/expanded/constants.ts +13 -0
  161. package/src/components/DataDictionary/components/Table/options/faceted/constants.ts +14 -0
  162. package/src/components/DataDictionary/components/Table/options/grouping/constants.ts +9 -0
  163. package/src/components/DataDictionary/components/Table/options/hook.ts +26 -3
  164. package/src/components/DataDictionary/components/Table/options/visibility/constants.ts +5 -0
  165. package/src/components/DataDictionary/components/Table/table.tsx +2 -0
  166. package/src/components/DataDictionary/components/Table/types.ts +8 -1
  167. package/src/components/DataDictionary/components/Table/utils.ts +40 -0
  168. package/src/components/DataDictionary/dataDictionary.tsx +9 -5
  169. package/src/components/DataDictionary/hooks/UseDataDictionary/hook.ts +19 -5
  170. package/src/components/DataDictionary/hooks/UseDataDictionary/types.ts +5 -4
  171. package/src/components/DataDictionary/types.ts +1 -0
  172. package/src/components/Detail/components/Table/components/TableBody/tableBody.tsx +14 -3
  173. package/src/components/Detail/components/Table/components/TableRows/components/CollapsableRows/collapsableRows.tsx +9 -2
  174. package/src/components/Detail/components/Table/components/TableRows/tableRows.tsx +9 -2
  175. package/src/components/Filter/components/FilterList/filterList.styles.ts +34 -15
  176. package/src/components/Table/common/utils.ts +16 -0
  177. package/src/components/Table/components/TableFeatures/ColumnFilter/columnFilter.styles.ts +23 -0
  178. package/src/components/Table/components/TableFeatures/ColumnFilter/columnFilter.tsx +98 -0
  179. package/src/components/Table/components/TableFeatures/ColumnFilter/constants.ts +16 -0
  180. package/src/components/Table/components/TableFeatures/ColumnFilter/types.ts +10 -0
  181. package/src/components/Table/components/TableFeatures/ColumnFilter/utils.ts +27 -0
  182. package/src/components/Table/featureOptions/facetedColumn/utils.ts +14 -0
  183. package/src/components/common/ButtonGroup/constants.ts +13 -0
  184. package/src/mocks/@storybook/addon-actions.ts +10 -0
  185. package/src/providers/exploreState/entities.ts +1 -1
  186. package/src/providers/exploreState.tsx +10 -11
  187. package/src/providers/exploreStateSync/hooks/UseMetaCommands/handlers.ts +25 -0
  188. package/src/providers/exploreStateSync/hooks/UseMetaCommands/hook.ts +38 -0
  189. package/src/providers/exploreStateSync/hooks/UseMetaCommands/types.ts +13 -0
  190. package/src/providers/exploreStateSync/hooks/UseMetaCommands/utils.ts +69 -0
  191. package/src/providers/exploreStateSync/provider.tsx +29 -0
  192. package/src/styles/common/mui/buttonGroup.ts +46 -0
  193. package/src/styles/common/mui/typography.ts +2 -0
  194. package/src/tests/mui/constants.ts +1 -0
  195. package/src/tests/utils.ts +9 -0
  196. package/src/theme/common/components.ts +17 -32
  197. package/src/theme/components/index.ts +1 -0
  198. package/src/theme/components/muiButtonGroup.ts +79 -0
  199. package/src/theme/theme.ts +1 -1
  200. package/src/views/ExploreView/exploreView.tsx +3 -2
  201. package/tests/dataDictionaryColumnFilters.test.tsx +101 -0
  202. package/lib/providers/exploreState/hooks/UseMetaCommands/actions.d.ts +0 -13
  203. package/lib/providers/exploreState/hooks/UseMetaCommands/actions.js +0 -24
  204. package/lib/providers/exploreState/hooks/UseMetaCommands/types.d.ts +0 -4
  205. package/lib/providers/exploreState/hooks/UseMetaCommands/types.js +0 -5
  206. package/lib/providers/exploreState/hooks/UseMetaCommands/useMetaCommands.d.ts +0 -2
  207. package/lib/providers/exploreState/hooks/UseMetaCommands/useMetaCommands.js +0 -21
  208. package/lib/providers/exploreState/hooks/UseMetaCommands/utils.d.ts +0 -9
  209. package/lib/providers/exploreState/hooks/UseMetaCommands/utils.js +0 -25
  210. package/src/providers/exploreState/hooks/UseMetaCommands/actions.ts +0 -29
  211. package/src/providers/exploreState/hooks/UseMetaCommands/types.ts +0 -4
  212. package/src/providers/exploreState/hooks/UseMetaCommands/useMetaCommands.ts +0 -27
  213. package/src/providers/exploreState/hooks/UseMetaCommands/utils.ts +0 -33
@@ -0,0 +1,101 @@
1
+ import { matchers } from "@emotion/jest";
2
+ import { jest } from "@jest/globals";
3
+ import { composeStories } from "@storybook/react";
4
+ import { waitFor } from "@storybook/test";
5
+ import "@testing-library/jest-dom";
6
+ import { fireEvent, render, screen, within } from "@testing-library/react";
7
+ import React from "react";
8
+ import * as stories from "../src/components/DataDictionary/components/Filters/stories/filters.stories";
9
+ import { MUI_CLASSES } from "../src/tests/mui/constants";
10
+ import {
11
+ getButton,
12
+ getRole,
13
+ getStartsWithRegex,
14
+ getText,
15
+ } from "../src/tests/utils";
16
+
17
+ expect.extend(matchers);
18
+
19
+ const { Default } = composeStories(stories);
20
+
21
+ describe("DataDictionaryColumnFilters", () => {
22
+ beforeEach(() => {
23
+ jest.clearAllMocks();
24
+ render(<Default />);
25
+ });
26
+
27
+ it("renders correctly", async () => {
28
+ expect(await screen.findByText("Required")).toBeInTheDocument();
29
+ });
30
+
31
+ it("renders all filterable column headers", async () => {
32
+ expect(await screen.findByText("Required")).toBeInTheDocument();
33
+ expect(await screen.findByText("BioNetwork")).toBeInTheDocument();
34
+ expect(screen.queryByText("Example")).not.toBeInTheDocument();
35
+ });
36
+
37
+ it("renders BioNetwork filter options", async () => {
38
+ const buttonEl = getButton("BioNetwork");
39
+ fireEvent.click(buttonEl);
40
+ // Wait for menu to open.
41
+ await waitFor(() => expect(getRole("menu")).toBeInTheDocument());
42
+ expect(getText("Brain")).toBeInTheDocument();
43
+ expect(getText("Lung")).toBeInTheDocument();
44
+ expect(getText("Nervous System")).toBeInTheDocument();
45
+ });
46
+
47
+ it("renders BioNetwork filter options in alphabetical order", async () => {
48
+ const buttonEl = getButton("BioNetwork");
49
+ fireEvent.click(buttonEl);
50
+ // Wait for menu to open.
51
+ await waitFor(() => expect(getRole("menu")).toBeInTheDocument());
52
+ const optionEls = within(getRole("menu")).getAllByRole("button");
53
+ ["Brain", "Lung", "Nervous System", "Clear All"].forEach((expected, i) => {
54
+ expect(optionEls[i].textContent).toMatch(getStartsWithRegex(expected));
55
+ });
56
+ });
57
+
58
+ it("can select and deselect a filter option", async () => {
59
+ const buttonEl = getButton("BioNetwork");
60
+ fireEvent.click(buttonEl);
61
+ // Wait for menu to open.
62
+ await waitFor(() => expect(getRole("menu")).toBeInTheDocument());
63
+ // Select first option.
64
+ const optionEls = within(getRole("menu")).getAllByRole("button");
65
+ const optionEl = optionEls[0];
66
+ fireEvent.click(optionEl);
67
+ await waitFor(() => expect(optionEl).toHaveClass(MUI_CLASSES.SELECTED));
68
+ // Deselect first option.
69
+ fireEvent.click(optionEl);
70
+ await waitFor(() => expect(optionEl).not.toHaveClass(MUI_CLASSES.SELECTED));
71
+ });
72
+
73
+ it("clears all filters", async () => {
74
+ const buttonEl = getButton("BioNetwork");
75
+ fireEvent.click(buttonEl);
76
+ // Wait for menu to open.
77
+ await waitFor(() => expect(getRole("menu")).toBeInTheDocument());
78
+ // Select all options.
79
+ const optionEls = within(getRole("menu")).getAllByRole("button");
80
+ optionEls.forEach(async (el) => {
81
+ fireEvent.click(el);
82
+ await waitFor(() => expect(el).toHaveClass(MUI_CLASSES.SELECTED));
83
+ });
84
+ // Select "Clear All" button.
85
+ const clearEl = getButton("Clear All");
86
+ fireEvent.click(clearEl);
87
+ // Wait for options to be deselected.
88
+ await waitFor(() =>
89
+ optionEls.forEach((el) =>
90
+ expect(el).not.toHaveClass(MUI_CLASSES.SELECTED)
91
+ )
92
+ );
93
+ });
94
+
95
+ it("disables Clear All when nothing selected", async () => {
96
+ const buttonEl = getButton("BioNetwork");
97
+ fireEvent.click(buttonEl);
98
+ await waitFor(() => expect(getRole("menu")).toBeInTheDocument());
99
+ expect(getButton("Clear All")).toHaveClass(MUI_CLASSES.DISABLED);
100
+ });
101
+ });
@@ -1,13 +0,0 @@
1
- import { ExploreState } from "../../../exploreState";
2
- /**
3
- * Updates the URL query parameters for the entity list page based on the current explore state.
4
- * Pushes the query to the router.
5
- * @param exploreState - The current explore state.
6
- */
7
- export declare function navigateToFilters(exploreState: ExploreState): void;
8
- /**
9
- * Updates the URL query parameters for the entity list page based on the current explore state.
10
- * Replaces the query to the router.
11
- * @param exploreState - The current explore state.
12
- */
13
- export declare function replaceToFilters(exploreState: ExploreState): void;
@@ -1,24 +0,0 @@
1
- import Router from "next/router";
2
- import { buildQuery } from "./utils";
3
- /**
4
- * Updates the URL query parameters for the entity list page based on the current explore state.
5
- * Pushes the query to the router.
6
- * @param exploreState - The current explore state.
7
- */
8
- export function navigateToFilters(exploreState) {
9
- // Build the query object.
10
- const query = buildQuery(exploreState);
11
- // Push the query to the router.
12
- Router.push({ query }, undefined, { shallow: true });
13
- }
14
- /**
15
- * Updates the URL query parameters for the entity list page based on the current explore state.
16
- * Replaces the query to the router.
17
- * @param exploreState - The current explore state.
18
- */
19
- export function replaceToFilters(exploreState) {
20
- // Build the query object.
21
- const query = buildQuery(exploreState);
22
- // Replace the query to the router.
23
- Router.replace({ query }, undefined, { shallow: true });
24
- }
@@ -1,4 +0,0 @@
1
- export declare enum META_COMMAND {
2
- NAVIGATE_TO_FILTERS = "NAVIGATE_TO_FILTERS",
3
- REPLACE_TO_FILTERS = "REPLACE_TO_FILTERS"
4
- }
@@ -1,5 +0,0 @@
1
- export var META_COMMAND;
2
- (function (META_COMMAND) {
3
- META_COMMAND["NAVIGATE_TO_FILTERS"] = "NAVIGATE_TO_FILTERS";
4
- META_COMMAND["REPLACE_TO_FILTERS"] = "REPLACE_TO_FILTERS";
5
- })(META_COMMAND || (META_COMMAND = {}));
@@ -1,2 +0,0 @@
1
- import { ExploreStateContextProps } from "../../../exploreState";
2
- export declare const useMetaCommands: ({ exploreDispatch, exploreState, }: ExploreStateContextProps) => void;
@@ -1,21 +0,0 @@
1
- import { useEffect } from "react";
2
- import { clearMeta } from "../../actions/clearMeta/dispatch";
3
- import { navigateToFilters, replaceToFilters } from "./actions";
4
- import { META_COMMAND } from "./types";
5
- export const useMetaCommands = ({ exploreDispatch, exploreState, }) => {
6
- useEffect(() => {
7
- const command = exploreState.meta?.command;
8
- switch (command) {
9
- case META_COMMAND.NAVIGATE_TO_FILTERS:
10
- navigateToFilters(exploreState);
11
- exploreDispatch(clearMeta());
12
- break;
13
- case META_COMMAND.REPLACE_TO_FILTERS:
14
- replaceToFilters(exploreState);
15
- exploreDispatch(clearMeta());
16
- break;
17
- default:
18
- break;
19
- }
20
- }, [exploreDispatch, exploreState]);
21
- };
@@ -1,9 +0,0 @@
1
- import { UrlObject } from "url";
2
- import { ExploreState } from "../../../exploreState";
3
- /**
4
- * Builds a query object from the current explore state.
5
- * Contains catalog, feature flag, filter, and entity list type.
6
- * @param exploreState - The current explore state.
7
- * @returns A query object.
8
- */
9
- export declare function buildQuery(exploreState: ExploreState): UrlObject["query"];
@@ -1,25 +0,0 @@
1
- import { EXPLORE_URL_PARAMS } from "../../../exploreState/constants";
2
- /**
3
- * Builds a query object from the current explore state.
4
- * Contains catalog, feature flag, filter, and entity list type.
5
- * @param exploreState - The current explore state.
6
- * @returns A query object.
7
- */
8
- export function buildQuery(exploreState) {
9
- const query = {};
10
- // Entity list type.
11
- query["entityListType"] = exploreState.tabValue;
12
- // Filter state.
13
- if (exploreState.filterState.length > 0) {
14
- query[EXPLORE_URL_PARAMS.FILTER] = JSON.stringify(exploreState.filterState);
15
- }
16
- // Catalog state.
17
- if (exploreState.catalogState) {
18
- query[EXPLORE_URL_PARAMS.CATALOG] = exploreState.catalogState;
19
- }
20
- // Feature flag state.
21
- if (exploreState.featureFlagState) {
22
- query[EXPLORE_URL_PARAMS.FEATURE_FLAG] = exploreState.featureFlagState;
23
- }
24
- return query;
25
- }
@@ -1,29 +0,0 @@
1
- import Router from "next/router";
2
- import { ExploreState } from "../../../exploreState";
3
- import { buildQuery } from "./utils";
4
-
5
- /**
6
- * Updates the URL query parameters for the entity list page based on the current explore state.
7
- * Pushes the query to the router.
8
- * @param exploreState - The current explore state.
9
- */
10
- export function navigateToFilters(exploreState: ExploreState): void {
11
- // Build the query object.
12
- const query = buildQuery(exploreState);
13
-
14
- // Push the query to the router.
15
- Router.push({ query }, undefined, { shallow: true });
16
- }
17
-
18
- /**
19
- * Updates the URL query parameters for the entity list page based on the current explore state.
20
- * Replaces the query to the router.
21
- * @param exploreState - The current explore state.
22
- */
23
- export function replaceToFilters(exploreState: ExploreState): void {
24
- // Build the query object.
25
- const query = buildQuery(exploreState);
26
-
27
- // Replace the query to the router.
28
- Router.replace({ query }, undefined, { shallow: true });
29
- }
@@ -1,4 +0,0 @@
1
- export enum META_COMMAND {
2
- NAVIGATE_TO_FILTERS = "NAVIGATE_TO_FILTERS",
3
- REPLACE_TO_FILTERS = "REPLACE_TO_FILTERS",
4
- }
@@ -1,27 +0,0 @@
1
- import { useEffect } from "react";
2
- import { ExploreStateContextProps } from "../../../exploreState";
3
- import { clearMeta } from "../../actions/clearMeta/dispatch";
4
- import { navigateToFilters, replaceToFilters } from "./actions";
5
- import { META_COMMAND } from "./types";
6
-
7
- export const useMetaCommands = ({
8
- exploreDispatch,
9
- exploreState,
10
- }: ExploreStateContextProps): void => {
11
- useEffect(() => {
12
- const command = exploreState.meta?.command;
13
-
14
- switch (command) {
15
- case META_COMMAND.NAVIGATE_TO_FILTERS:
16
- navigateToFilters(exploreState);
17
- exploreDispatch(clearMeta());
18
- break;
19
- case META_COMMAND.REPLACE_TO_FILTERS:
20
- replaceToFilters(exploreState);
21
- exploreDispatch(clearMeta());
22
- break;
23
- default:
24
- break;
25
- }
26
- }, [exploreDispatch, exploreState]);
27
- };
@@ -1,33 +0,0 @@
1
- import { UrlObject } from "url";
2
- import { ExploreState } from "../../../exploreState";
3
- import { EXPLORE_URL_PARAMS } from "../../../exploreState/constants";
4
-
5
- /**
6
- * Builds a query object from the current explore state.
7
- * Contains catalog, feature flag, filter, and entity list type.
8
- * @param exploreState - The current explore state.
9
- * @returns A query object.
10
- */
11
- export function buildQuery(exploreState: ExploreState): UrlObject["query"] {
12
- const query: UrlObject["query"] = {};
13
-
14
- // Entity list type.
15
- query["entityListType"] = exploreState.tabValue;
16
-
17
- // Filter state.
18
- if (exploreState.filterState.length > 0) {
19
- query[EXPLORE_URL_PARAMS.FILTER] = JSON.stringify(exploreState.filterState);
20
- }
21
-
22
- // Catalog state.
23
- if (exploreState.catalogState) {
24
- query[EXPLORE_URL_PARAMS.CATALOG] = exploreState.catalogState;
25
- }
26
-
27
- // Feature flag state.
28
- if (exploreState.featureFlagState) {
29
- query[EXPLORE_URL_PARAMS.FEATURE_FLAG] = exploreState.featureFlagState;
30
- }
31
-
32
- return query;
33
- }