Skip to content

Commit b1b66f2

Browse files
authored
fix(toolbar): sw-3443 productId key refresh (#1566)
* toolbar, productId key refresh component, align with toolbarFields * viewReducer, simplify focused query reset to hard reset
1 parent b036dd6 commit b1b66f2

File tree

3 files changed

+15
-38
lines changed

3 files changed

+15
-38
lines changed

src/components/toolbar/toolbar.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const Toolbar = ({
6262
useToolbarFieldClearAll: useAliasToolbarFieldClearAll = useToolbarFieldClearAll,
6363
useToolbarFields: useAliasToolbarFields = useToolbarFields
6464
}) => {
65-
const { productGroup } = useAliasProduct();
65+
const { productId } = useAliasProduct();
6666
const toolbarFieldQueries = useAliasProductToolbarQuery();
6767
const { currentCategory, options } = useAliasSelectCategoryOptions();
6868
const clearField = useAliasToolbarFieldClear();
@@ -115,7 +115,7 @@ const Toolbar = ({
115115
return (
116116
<PfToolbar
117117
id="curiosity-toolbar"
118-
key={productGroup}
118+
key={productId}
119119
className="curiosity-toolbar pf-m-toggle-group-container ins-c-primary-toolbar"
120120
collapseListedFiltersBreakpoint="sm"
121121
clearAllFilters={onClearAll}

src/redux/reducers/__tests__/__snapshots__/viewReducer.test.js.snap

+4-24
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,10 @@ exports[`ViewReducer should handle clearing state with defined types: defined ty
44
{
55
"result": {
66
"graphTallyQuery": {},
7-
"inventoryGuestsQuery": {
8-
"another_test_id": {
9-
"offset": 10,
10-
},
11-
},
12-
"inventoryHostsQuery": {
13-
"another_test_id": {
14-
"dir": "lorem desc direction",
15-
"offset": 90,
16-
"sort": "lorem sort",
17-
},
18-
},
19-
"inventorySubscriptionsQuery": {
20-
"another_test_id": {
21-
"dir": "dolor desc direction",
22-
"offset": 40,
23-
"sort": "dolor sort",
24-
},
25-
},
26-
"query": {
27-
"another_test_id": {
28-
"lorem": "ipsum",
29-
},
30-
},
7+
"inventoryGuestsQuery": {},
8+
"inventoryHostsQuery": {},
9+
"inventorySubscriptionsQuery": {},
10+
"query": {},
3111
},
3212
"type": "SET_PRODUCT_VARIANT_QUERY_RESET_ALL",
3313
}

src/redux/reducers/viewReducer.js

+9-12
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,20 @@ const initialState = {
3535
*/
3636
const viewReducer = (state = initialState, action) => {
3737
switch (action.type) {
38-
// Reset query state/object associated with a variant/productId
38+
/*
39+
* Note: Hard reset query state/object associated with a variant/productId. Remove this action type if restoring
40+
* queries based on product variant is needed, also review toolbar reducer for restoring/removing legend state.
41+
*/
3942
case reduxTypes.app.SET_PRODUCT_VARIANT_QUERY_RESET_ALL:
40-
const updateVariantResetQueries = (query = {}, id) => {
41-
const updatedQuery = query;
42-
delete updatedQuery[id];
43-
return updatedQuery;
44-
};
45-
4643
return reduxHelpers.setStateProp(
4744
null,
4845
{
4946
...state,
50-
query: updateVariantResetQueries(state.query, action.variant),
51-
graphTallyQuery: updateVariantResetQueries(state.graphTallyQuery, action.variant),
52-
inventoryGuestsQuery: updateVariantResetQueries(state.inventoryGuestsQuery, action.variant),
53-
inventoryHostsQuery: updateVariantResetQueries(state.inventoryHostsQuery, action.variant),
54-
inventorySubscriptionsQuery: updateVariantResetQueries(state.inventorySubscriptionsQuery, action.variant)
47+
query: {},
48+
graphTallyQuery: {},
49+
inventoryGuestsQuery: {},
50+
inventoryHostsQuery: {},
51+
inventorySubscriptionsQuery: {}
5552
},
5653
{
5754
state,

0 commit comments

Comments
 (0)