@databiosphere/findable-ui 2.1.0 → 3.0.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 (135) hide show
  1. package/lib/components/Detail/components/DetailViewTable/detailViewTable.js +1 -1
  2. package/lib/components/Filter/components/FilterLabel/filterLabel.styles.d.ts +1 -1
  3. package/lib/components/Filter/components/Filters/filters.d.ts +1 -1
  4. package/lib/components/Filter/components/Filters/filters.styles.js +1 -1
  5. package/lib/components/Filter/components/VariableSizeListItem/variableSizeListItem.js +2 -1
  6. package/lib/components/Index/index.d.ts +2 -1
  7. package/lib/components/Index/index.js +2 -2
  8. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/AuthenticationMenu/authenticationMenu.styles.d.ts +3 -3
  9. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.styles.d.ts +1 -1
  10. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchBar/searchBar.styles.d.ts +1 -1
  11. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.styles.d.ts +1 -1
  12. package/lib/components/Layout/components/Outline/components/ContentsTab/contentsTab.styles.d.ts +1 -1
  13. package/lib/components/Layout/components/Outline/outline.styles.d.ts +1 -1
  14. package/lib/components/Table/common/utils.d.ts +6 -0
  15. package/lib/components/Table/common/utils.js +12 -1
  16. package/lib/components/Table/components/CheckboxMenu/checkboxMenu.js +2 -2
  17. package/lib/components/Table/components/CheckboxMenu/checkboxMenu.styles.d.ts +1 -1
  18. package/lib/components/Table/components/CheckboxMenu/checkboxMenu.styles.js +3 -3
  19. package/lib/components/Table/components/TableCell/common/utils.d.ts +8 -0
  20. package/lib/components/Table/components/TableCell/common/utils.js +15 -0
  21. package/lib/components/Table/components/TableCell/components/RowSelectionCell/rowSelectionCell.d.ts +6 -0
  22. package/lib/components/Table/components/TableCell/components/RowSelectionCell/rowSelectionCell.js +15 -0
  23. package/lib/components/Table/components/TableHead/components/HeadSelectionCell/headSelectionCell.d.ts +6 -0
  24. package/lib/components/Table/components/TableHead/components/HeadSelectionCell/headSelectionCell.js +16 -0
  25. package/lib/components/Table/components/TableHead/tableHead.js +2 -2
  26. package/lib/components/Table/components/TableRows/tableRows.js +2 -3
  27. package/lib/components/Table/components/TableToolbar/components/RowSelection/components/DropdownMenu/dropdownMenu.d.ts +10 -0
  28. package/lib/components/Table/components/TableToolbar/components/RowSelection/components/DropdownMenu/dropdownMenu.js +37 -0
  29. package/lib/components/Table/components/TableToolbar/components/RowSelection/components/DropdownMenu/dropdownMenu.styles.d.ts +3 -0
  30. package/lib/components/Table/components/TableToolbar/components/RowSelection/components/DropdownMenu/dropdownMenu.styles.js +13 -0
  31. package/lib/components/Table/components/TableToolbar/components/RowSelection/rowSelection.d.ts +9 -0
  32. package/lib/components/Table/components/TableToolbar/components/RowSelection/rowSelection.js +19 -0
  33. package/lib/components/Table/components/TableToolbar/components/RowSelection/rowSelection.styles.d.ts +5 -0
  34. package/lib/components/Table/components/TableToolbar/components/RowSelection/rowSelection.styles.js +13 -0
  35. package/lib/components/Table/components/TableToolbar/tableToolbar.js +5 -5
  36. package/lib/components/Table/components/TableToolbar/tableToolbar.styles.d.ts +1 -5
  37. package/lib/components/Table/components/TableToolbar/tableToolbar.styles.js +10 -7
  38. package/lib/components/Table/table.d.ts +5 -2
  39. package/lib/components/Table/table.js +13 -2
  40. package/lib/components/TableCreator/common/constants.d.ts +6 -0
  41. package/lib/components/TableCreator/common/constants.js +22 -0
  42. package/lib/components/TableCreator/common/entities.d.ts +5 -0
  43. package/lib/components/TableCreator/common/entities.js +2 -0
  44. package/lib/components/TableCreator/common/utils.d.ts +8 -0
  45. package/lib/components/TableCreator/common/utils.js +24 -0
  46. package/lib/components/TableCreator/tableCreator.d.ts +3 -1
  47. package/lib/components/TableCreator/tableCreator.js +19 -34
  48. package/lib/components/common/Alert/components/AlertText/alertText.styles.d.ts +5 -0
  49. package/lib/components/common/Alert/components/AlertText/alertText.styles.js +25 -0
  50. package/lib/components/common/Button/components/DropdownButton/dropdownButton.d.ts +4 -2
  51. package/lib/components/common/Button/components/DropdownButton/dropdownButton.js +2 -2
  52. package/lib/components/common/Button/components/DropdownButton/dropdownButton.styles.d.ts +5 -1
  53. package/lib/components/common/Button/components/DropdownButton/dropdownButton.styles.js +24 -1
  54. package/lib/components/common/CustomIcon/components/IndeterminateIcon/indeterminateIcon.d.ts +6 -0
  55. package/lib/components/common/CustomIcon/components/IndeterminateIcon/indeterminateIcon.js +29 -0
  56. package/lib/components/common/Dialog/dialog.d.ts +7 -0
  57. package/lib/components/common/Dialog/dialog.js +24 -0
  58. package/lib/components/common/DropdownMenu/common/constants.d.ts +2 -0
  59. package/lib/components/common/DropdownMenu/common/constants.js +8 -0
  60. package/lib/components/common/DropdownMenu/common/entities.d.ts +10 -0
  61. package/lib/components/common/DropdownMenu/common/entities.js +2 -0
  62. package/lib/components/common/DropdownMenu/components/MenuItem/menuItem.d.ts +7 -0
  63. package/lib/components/common/DropdownMenu/components/MenuItem/menuItem.js +25 -0
  64. package/lib/components/common/DropdownMenu/dropdownMenu.d.ts +9 -0
  65. package/lib/components/common/DropdownMenu/dropdownMenu.js +49 -0
  66. package/lib/components/common/DropdownMenu/dropdownMenu.styles.d.ts +3 -0
  67. package/lib/components/common/DropdownMenu/dropdownMenu.styles.js +13 -0
  68. package/lib/components/common/IconButton/iconButton.d.ts +4 -3
  69. package/lib/components/common/IconButton/iconButton.js +4 -4
  70. package/lib/components/common/IconButton/iconButton.styles.d.ts +34 -0
  71. package/lib/components/common/IconButton/iconButton.styles.js +27 -1
  72. package/lib/components/common/Tabs/tabs.styles.d.ts +1 -1
  73. package/lib/config/entities.d.ts +9 -1
  74. package/lib/providers/exploreState/constants.d.ts +3 -3
  75. package/lib/providers/exploreState/constants.js +3 -26
  76. package/lib/providers/exploreState/entities.d.ts +16 -5
  77. package/lib/providers/exploreState/initializer/constants.js +2 -0
  78. package/lib/providers/exploreState/initializer/utils.js +77 -5
  79. package/lib/providers/exploreState/payloads/entities.d.ts +32 -6
  80. package/lib/providers/exploreState/utils.d.ts +65 -11
  81. package/lib/providers/exploreState/utils.js +126 -15
  82. package/lib/providers/exploreState.d.ts +39 -7
  83. package/lib/providers/exploreState.js +58 -11
  84. package/lib/theme/common/components.js +4 -0
  85. package/lib/views/ExploreView/exploreView.d.ts +3 -1
  86. package/lib/views/ExploreView/exploreView.js +17 -11
  87. package/package.json +1 -1
  88. package/src/components/Detail/components/DetailViewTable/detailViewTable.tsx +2 -2
  89. package/src/components/Filter/components/Filters/filters.styles.ts +1 -1
  90. package/src/components/Filter/components/Filters/filters.tsx +1 -1
  91. package/src/components/Filter/components/VariableSizeListItem/variableSizeListItem.tsx +6 -3
  92. package/src/components/Index/index.tsx +3 -1
  93. package/src/components/Table/common/utils.ts +17 -0
  94. package/src/components/Table/components/CheckboxMenu/checkboxMenu.styles.ts +3 -3
  95. package/src/components/Table/components/CheckboxMenu/checkboxMenu.tsx +4 -2
  96. package/src/components/Table/components/TableCell/common/utils.ts +16 -0
  97. package/src/components/Table/components/TableCell/components/RowSelectionCell/rowSelectionCell.tsx +24 -0
  98. package/src/components/Table/components/TableHead/components/HeadSelectionCell/headSelectionCell.tsx +31 -0
  99. package/src/components/Table/components/TableHead/tableHead.tsx +18 -7
  100. package/src/components/Table/components/TableRows/tableRows.tsx +10 -8
  101. package/src/components/Table/components/TableToolbar/components/RowSelection/components/DropdownMenu/dropdownMenu.styles.ts +8 -0
  102. package/src/components/Table/components/TableToolbar/components/RowSelection/components/DropdownMenu/dropdownMenu.tsx +50 -0
  103. package/src/components/Table/components/TableToolbar/components/RowSelection/rowSelection.styles.ts +8 -0
  104. package/src/components/Table/components/TableToolbar/components/RowSelection/rowSelection.tsx +30 -0
  105. package/src/components/Table/components/TableToolbar/tableToolbar.styles.ts +10 -7
  106. package/src/components/Table/components/TableToolbar/tableToolbar.tsx +11 -8
  107. package/src/components/Table/table.tsx +18 -1
  108. package/src/components/TableCreator/common/constants.ts +26 -0
  109. package/src/components/TableCreator/common/entities.ts +6 -0
  110. package/src/components/TableCreator/common/utils.ts +33 -0
  111. package/src/components/TableCreator/tableCreator.tsx +38 -17
  112. package/src/components/common/Alert/components/AlertText/alertText.styles.ts +20 -0
  113. package/src/components/common/Button/components/DropdownButton/dropdownButton.styles.ts +15 -1
  114. package/src/components/common/Button/components/DropdownButton/dropdownButton.tsx +10 -2
  115. package/src/components/common/CustomIcon/components/IndeterminateIcon/indeterminateIcon.tsx +23 -0
  116. package/src/components/common/Dialog/dialog.tsx +21 -0
  117. package/src/components/common/DropdownMenu/common/constants.ts +7 -0
  118. package/src/components/common/DropdownMenu/common/entities.ts +11 -0
  119. package/src/components/common/DropdownMenu/components/MenuItem/menuItem.tsx +24 -0
  120. package/src/components/common/DropdownMenu/dropdownMenu.styles.ts +8 -0
  121. package/src/components/common/DropdownMenu/dropdownMenu.tsx +48 -0
  122. package/src/components/common/IconButton/iconButton.styles.ts +18 -0
  123. package/src/components/common/IconButton/iconButton.tsx +10 -11
  124. package/src/config/entities.ts +13 -1
  125. package/src/providers/exploreState/constants.ts +3 -0
  126. package/src/providers/exploreState/entities.ts +28 -4
  127. package/src/providers/exploreState/initializer/constants.ts +2 -0
  128. package/src/providers/exploreState/initializer/utils.ts +94 -3
  129. package/src/providers/exploreState/payloads/entities.ts +41 -7
  130. package/src/providers/exploreState/utils.ts +185 -21
  131. package/src/providers/exploreState.tsx +155 -21
  132. package/src/theme/common/components.ts +4 -0
  133. package/src/views/ExploreView/exploreView.tsx +22 -10
  134. package/types/data-explorer-ui.d.ts +10 -0
  135. package/src/components/Table/components/EntityViewToggle/entityViewToggle.tsx +0 -36
