mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[Synthetics] Handle string filters in url (#161780)
This commit is contained in:
parent
885fb43651
commit
82285ac7c8
4 changed files with 20 additions and 10 deletions
|
@ -32,7 +32,7 @@ export const FilterButton = ({
|
|||
|
||||
// Transform the values to readable labels (if any) so that selected values are checked on filter dropdown
|
||||
const selectedValueLabels = getSyntheticsFilterDisplayValues(
|
||||
(urlParams[field] || []).map(valueToLabelWithEmptyCount),
|
||||
valueToLabelWithEmptyCount(urlParams[field]),
|
||||
field,
|
||||
[]
|
||||
).map(({ label: selectedValueLabel }) => selectedValueLabel);
|
||||
|
|
|
@ -23,9 +23,17 @@ import { FilterButton } from './filter_button';
|
|||
|
||||
const mixUrlValues = (
|
||||
values?: LabelWithCountValue[],
|
||||
urlLabels?: string[]
|
||||
urlLabels?: string[] | string
|
||||
): LabelWithCountValue[] => {
|
||||
const urlValues = urlLabels?.map((label) => ({ label, count: 0 })) ?? [];
|
||||
let urlValues: Array<{
|
||||
label: string;
|
||||
count: number;
|
||||
}> = [];
|
||||
if (typeof urlLabels === 'string' && urlLabels) {
|
||||
urlValues.push({ label: urlLabels, count: 0 });
|
||||
} else if (Array.isArray(urlLabels)) {
|
||||
urlValues = urlLabels?.map((label) => ({ label, count: 0 })) ?? [];
|
||||
}
|
||||
const newValues = [...(values ?? [])];
|
||||
// add url values that are not in the values
|
||||
urlValues.forEach((urlValue) => {
|
||||
|
|
|
@ -81,10 +81,12 @@ export function getSyntheticsFilterKeyForLabel(value: string, field: SyntheticsM
|
|||
}
|
||||
}
|
||||
|
||||
export const valueToLabelWithEmptyCount = (value: string): LabelWithCountValue => ({
|
||||
label: value,
|
||||
count: 0,
|
||||
});
|
||||
export const valueToLabelWithEmptyCount = (value?: string | string[]): LabelWithCountValue[] => {
|
||||
if (Array.isArray(value)) {
|
||||
return value.map((v) => ({ label: v, count: 0 }));
|
||||
}
|
||||
return value ? [{ label: value, count: 0 }] : [];
|
||||
};
|
||||
|
||||
export const monitorTypeKeyLabelMap: Record<DataStream, string> = {
|
||||
[DataStream.BROWSER]: 'Journey / Page',
|
||||
|
|
|
@ -29,11 +29,11 @@ export interface SyntheticsUrlParams {
|
|||
query?: string;
|
||||
tags?: string[];
|
||||
locations?: string[];
|
||||
monitorTypes?: string[];
|
||||
monitorTypes?: string[] | string;
|
||||
status?: string[];
|
||||
locationId?: string;
|
||||
projects?: string[];
|
||||
schedules?: string[];
|
||||
projects?: string[] | string;
|
||||
schedules?: string[] | string;
|
||||
groupBy?: MonitorOverviewState['groupBy']['field'];
|
||||
groupOrderBy?: MonitorOverviewState['groupBy']['order'];
|
||||
packagePolicyId?: string;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue