1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-11 00:08:30 +01:00

Fix/metrics chip adhock improvement (#7976)

On flag metrics page
This commit is contained in:
Tymoteusz Czech 2024-08-26 12:28:21 +02:00 committed by GitHub
parent 499c9cebfd
commit 80a9591d37
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 20 deletions

View File

@ -40,21 +40,19 @@ export const FeatureMetrics = () => {
featureId,
query.hoursBack || FEATURE_METRIC_HOURS_BACK_DEFAULT,
);
const defaultApplication = Array.from(applications)[0];
const allApplications = Array.from(applications);
const defaultApplication = allApplications[0];
const { environment: selectedEnvironment, hoursBack } = query;
const selectedApplications = query.applications.filter(
(item) => item !== null,
) as string[];
useEffect(() => {
if (
query.applications &&
query.applications.length === 0 &&
defaultApplication
) {
setQuery({ applications: [defaultApplication] });
if (query.applications && query.applications.length === 0) {
setQuery({ applications: allApplications });
}
}, [JSON.stringify(Array.from(applications))]);
}, [JSON.stringify(allApplications)]);
const allSelected = [...applications].every((element) =>
selectedApplications.includes(element),
@ -100,7 +98,7 @@ export const FeatureMetrics = () => {
return (
<PageContent>
<Grid container component='header' spacing={2}>
<Grid item xs={12} md={5}>
<Grid item xs={12} md={4}>
<ConditionallyRender
condition={environments.size > 0}
show={
@ -115,7 +113,7 @@ export const FeatureMetrics = () => {
}
/>
</Grid>
<Grid item xs={12} md={5}>
<Grid item xs={12} md={6}>
<ConditionallyRender
condition={applications.size > 0}
show={

View File

@ -64,6 +64,15 @@ export const FeatureMetricsChips = ({
<div>
<StyledTitle>{title}</StyledTitle>
<StyledList>
{toggleValues && values.size > 1 && (
<Button
size={'small'}
onClick={toggleValues}
aria-pressed={allSelected}
>
{allSelected ? 'Unselect' : 'Select all'}
</Button>
)}
{sortedValues.map((val) => (
<StyledItem key={val}>
<Chip
@ -74,16 +83,6 @@ export const FeatureMetricsChips = ({
/>
</StyledItem>
))}
{toggleValues && values.size > 1 && (
<Button
size={'small'}
onClick={toggleValues}
aria-pressed={allSelected}
>
{allSelected ? 'Unselect' : 'Select all'}
</Button>
)}
</StyledList>
</div>
);