@@ -1,14 +1,54 @@
1
- import { SelectedFilter } from "../../common/entities";
2
- import { CategoryConfig } from "../../config/entities";
3
- import { ExploreState, PaginationState } from "../exploreState";
1
+ import { ColumnSort } from "@tanstack/react-table";
2
+ import {
3
+ CategoryKey,
4
+ CategoryValueKey,
5
+ SelectedFilter,
6
+ } from "../../common/entities";
7
+ import { ACCESSOR_KEYS } from "../../components/TableCreator/common/constants";
8
+ import { ExploreState, ListItems, PaginationState } from "../exploreState";
4
9
  import {
5
10
  CategoryGroupConfigKey,
6
11
  EntityPageState,
7
12
  EntityPageStateMapper,
8
13
  EntityState,
14
+ EntityStateSavedFilter,
15
+ ListItem,
9
16
  } from "./entities";
10
17
  import { DEFAULT_ENTITY_STATE } from "./initializer/constants";
11
18
 
19
+ /**
20
+ * Returns the entity state saved filter state for the given category key.
21
+ * @param categoryKey - Category key.
22
+ * @param selectedValue - Key of category value that has been de/selected.
23
+ * @param selected - True if value is selected, false if de-selected.
24
+ * @returns entity state saved filter state.
25
+ */
26
+ export function buildEntityStateSavedFilterState(
27
+ categoryKey: CategoryKey,
28
+ selectedValue: CategoryValueKey,
29
+ selected: boolean
30
+ ): SelectedFilter[] {
31
+ if (!selected) return [];
32
+ return [{ categoryKey, value: [selectedValue] }];
33
+ }
34
+
35
+ /**
36
+ * Build new set of selected filters on de/select of a "saved filter" filter.
37
+ * @param state - Explore state.
38
+ * @param selectedValue - Key of category value that has been de/selected.
39
+ * @param selected - True if value is selected, false if de-selected.
40
+ * @returns new selected filters.
41
+ */
42
+ export function buildNextSavedFilterState(
43
+ state: ExploreState,
44
+ selectedValue: CategoryValueKey,
45
+ selected: boolean
46
+ ): SelectedFilter[] {
47
+ if (!selected) return []; // Clears all filters on de-select of saved filter.
48
+ const savedFilter = getEntityStateSavedFilter(state, selectedValue);
49
+ return savedFilter?.filters || [];
50
+ }
51
+
12
52
  /**
13
53
  * Returns the category group config key for the current entity.
14
54
  * @param entityPath - Entity path.
@@ -23,28 +63,17 @@ export function getEntityCategoryGroupConfigKey(
23
63
  }
24
64
 
25
65
  /**
26
- * Returns the category configs for the current entity.
66
+ * Returns the entity state for the current entity.
27
67
  * @param state - Explore state.
28
- * @returns category configs.
29
- */
30
- export function getEntityCategoryConfigs(
31
- state: ExploreState
32
- ): CategoryConfig[] | undefined {
33
- return getEntityState(
34
- getEntityCategoryGroupConfigKey(state.tabValue, state.entityPageState),
35
- state
36
- ).categoryConfigs;
37
- }
38
-
39
- /**
40
- * Returns the entity state for the given category group config key.
41
68
  * @param categoryGroupConfigKey - Category group config key.
42
- * @param state - Explore state.
43
69
  * @returns entity state.
44
70
  */
