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,
|
countData,
|
||||||
}: ILifecycleFiltersBaseProps) => {
|
}: ILifecycleFiltersBaseProps) => {
|
||||||
const current = state.lifecycle?.values ?? [];
|
const current = state.lifecycle?.values ?? [];
|
||||||
|
const allFlagsCount = Object.entries(countData ?? {}).reduce(
|
||||||
|
(acc, [key, count]) => (key !== 'archived' ? acc + count : acc),
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
@ -75,7 +79,9 @@ export const LifecycleFilters = ({
|
|||||||
value === null
|
value === null
|
||||||
? !state.lifecycle
|
? !state.lifecycle
|
||||||
: current.includes(value);
|
: current.includes(value);
|
||||||
const count = value ? countData?.[value] : total;
|
const count = value
|
||||||
|
? countData?.[value]
|
||||||
|
: allFlagsCount || undefined;
|
||||||
const dynamicLabel =
|
const dynamicLabel =
|
||||||
isActive && Number.isInteger(total)
|
isActive && Number.isInteger(total)
|
||||||
? `${label} (${total === count ? total : `${total} of ${count}`})`
|
? `${label} (${total === count ? total : `${total} of ${count}`})`
|
||||||
|
@ -47,7 +47,7 @@ describe('LifecycleFilters', () => {
|
|||||||
<FeaturesOverviewLifecycleFilters state={{}} onChange={vi.fn()} />,
|
<FeaturesOverviewLifecycleFilters state={{}} onChange={vi.fn()} />,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(getByText('All flags')).toBeInTheDocument();
|
expect(getByText('All flags (10)')).toBeInTheDocument();
|
||||||
expect(getByText('Develop (2)')).toBeInTheDocument();
|
expect(getByText('Develop (2)')).toBeInTheDocument();
|
||||||
expect(getByText('Rollout production (3)')).toBeInTheDocument();
|
expect(getByText('Rollout production (3)')).toBeInTheDocument();
|
||||||
expect(getByText('Cleanup (4)')).toBeInTheDocument();
|
expect(getByText('Cleanup (4)')).toBeInTheDocument();
|
||||||
@ -98,7 +98,7 @@ describe('LifecycleFilters', () => {
|
|||||||
lifecycle: { operator: 'IS', values: ['completed'] },
|
lifecycle: { operator: 'IS', values: ['completed'] },
|
||||||
});
|
});
|
||||||
|
|
||||||
await userEvent.click(getByText('All flags'));
|
await userEvent.click(getByText('All flags (10)'));
|
||||||
expect(onChange).toHaveBeenCalledWith({ lifecycle: null });
|
expect(onChange).toHaveBeenCalledWith({ lifecycle: null });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user