Skip to content

Commit

Permalink
Merge pull request #1851 from newrelic/liz/filter-bug
Browse files Browse the repository at this point in the history
Refactor disabled checks and add additional filtering
  • Loading branch information
LizBaker authored Nov 5, 2021
2 parents e56bb10 + 3977026 commit 11ecd21
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/pages/instant-observability.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ const QuickstartsPage = ({ data, location }) => {
setIsCategoriesOverlayOpen(false);
};

const filterByContentTypes = (quickstart) =>
filters.every((filter) => filterByContentType(filter)(quickstart));

const handleFilter = (value, e) => {
const currentFilters = filters.slice();
const params = new URLSearchParams(location.search);
Expand Down Expand Up @@ -230,13 +233,15 @@ const QuickstartsPage = ({ data, location }) => {
...cat,
count: quickstarts
.filter(filterBySearch(search))
.filter(filterByCategory(cat.value)).length,
.filter(filterByCategory(cat.value))
.filter(filterByContentTypes).length,
}));

const filtersWithCount = FILTERS.map((filter) => ({
...filter,
count: quickstarts
.filter(filterBySearch(search))
.filter(filterByContentTypes)
.filter(filterByContentType(filter.type))
.filter(filterByCategory(category)).length,
}));
Expand Down Expand Up @@ -365,7 +370,7 @@ const QuickstartsPage = ({ data, location }) => {
type={type}
icon={icon}
count={count}
isChecked={filters.includes(type)}
isChecked={filters.includes(type) && count !== 0}
handleFilter={handleFilter}
/>
))}
Expand All @@ -377,6 +382,7 @@ const QuickstartsPage = ({ data, location }) => {
<Button
type="button"
key={value}
disabled={count === 0}
onClick={() => handleCategory(value)}
css={css`
padding: 1rem 0.5rem;
Expand Down

0 comments on commit 11ecd21

Please sign in to comment.