45
71
  export function getEntityState(
46
- categoryGroupConfigKey: CategoryGroupConfigKey,
47
- state: ExploreState
72
+ state: ExploreState,
73
+ categoryGroupConfigKey = getEntityCategoryGroupConfigKey(
74
+ state.tabValue,
75
+ state.entityPageState
76
+ )
48
77
  ): EntityState {
49
78
  return (
50
79
  state.entityStateByCategoryGroupConfigKey.get(categoryGroupConfigKey) ||
@@ -52,6 +81,37 @@ export function getEntityState(
52
81
  );
53
82
  }
54
83
 
84
+ /**
85
+ * Returns the saved filter/sorting for the given category key.
86
+ * @param state - Explore state.
87
+ * @param categoryValueKey - Category key.
88
+ * @returns saved filter/sorting for the category key.
89
+ */
90
+ export function getEntityStateSavedFilter(
91
+ state: ExploreState,
92
+ categoryValueKey: CategoryValueKey
93
+ ): EntityStateSavedFilter | undefined {
94
+ const entityState = getEntityState(state);
95
+ return entityState.savedFilterByCategoryValueKey?.get(categoryValueKey);
96
+ }
97
+
98
+ /**
99
+ * Returns entity state "saved filter" sorting for the given category value key.
100
+ * @param state - Explore state.
101
+ * @param selectedValue - Key of category value that has been de/selected.
102
+ * @param selected - True if value is selected, false if de-selected.
103
+ * @returns sorting.
104
+ */
105
+ export function getEntityStateSavedSorting(
106
+ state: ExploreState,
107
+ selectedValue: CategoryValueKey,
108
+ selected: boolean
109
+ ): ColumnSort[] | undefined {
110
+ if (!selected) return;
111
+ const savedFilter = getEntityStateSavedFilter(state, selectedValue);
112
+ return savedFilter?.sorting;
113
+ }
114
+
55
115
  /**
56
116
  * Returns the filter count.
57
117
  * @param filterState - Filter state.
@@ -61,6 +121,28 @@ export function getFilterCount(filterState: SelectedFilter[]): number {
61
121
  return filterState.reduce((acc, filter) => acc + filter.value.length, 0);
62
122
  }
63
123
 
124
+ /**
125
+ * Returns list items with updated list items patched.
126
+ * @param listItems - List items.
127
+ * @param updatedListItems - List items to patch.
128
+ * @param listItemKey - List item key identifier to map list items.
129
+ * @returns list items with updated list items patched.
130
+ */
131
+ export function patchEntityListItems(
132
+ listItems: ListItems,
133
+ updatedListItems: ListItems,
134
+ listItemKey: keyof ListItem
135
+ ): ListItems {
136
+ if (!listItems || !updatedListItems) return listItems;
137
+ const listItemById = new Map(
138
+ listItems.map((listItem) => [listItem[listItemKey], listItem])
139
+ );
140
+ updatedListItems.forEach((listItem) => {
141
+ listItemById.set(listItem[listItemKey], listItem);
142
+ });
143
+ return [...listItemById.values()];
144
+ }
145
+
64
146
  /**
65
147
  * Resets pagination.
66
148
  * @param paginationState - Pagination state.
@@ -73,6 +155,30 @@ export function resetPage(paginationState: PaginationState): PaginationState {
73
155
  return nextPaginationState;
74
156
  }
75
157
 
158
+ /**
159
+ * Resets row selection for the current entity and entities that share the same category group config key.
160
+ * @param state - Explore state.
161
+ * @returns entity page state mapper with row selection reset.
162
+ */
163
+ export function resetRowSelection(state: ExploreState): EntityPageStateMapper {
164
+ const categoryGroupConfigKey = getEntityCategoryGroupConfigKey(
165
+ state.tabValue,
166
+ state.entityPageState
167
+ );
168
+ return Object.entries(state.entityPageState).reduce(
169
+ (acc, [entityPath, entityPageState]) => {
170
+ if (entityPageState.categoryGroupConfigKey === categoryGroupConfigKey) {
171
+ return {
172
+ ...acc,
173
+ [entityPath]: { ...entityPageState, rowSelection: {} },
174
+ };
175
+ }
176
+ return { ...acc, [entityPath]: entityPageState };
177
+ },
178
+ {} as EntityPageStateMapper
179
+ );
180
+ }
181
+
76
182
  /**
77
183
  * Sets entity state for the given category group config key.
78
184
  * @param categoryGroupConfigKey - Category group config key.
@@ -111,6 +217,32 @@ export function updateEntityPageState(
111
217
  };
112
218
  }
113
219
 
220
+ /**
221
+ * Updates entity page state sorting for all entities with the same category group config key.
222
+ * @param state - Explore state.
223
+ * @param sorting - Sorting.
224
+ * @returns entity page state.
225
+ */
226
+ export function updateEntityPageStateSorting(
227
+ state: ExploreState,
228
+ sorting?: EntityPageState["sorting"]
229
+ ): EntityPageStateMapper {
230
+ if (!sorting) return state.entityPageState;
231
+ const categoryGroupConfigKey = getEntityCategoryGroupConfigKey(
232
+ state.tabValue,
233
+ state.entityPageState
234
+ );
235
+ return Object.entries(state.entityPageState).reduce(
236
+ (acc, [entityPath, entityPageState]) => {
237
+ if (entityPageState.categoryGroupConfigKey === categoryGroupConfigKey) {
238
+ return { ...acc, [entityPath]: { ...entityPageState, sorting } };
239
+ }
240
+ return { ...acc, [entityPath]: entityPageState };
241
+ },
242
+ {} as EntityPageStateMapper
243
+ );
244
+ }
245
+
114
246
  /**
115
247
  * Updates entity state by category group config key.
116
248
  * @param state - Explore state.
@@ -125,7 +257,7 @@ export function updateEntityStateByCategoryGroupConfigKey(
125
257
  state.tabValue,
126
258
  state.entityPageState
127
259
  );
128
- const entityState = getEntityState(categoryGroupConfigKey, state);
260
+ const entityState = getEntityState(state, categoryGroupConfigKey);
129
261
  if (entityState) {
130
262
  setEntityStateByCategoryGroupConfigKey(categoryGroupConfigKey, state, {
131
263
  ...entityState,
@@ -133,3 +265,35 @@ export function updateEntityStateByCategoryGroupConfigKey(
133
265
  });
134
266
  }
135
267
  }
268
+
269
+ /**
270
+ * Updates the entity page state for each entity with row selection enabled,
271
+ * by updating the visibility of the "select" column based on user access and resetting row selection state.
272
+ * @param state - Explore state.
273
+ * @param canEdit - User has edit access.
274
+ * @returns new entity page state mapper with updated column visibility and row selection state.
275
+ */
276
+ export function updateSelectColumnVisibility(
277
+ state: ExploreState,
278
+ canEdit: boolean
279
+ ): EntityPageStateMapper {
280
+ return Object.entries(state.entityPageState).reduce(
281
+ (acc, [entityPath, entityPageState]) => {
282
+ if (entityPageState.enableRowSelection) {
283
+ return {
284
+ ...acc,
285
+ [entityPath]: {
286
+ ...entityPageState,
287
+ columnsVisibility: {
288
+ ...entityPageState.columnsVisibility,
289
+ [ACCESSOR_KEYS.SELECT]: canEdit,
290
+ },
291
+ rowSelection: {},
292
+ },
293
+ };
294
+ }
295
+ return { ...acc, [entityPath]: entityPageState };
296
+ },
297
+ {} as EntityPageStateMapper
298
+ );
299
+ }
@@ -8,7 +8,7 @@ import React, {
8
8
  useState,
9
9
  } from "react";
10
10
  import { AzulSearchIndex } from "../apis/azul/common/entities";
11
- import { SelectCategory, SelectedFilter } from "../common/entities";
11
+ import { SelectCategoryView, SelectedFilter } from "../common/entities";
12
12
  import { CategoryGroup, SiteConfig } from "../config/entities";
13
13
  import { useAuthentication } from "../hooks/useAuthentication/useAuthentication";
14
14
  import {
@@ -20,6 +20,7 @@ import { useURLFilterParams } from "../hooks/useURLFilterParams";
20
20
  import {
21
21
  EntityPageStateMapper,
22
22
  EntityStateByCategoryGroupConfigKey,
23
+ ListItem,
23
24
  } from "./exploreState/entities";
24
25
  import {
25
26
  DEFAULT_PAGINATION_STATE,
@@ -27,23 +28,33 @@ import {
27
28
  } from "./exploreState/initializer/constants";
28
29
  import { initReducerArguments } from "./exploreState/initializer/utils";
29
30
  import {
31
+ ApplySavedFilterPayload,
30
32
  PaginateTablePayload,
33
+ PatchExploreResponsePayload,
31
34
  ProcessExploreResponsePayload,
32
35
  ProcessRelatedResponsePayload,
33
36
  ResetExploreResponsePayload,
34
37
  ToggleEntityViewPayload,
35
38
  UpdateColumnVisibilityPayload,
39
+ UpdateEntityViewAccessPayload,
36
40
  UpdateFilterPayload,
41
+ UpdateRowSelectionPayload,
37
42
  UpdateSortingPayload,
38
43
  } from "./exploreState/payloads/entities";
39
44
  import {
40
- getEntityCategoryConfigs,
45
+ buildEntityStateSavedFilterState,
46
+ buildNextSavedFilterState,
41
47
  getEntityCategoryGroupConfigKey,
42
48
  getEntityState,
49
+ getEntityStateSavedSorting,
43
50
  getFilterCount,
51
+ patchEntityListItems,
44
52
  resetPage,
53
+ resetRowSelection,
45
54
  updateEntityPageState,
55
+ updateEntityPageStateSorting,
46
56
  updateEntityStateByCategoryGroupConfigKey,
57
+ updateSelectColumnVisibility,
47
58
  } from "./exploreState/utils";
48
59
 
49
60
  export type CatalogState = string | undefined;
@@ -70,7 +81,7 @@ export interface ExploreContext {
70
81
  export type ExploreState = {
71
82
  catalogState: CatalogState;
72
83
  categoryGroups?: CategoryGroup[];
73
- categoryViews: SelectCategory[];
84
+ categoryViews: SelectCategoryView[];
74
85
  entityPageState: EntityPageStateMapper;
75
86
  entityStateByCategoryGroupConfigKey: EntityStateByCategoryGroupConfigKey;
76
87
  featureFlagState: FeatureFlagState;
@@ -98,8 +109,7 @@ export type FeatureFlagState = string | undefined;
98
109
  /**
99
110
  * List items.
100
111
  */
101
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO revisit when adding react query or similar
102
- export type ListItems = any[] | undefined;
112
+ export type ListItems = ListItem[] | undefined;
103
113
 
104
114
  /**
105
115
  * Pagination index.
@@ -218,8 +228,10 @@ export function ExploreStateProvider({
218
228
  * Explore action kind.
219
229
  */
220
230
  export enum ExploreActionKind {
231
+ ApplySavedFilter = "APPLY_SAVED_FILTER",
221
232
  ClearFilters = "CLEAR_FILTERS",
222
233
  PaginateTable = "PAGINATE_TABLE",
234
+ PatchExploreResponse = "PATCH_EXPLORE_RESPONSE",
223
235
  ProcessExploreResponse = "PROCESS_EXPLORE_RESPONSE",
224
236
  ProcessRelatedResponse = "PROCESS_RELATED_RESPONSE",
225
237
  ResetExploreResponse = "RESET_EXPLORE_RESPONSE",
@@ -227,7 +239,9 @@ export enum ExploreActionKind {
227
239
  SelectEntityType = "SELECT_ENTITY_TYPE",
228
240
  ToggleEntityView = "TOGGLE_ENTITY_VIEW",
229
241
  UpdateColumnVisibility = "UPDATE_COLUMN_VISIBILITY",
242
+ UpdateEntityViewAccess = "UPDATE_ENTITY_VIEW_ACCESS",
230
243
  UpdateFilter = "UPDATE_FILTER",
244
+ UpdateRowSelection = "UPDATE_ROW_SELECTION",
231
245
  UpdateSorting = "UPDATE_SORTING",
232
246
  }
233
247
 
@@ -235,8 +249,10 @@ export enum ExploreActionKind {
235
249
  * Explore action.
236
250
  */
237
251
  export type ExploreAction =
252
+ | ApplySavedFilterAction
238
253
  | ClearFiltersAction
239
254
  | PaginateTableAction
255
+ | PatchExploreResponseAction
240
256
  | ProcessExploreResponseAction
241
257
  | ProcessRelatedResponseAction
242
258
  | ResetExploreResponseAction
@@ -244,9 +260,19 @@ export type ExploreAction =
244
260
  | SelectEntityTypeAction
245
261
  | ToggleEntityViewAction
246
262
  | UpdateColumnVisibilityAction
263
+ | UpdateEntityViewAccessAction
247
264
  | UpdateFilterAction
265
+ | UpdateRowSelectionAction
248
266
  | UpdateSortingAction;
249
267
 
268
+ /**
269
+ * Apply saved filter action.
270
+ */
271
+ type ApplySavedFilterAction = {
272
+ payload: ApplySavedFilterPayload;
273
+ type: ExploreActionKind.ApplySavedFilter;
274
+ };
275
+
250
276
  /**
251
277
  * Clear filters action.
252
278
  */
@@ -263,6 +289,14 @@ type PaginateTableAction = {
263
289
  type: ExploreActionKind.PaginateTable;
264
290
  };
265
291
 
292
+ /**
293
+ * Patch explore response action.
294
+ */
295
+ type PatchExploreResponseAction = {
296
+ payload: PatchExploreResponsePayload;
297
+ type: ExploreActionKind.PatchExploreResponse;
298
+ };
299
+
266
300
  /**
267
301
  * Process explore response action.
268
302
  */
@@ -304,7 +338,7 @@ type SelectEntityTypeAction = {
304
338
  };
305
339
 
306
340
  /**
307
- * Toggle entity view.
341
+ * Toggle entity view action.
308
342
  */
309
343
  type ToggleEntityViewAction = {
310
344
  payload: ToggleEntityViewPayload;
@@ -319,6 +353,14 @@ type UpdateColumnVisibilityAction = {
319
353
  type: ExploreActionKind.UpdateColumnVisibility;
320
354
  };
321
355
 
356
+ /**
357
+ * Update entity view access action.
358
+ */
359
+ type UpdateEntityViewAccessAction = {
360
+ payload: UpdateEntityViewAccessPayload;
361
+ type: ExploreActionKind.UpdateEntityViewAccess;
362
+ };
363
+
322
364
  /**
323
365
  * Update filter action.
324
366
  */
@@ -327,6 +369,14 @@ type UpdateFilterAction = {
327
369
  type: ExploreActionKind.UpdateFilter;
328
370
  };
329
371
 
372
+ /**
373
+ * Update row selection action.
374
+ */
375
+ type UpdateRowSelectionAction = {
376
+ payload: UpdateRowSelectionPayload;
377
+ type: ExploreActionKind.UpdateRowSelection;
378
+ };
379
+
330
380
  /**
331
381
  * Update sorting action.
332
382
  */
@@ -351,13 +401,48 @@ function exploreReducer(
351
401
  const { config, entityList } = exploreContext;
352
402
 
353
403
  switch (type) {
404
+ /**
405
+ * Apply saved filter
406
+ **/
407
+ case ExploreActionKind.ApplySavedFilter: {
408
+ const filterState = buildNextSavedFilterState(
409
+ state,
410
+ payload.selectedValue,
411
+ payload.selected
412
+ );
413
+ const savedFilterState = buildEntityStateSavedFilterState(
414
+ payload.categoryKey,
415
+ payload.selectedValue,
416
+ payload.selected
417
+ );
418
+ const savedSorting = getEntityStateSavedSorting(
419
+ state,
420
+ payload.selectedValue,
421
+ payload.selected
422
+ );
423
+ updateEntityStateByCategoryGroupConfigKey(state, {
424
+ filterState,
425
+ savedFilterState,
426
+ });
427
+ return {
428
+ ...state,
429
+ entityPageState: updateEntityPageStateSorting(state, savedSorting),
430
+ filterCount: getFilterCount(filterState),
431
+ filterState,
432
+ paginationState: resetPage(state.paginationState),
433
+ };
434
+ }
354
435
  /**
355
436
  * Clear all filters
356
437
  **/
357
438
  case ExploreActionKind.ClearFilters: {
358
439
  const filterCount = 0;
359
440
  const filterState: SelectedFilter[] = [];
360
- updateEntityStateByCategoryGroupConfigKey(state, { filterState });
441
+ const savedFilterState: SelectedFilter[] = [];
442
+ updateEntityStateByCategoryGroupConfigKey(state, {
443
+ filterState,
444
+ savedFilterState,
445
+ });
361
446
  return {
362
447
  ...state,
363
448
  filterCount,
@@ -382,15 +467,37 @@ function exploreReducer(
382
467
  paginationState: nextPaginationState,
383
468
  };
384
469
  }
470
+ /**
471
+ * Patch explore response
472
+ */
473
+ case ExploreActionKind.PatchExploreResponse: {
474
+ return {
475
+ ...state,
476
+ entityPageState: updateEntityPageState(
477
+ state.tabValue,
478
+ state.entityPageState,
479
+ { rowSelection: {} }
480
+ ),
481
+ listItems: patchEntityListItems(
482
+ state.listItems,
483
+ payload.updatedListItems,
484
+ payload.listItemKey
485
+ ),
486
+ };
487
+ }
385
488
  /**
386
489
  * Process explore response
387
490
  **/
388
491
  case ExploreActionKind.ProcessExploreResponse: {
492
+ const entityState = getEntityState(state);
389
493
  const nextCategoryViews = payload.selectCategories
390
494
  ? buildCategoryViews(
391
- payload.selectCategories,
392
- getEntityCategoryConfigs(state),
393
- state.filterState
495
+ [
496
+ ...payload.selectCategories,
497
+ ...entityState.savedSelectCategories, // "savedFilter" select categories are built from config at reducer initialization.
498
+ ],
499
+ entityState.categoryConfigs,
500
+ [...state.filterState, ...entityState.savedFilterState]
394
501
  )
395
502
  : state.categoryViews;
396
503
  updateEntityStateByCategoryGroupConfigKey(state, {
@@ -441,8 +548,8 @@ function exploreReducer(
441
548
  return state;
442
549
  }
443
550
  const entityState = getEntityState(
444
- getEntityCategoryGroupConfigKey(payload, state.entityPageState),
445
- state
551
+ state,
552
+ getEntityCategoryGroupConfigKey(payload, state.entityPageState)
446
553
  );
447
554
  return {
448
555
  ...state,
@@ -466,6 +573,28 @@ function exploreReducer(
466
573
  listView: payload,
467
574
  };
468
575
  }
576
+ /**
577
+ * Update column visibility
578
+ **/
579
+ case ExploreActionKind.UpdateColumnVisibility: {
580
+ return {
581
+ ...state,
582
+ entityPageState: updateEntityPageState(
583
+ state.tabValue,
584
+ state.entityPageState,
585
+ { columnsVisibility: payload }
586
+ ),
587
+ };
588
+ }
589
+ /**
590
+ * Update entity view access
591
+ **/
592
+ case ExploreActionKind.UpdateEntityViewAccess: {
593
+ return {
594
+ ...state,
595
+ entityPageState: updateSelectColumnVisibility(state, payload.canEdit),
596
+ };
597
+ }
469
598
  /**
470
599
  * Update filter
471
600
  **/
@@ -476,39 +605,44 @@ function exploreReducer(
476
605
  payload.selectedValue,
477
606
  payload.selected
478
607
  );
479
- updateEntityStateByCategoryGroupConfigKey(state, { filterState });
608
+ const savedFilterState: SelectedFilter[] = []; // Clear saved filter state.
609
+ updateEntityStateByCategoryGroupConfigKey(state, {
610
+ filterState,
611
+ savedFilterState,
612
+ });
480
613
  return {
481
614
  ...state,
615
+ entityPageState: resetRowSelection(state),
482
616
  filterCount: getFilterCount(filterState),
483
617
  filterState,
484
618
  paginationState: resetPage(state.paginationState),
485
619
  };
486
620
  }
487
621
  /**
488
- * Update sorting
489
- **/
490
- case ExploreActionKind.UpdateSorting: {
622
+ * Update row selection
623
+ */
624
+ case ExploreActionKind.UpdateRowSelection: {
491
625
  return {
492
626
  ...state,
493
627
  entityPageState: updateEntityPageState(
494
628
  state.tabValue,
495
629
  state.entityPageState,
496
- { sorting: payload }
630
+ { rowSelection: payload }
497
631
  ),
498
- paginationState: resetPage(state.paginationState),
499
632
  };
500
633
  }
501
634
  /**
502
- * Update column visibility
635
+ * Update sorting
503
636
  **/
504
- case ExploreActionKind.UpdateColumnVisibility: {
637
+ case ExploreActionKind.UpdateSorting: {
505
638
  return {
506
639
  ...state,
507
640
  entityPageState: updateEntityPageState(
508
641
  state.tabValue,
509
642
  state.entityPageState,
510
- { columnsVisibility: payload }
643
+ { sorting: payload }
511
644
  ),
645
+ paginationState: resetPage(state.paginationState),
512
646
  };
513
647
  }
514
648
 
@@ -1324,6 +1324,10 @@ export const MuiTableCell = (theme: Theme): Components["MuiTableCell"] => {
1324
1324
  ...theme.typography[TEXT_BODY_SMALL_500],
1325
1325
  padding: "20px",
1326
1326
  },
1327
+ paddingCheckbox: {
1328
+ paddingRight: 0,
1329
+ width: "unset",
1330
+ },
1327
1331
  root: {
1328
1332
  padding: "18px 20px",
1329
1333
  },