Problems: filter by particular severity, fixes #572

This commit is contained in:
Alexander Zobnin
2023-03-20 17:20:44 +01:00
parent 9deb7ddc3e
commit 07c02ca97a
3 changed files with 25 additions and 13 deletions

View File

@@ -3,7 +3,7 @@ import React, { useEffect, FormEvent } from 'react';
import { useAsyncFn } from 'react-use';
import { SelectableValue } from '@grafana/data';
import { InlineField, Input, Select } from '@grafana/ui';
import { InlineField, Input, MultiSelect, Select } from '@grafana/ui';
import { QueryEditorRow } from './QueryEditorRow';
import { MetricPicker } from '../../../components';
import { getVariableOptions } from './utils';
@@ -143,9 +143,9 @@ export const ProblemsQueryEditor = ({ query, datasource, onChange }: Props) => {
};
};
const onMinSeverityChange = (option: SelectableValue) => {
if (option.value !== null) {
onChange({ ...query, options: { ...query.options, minSeverity: option.value } });
const onSeveritiesChange = (options: SelectableValue[]) => {
if (options !== null) {
onChange({ ...query, options: { ...query.options, severities: options.map((o) => o.value) } });
}
};
@@ -217,13 +217,14 @@ export const ProblemsQueryEditor = ({ query, datasource, onChange }: Props) => {
onChange={onPropChange('showProblems')}
/>
</InlineField>
<InlineField label="Min severity" labelWidth={12}>
<Select
<InlineField label="Severity" labelWidth={12}>
<MultiSelect
isSearchable={false}
width={24}
value={query.options?.minSeverity}
isClearable={true}
placeholder="Show all problems"
value={query.options?.severities}
options={severityOptions}
onChange={onMinSeverityChange}
onChange={onSeveritiesChange}
/>
</InlineField>
</QueryEditorRow>