Skip to content

Commit

Permalink
fix(bannerMessages): issues/541 state updates for filters (#565)
Browse files Browse the repository at this point in the history
* appMessagesSelectors, adjust query to update
* productView, var/props name consistency
  • Loading branch information
cdcabrera committed Jan 27, 2021
1 parent 47e3884 commit b514590
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ exports[`ProductView Component should render a non-connected component: non-conn
>
<Connect(BannerMessages)
productId="lorem ipsum"
query={Object {}}
viewId="dolor sit"
/>
</PageMessages>
Expand Down
7 changes: 4 additions & 3 deletions src/components/productView/productView.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ const ProductView = ({ productConfig, routeDetail, t }) => {
} = productConfig;

const {
query: initialQuery,
graphTallyQuery: initialGraphTallyQuery,
inventoryHostsQuery: initialInventoryHostsQuery,
inventorySubscriptionsQuery: initialInventorySubscriptionsQuery,
toolbarQuery
toolbarQuery: initialToolbarQuery
} = apiQueries.parseRhsmQuery(query, { graphTallyQuery, inventoryHostsQuery, inventorySubscriptionsQuery });

const { pathParameter: productId, productParameter: productLabel, viewParameter: viewId } = routeDetail;
Expand All @@ -75,13 +76,13 @@ const ProductView = ({ productConfig, routeDetail, t }) => {
{t(`curiosity-view.title`, { appName: helpers.UI_DISPLAY_NAME, context: productLabel })}
</PageHeader>
<PageMessages>
<BannerMessages productId={productId} viewId={viewId} query={query} />
<BannerMessages productId={productId} viewId={viewId} query={initialQuery} />
</PageMessages>
<PageToolbar>
<ConnectedToolbar
filterOptions={initialToolbarFilters}
productId={productId}
query={toolbarQuery}
query={initialToolbarQuery}
viewId={viewId}
/>
</PageToolbar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,62 +4,62 @@ exports[`AppMessagesSelectors should map a fulfilled product ID response to an a
Object {
"appMessages": Object {
"cloudigradeMismatch": true,
"query": Object {},
},
"query": Object {},
}
`;

exports[`AppMessagesSelectors should pass minimal data on a product ID without a product ID provided: no product id error 1`] = `
Object {
"appMessages": Object {
"cloudigradeMismatch": false,
"query": Object {},
},
"query": Object {},
}
`;

exports[`AppMessagesSelectors should pass minimal data on missing a reducer response: missing reducer error 1`] = `
Object {
"appMessages": Object {
"cloudigradeMismatch": false,
"query": Object {},
},
"query": Object {},
}
`;

exports[`AppMessagesSelectors should populate data from the in memory cache: cached data: cache used and pending 1`] = `
Object {
"appMessages": Object {
"cloudigradeMismatch": true,
"query": Object {},
},
"query": Object {},
}
`;

exports[`AppMessagesSelectors should populate data from the in memory cache: cached data: initial fulfilled 1`] = `
Object {
"appMessages": Object {
"cloudigradeMismatch": true,
"query": Object {},
},
"query": Object {},
}
`;

exports[`AppMessagesSelectors should populate data from the in memory cache: cached data: update and fulfilled 1`] = `
Object {
"appMessages": Object {
"cloudigradeMismatch": true,
"query": Object {},
},
"query": Object {},
}
`;

exports[`AppMessagesSelectors should populate data on a product ID when the api response is missing expected properties: data populated, missing properties 1`] = `
Object {
"appMessages": Object {
"cloudigradeMismatch": false,
"query": Object {},
},
"query": Object {},
}
`;

Expand Down
5 changes: 2 additions & 3 deletions src/redux/selectors/appMessagesSelectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ const queryFilter = (state, props = {}) => ({
const selector = createSelector([statePropsFilter, queryFilter], (data, query = {}) => {
const { viewId = null, productId = null, report = {} } = data || {};
const appMessages = {
cloudigradeMismatch: false,
query
cloudigradeMismatch: false
};

const cache = (viewId && productId && selectorCache.data[`${viewId}_${productId}`]) || undefined;
Expand All @@ -70,7 +69,7 @@ const selector = createSelector([statePropsFilter, queryFilter], (data, query =
};
}

return { appMessages };
return { appMessages, query };
});

/**
Expand Down

0 comments on commit b514590

Please sign in to comment.