Skip to content

Commit

Permalink
Fix/metrics chip adhock improvement (#7976)
Browse files Browse the repository at this point in the history
On flag metrics page
  • Loading branch information
Tymek authored Aug 26, 2024
1 parent 499c9ce commit 80a9591
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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={
Expand All @@ -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={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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>
);
Expand Down

0 comments on commit 80a9591

Please sign in to comment.