mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-01 13:47:27 +02:00
feat: series query warning (#10413)
Co-authored-by: Thomas Heartman <thomas@getunleash.io>
This commit is contained in:
parent
15449e83d3
commit
8554eee37a
@ -1,13 +1,19 @@
|
||||
import {
|
||||
Alert,
|
||||
Autocomplete,
|
||||
Box,
|
||||
Checkbox,
|
||||
Chip,
|
||||
FormControlLabel,
|
||||
styled,
|
||||
TextField,
|
||||
Typography,
|
||||
} from '@mui/material';
|
||||
import type { FC } from 'react';
|
||||
|
||||
const StyledSelectAllLabel = styled('span')(({ theme }) => ({
|
||||
fontSize: theme.fontSizes.smallBody,
|
||||
}));
|
||||
|
||||
type LabelFilterItemProps = {
|
||||
labelKey: string;
|
||||
options: string[];
|
||||
@ -25,6 +31,7 @@ export const LabelFilterItem: FC<LabelFilterItemProps> = ({
|
||||
const isAllSelected = value.includes('*');
|
||||
const autocompleteId = `autocomplete-${labelKey}`;
|
||||
const selectAllId = `select-all-${labelKey}`;
|
||||
const isTruncated = options.length >= 1_000;
|
||||
|
||||
return (
|
||||
<>
|
||||
@ -46,16 +53,7 @@ export const LabelFilterItem: FC<LabelFilterItemProps> = ({
|
||||
}}
|
||||
/>
|
||||
}
|
||||
label={
|
||||
<Box
|
||||
component='span'
|
||||
sx={(theme) => ({
|
||||
fontSize: theme.fontSizes.smallBody,
|
||||
})}
|
||||
>
|
||||
Select all
|
||||
</Box>
|
||||
}
|
||||
label={<StyledSelectAllLabel>Select all</StyledSelectAllLabel>}
|
||||
/>
|
||||
<Autocomplete
|
||||
multiple
|
||||
@ -66,37 +64,68 @@ export const LabelFilterItem: FC<LabelFilterItemProps> = ({
|
||||
onChange(newValues);
|
||||
}}
|
||||
disabled={isAllSelected}
|
||||
renderTags={(value, getTagProps) =>
|
||||
value.map((option, index) => {
|
||||
const { key, ...chipProps } = getTagProps({
|
||||
index,
|
||||
});
|
||||
return (
|
||||
<Chip
|
||||
{...chipProps}
|
||||
key={key}
|
||||
label={option}
|
||||
size='small'
|
||||
/>
|
||||
);
|
||||
})
|
||||
}
|
||||
renderTags={(value, getTagProps) => {
|
||||
const overflowCount = 5;
|
||||
const displayedValues = value.slice(-overflowCount);
|
||||
const remainingCount = value.length - overflowCount;
|
||||
|
||||
return (
|
||||
<>
|
||||
{displayedValues.map((option, index) => {
|
||||
const { key, ...chipProps } = getTagProps({
|
||||
index,
|
||||
});
|
||||
return (
|
||||
<Chip
|
||||
{...chipProps}
|
||||
key={key}
|
||||
label={option}
|
||||
size='small'
|
||||
/>
|
||||
);
|
||||
})}
|
||||
{remainingCount > 0 ? (
|
||||
<Typography
|
||||
component='span'
|
||||
sx={{ color: 'text.secondary' }}
|
||||
>
|
||||
{' '}
|
||||
(+{remainingCount})
|
||||
</Typography>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
}}
|
||||
renderInput={(params) => (
|
||||
<TextField
|
||||
{...params}
|
||||
label={labelKey}
|
||||
placeholder={
|
||||
isAllSelected ? undefined : 'Select values…'
|
||||
}
|
||||
variant='outlined'
|
||||
size='small'
|
||||
inputProps={{
|
||||
...params.inputProps,
|
||||
'aria-describedby': isAllSelected
|
||||
? `${selectAllId}-description`
|
||||
: undefined,
|
||||
}}
|
||||
/>
|
||||
<>
|
||||
<TextField
|
||||
{...params}
|
||||
label={labelKey}
|
||||
placeholder={
|
||||
isAllSelected ? undefined : 'Select values…'
|
||||
}
|
||||
variant='outlined'
|
||||
size='small'
|
||||
inputProps={{
|
||||
...params.inputProps,
|
||||
'aria-describedby': isAllSelected
|
||||
? `${selectAllId}-description`
|
||||
: undefined,
|
||||
}}
|
||||
/>
|
||||
{isTruncated && (
|
||||
<Alert
|
||||
severity='warning'
|
||||
sx={(theme) => ({
|
||||
padding: theme.spacing(1, 2),
|
||||
marginTop: theme.spacing(1),
|
||||
})}
|
||||
>
|
||||
Maximum of 1000 values loaded due to
|
||||
performance.
|
||||
</Alert>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
/>
|
||||
</>
|
||||
|
@ -72,30 +72,32 @@ export const LabelsFilter: FC<LabelsFilterProps> = ({
|
||||
flexGrow: 1,
|
||||
}}
|
||||
>
|
||||
{Object.entries(availableLabels).map(([labelKey, values]) => {
|
||||
const currentSelection = selectedLabels[labelKey] || [];
|
||||
{Object.entries(availableLabels)
|
||||
.sort()
|
||||
.map(([labelKey, values]) => {
|
||||
const currentSelection = selectedLabels[labelKey] || [];
|
||||
|
||||
return (
|
||||
<Box
|
||||
key={labelKey}
|
||||
sx={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
flexGrow: 1,
|
||||
}}
|
||||
>
|
||||
<LabelFilterItem
|
||||
labelKey={labelKey}
|
||||
options={values}
|
||||
value={currentSelection}
|
||||
onChange={(newValues) =>
|
||||
handleLabelChange(labelKey, newValues)
|
||||
}
|
||||
handleAllToggle={handleAllToggle}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
})}
|
||||
return (
|
||||
<Box
|
||||
key={labelKey}
|
||||
sx={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
flexGrow: 1,
|
||||
}}
|
||||
>
|
||||
<LabelFilterItem
|
||||
labelKey={labelKey}
|
||||
options={values}
|
||||
value={currentSelection}
|
||||
onChange={(newValues) =>
|
||||
handleLabelChange(labelKey, newValues)
|
||||
}
|
||||
handleAllToggle={handleAllToggle}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
})}
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
|
@ -202,6 +202,19 @@ export const ImpactMetricsChart: FC<ImpactMetricsChartProps> = ({
|
||||
</Typography>
|
||||
</Box>
|
||||
) : null}
|
||||
{isPreview && debug?.isTruncated ? (
|
||||
<Box
|
||||
sx={(theme) => ({
|
||||
padding: theme.spacing(0, 2),
|
||||
})}
|
||||
>
|
||||
<Alert severity='warning'>
|
||||
Showing only {timeSeriesData.length} series due to
|
||||
performance. Please change filters for more accurate
|
||||
results.
|
||||
</Alert>
|
||||
</Box>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
@ -10,6 +10,7 @@ export type ImpactMetricsSeries = {
|
||||
data: TimeSeriesData;
|
||||
};
|
||||
|
||||
// TODO(impactMetrics): use OpenAPI types
|
||||
export type ImpactMetricsResponse = {
|
||||
start?: string;
|
||||
end?: string;
|
||||
@ -18,6 +19,7 @@ export type ImpactMetricsResponse = {
|
||||
labels?: ImpactMetricsLabels;
|
||||
debug?: {
|
||||
query?: string;
|
||||
isTruncated?: string;
|
||||
};
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user