Skip to content

Commit

Permalink
[Fleet] Fix all category count (elastic#108089)
Browse files Browse the repository at this point in the history
  • Loading branch information
nchaulet authored and kibanamachine committed Aug 12, 2021
1 parent f509739 commit d62bdac
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ const AvailablePackages: React.FC = memo(() => {
const queryParams = new URLSearchParams(useLocation().search);
const initialCategory = queryParams.get('category') || '';
const [selectedCategory, setSelectedCategory] = useState(initialCategory);
const { data: allCategoryPackagesRes, isLoading: isLoadingAllPackages } = useGetPackages({
category: '',
});
const { data: categoryPackagesRes, isLoading: isLoadingCategoryPackages } = useGetPackages({
category: selectedCategory,
});
Expand All @@ -152,6 +155,11 @@ const AvailablePackages: React.FC = memo(() => {
[categoryPackagesRes]
);

const allPackages = useMemo(
() => packageListToIntegrationsList(allCategoryPackagesRes?.response || []),
[allCategoryPackagesRes]
);

const title = useMemo(
() =>
i18n.translate('xpack.fleet.epmList.allTitle', {
Expand All @@ -167,16 +175,16 @@ const AvailablePackages: React.FC = memo(() => {
title: i18n.translate('xpack.fleet.epmList.allPackagesFilterLinkText', {
defaultMessage: 'All',
}),
count: packages?.length || 0,
count: allPackages?.length || 0,
},
...(categoriesRes ? categoriesRes.response : []),
],
[packages?.length, categoriesRes]
[allPackages?.length, categoriesRes]
);

const controls = categories ? (
<CategoryFacets
isLoading={isLoadingCategories}
isLoading={isLoadingCategories || isLoadingAllPackages}
categories={categories}
selectedCategory={selectedCategory}
onCategoryChange={({ id }: CategorySummaryItem) => {
Expand Down

0 comments on commit d62bdac

Please sign in to comment.