mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-19 17:52:45 +02:00
fix: quick project filters total calculation (#10658)
This commit is contained in:
parent
4b42435590
commit
e79fa33647
@ -66,6 +66,10 @@ export const LifecycleFilters = ({
|
||||
countData,
|
||||
}: ILifecycleFiltersBaseProps) => {
|
||||
const current = state.lifecycle?.values ?? [];
|
||||
const allFlagsCount = Object.entries(countData ?? {}).reduce(
|
||||
(acc, [key, count]) => (key !== 'archived' ? acc + count : acc),
|
||||
0,
|
||||
);
|
||||
|
||||
return (
|
||||
<Wrapper>
|
||||
@ -75,7 +79,9 @@ export const LifecycleFilters = ({
|
||||
value === null
|
||||
? !state.lifecycle
|
||||
: current.includes(value);
|
||||
const count = value ? countData?.[value] : total;
|
||||
const count = value
|
||||
? countData?.[value]
|
||||
: allFlagsCount || undefined;
|
||||
const dynamicLabel =
|
||||
isActive && Number.isInteger(total)
|
||||
? `${label} (${total === count ? total : `${total} of ${count}`})`
|
||||
|
@ -47,7 +47,7 @@ describe('LifecycleFilters', () => {
|
||||
<FeaturesOverviewLifecycleFilters state={{}} onChange={vi.fn()} />,
|
||||
);
|
||||
|
||||
expect(getByText('All flags')).toBeInTheDocument();
|
||||
expect(getByText('All flags (10)')).toBeInTheDocument();
|
||||
expect(getByText('Develop (2)')).toBeInTheDocument();
|
||||
expect(getByText('Rollout production (3)')).toBeInTheDocument();
|
||||
expect(getByText('Cleanup (4)')).toBeInTheDocument();
|
||||
@ -98,7 +98,7 @@ describe('LifecycleFilters', () => {
|
||||
lifecycle: { operator: 'IS', values: ['completed'] },
|
||||
});
|
||||
|
||||
await userEvent.click(getByText('All flags'));
|
||||
await userEvent.click(getByText('All flags (10)'));
|
||||
expect(onChange).toHaveBeenCalledWith({ lifecycle: null });
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user