|
|
|
@ -1,5 +1,5 @@ |
|
|
|
|
import React, { FormEvent, useState } from 'react'; |
|
|
|
|
import { Button, Icon, Input, Label, RadioButtonGroup, Tooltip, useStyles } from '@grafana/ui'; |
|
|
|
|
import { Button, Field, Icon, Input, Label, RadioButtonGroup, Tooltip, useStyles } from '@grafana/ui'; |
|
|
|
|
import { DataSourceInstanceSettings, GrafanaTheme, SelectableValue } from '@grafana/data'; |
|
|
|
|
import { css, cx } from '@emotion/css'; |
|
|
|
|
import { debounce } from 'lodash'; |
|
|
|
@ -9,6 +9,7 @@ import { useQueryParams } from 'app/core/hooks/useQueryParams'; |
|
|
|
|
import { getFiltersFromUrlParams } from '../../utils/misc'; |
|
|
|
|
import { DataSourcePicker } from '@grafana/runtime'; |
|
|
|
|
import { alertStateToReadable } from '../../utils/rules'; |
|
|
|
|
import { Stack } from '@grafana/experimental'; |
|
|
|
|
|
|
|
|
|
const ViewOptions: SelectableValue[] = [ |
|
|
|
|
{ |
|
|
|
@ -87,8 +88,7 @@ const RulesFilter = () => { |
|
|
|
|
const searchIcon = <Icon name={'search'} />; |
|
|
|
|
return ( |
|
|
|
|
<div className={styles.container}> |
|
|
|
|
<div className={styles.inputWidth}> |
|
|
|
|
<Label>Search by data source</Label> |
|
|
|
|
<Field className={styles.inputWidth} label="Search by data source"> |
|
|
|
|
<DataSourcePicker |
|
|
|
|
key={dataSourceKey} |
|
|
|
|
alerting |
|
|
|
@ -98,23 +98,29 @@ const RulesFilter = () => { |
|
|
|
|
onChange={handleDataSourceChange} |
|
|
|
|
onClear={clearDataSource} |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
</Field> |
|
|
|
|
<div className={cx(styles.flexRow, styles.spaceBetween)}> |
|
|
|
|
<div className={styles.flexRow}> |
|
|
|
|
<div className={styles.rowChild}> |
|
|
|
|
<Label> |
|
|
|
|
<Tooltip |
|
|
|
|
content={ |
|
|
|
|
<div> |
|
|
|
|
Filter rules and alerts using label querying, ex: |
|
|
|
|
<pre>{`{severity="critical", instance=~"cluster-us-.+"}`}</pre> |
|
|
|
|
</div> |
|
|
|
|
} |
|
|
|
|
> |
|
|
|
|
<Icon name="info-circle" className={styles.tooltip} /> |
|
|
|
|
</Tooltip> |
|
|
|
|
Search by label |
|
|
|
|
</Label> |
|
|
|
|
<Field |
|
|
|
|
className={styles.rowChild} |
|
|
|
|
label={ |
|
|
|
|
<Label> |
|
|
|
|
<Stack gap={0.5}> |
|
|
|
|
<span>Search by label</span> |
|
|
|
|
<Tooltip |
|
|
|
|
content={ |
|
|
|
|
<div> |
|
|
|
|
Filter rules and alerts using label querying, ex: |
|
|
|
|
<code>{`{severity="critical", instance=~"cluster-us-.+"}`}</code> |
|
|
|
|
</div> |
|
|
|
|
} |
|
|
|
|
> |
|
|
|
|
<Icon name="info-circle" size="sm" /> |
|
|
|
|
</Tooltip> |
|
|
|
|
</Stack> |
|
|
|
|
</Label> |
|
|
|
|
} |
|
|
|
|
> |
|
|
|
|
<Input |
|
|
|
|
key={queryStringKey} |
|
|
|
|
className={styles.inputWidth} |
|
|
|
@ -124,7 +130,7 @@ const RulesFilter = () => { |
|
|
|
|
placeholder="Search" |
|
|
|
|
data-testid="search-query-input" |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
</Field> |
|
|
|
|
<div className={styles.rowChild}> |
|
|
|
|
<Label>State</Label> |
|
|
|
|
<RadioButtonGroup options={stateOptions} value={alertState} onChange={handleAlertStateChange} /> |
|
|
|
@ -169,12 +175,8 @@ const getStyles = (theme: GrafanaTheme) => { |
|
|
|
|
container: css` |
|
|
|
|
display: flex; |
|
|
|
|
flex-direction: column; |
|
|
|
|
border-bottom: 1px solid ${theme.colors.border1}; |
|
|
|
|
padding-bottom: ${theme.spacing.sm}; |
|
|
|
|
|
|
|
|
|
& > div { |
|
|
|
|
margin-bottom: ${theme.spacing.sm}; |
|
|
|
|
} |
|
|
|
|
margin-bottom: ${theme.spacing.sm}; |
|
|
|
|
`,
|
|
|
|
|
inputWidth: css` |
|
|
|
|
width: 340px; |
|
|
|
@ -191,11 +193,7 @@ const getStyles = (theme: GrafanaTheme) => { |
|
|
|
|
justify-content: space-between; |
|
|
|
|
`,
|
|
|
|
|
rowChild: css` |
|
|
|
|
margin-right: ${theme.spacing.sm}; |
|
|
|
|
margin-top: ${theme.spacing.sm}; |
|
|
|
|
`,
|
|
|
|
|
tooltip: css` |
|
|
|
|
margin: 0 ${theme.spacing.xs}; |
|
|
|
|
margin: 0 ${theme.spacing.sm} 0 0; |
|
|
|
|
`,
|
|
|
|
|
clearButton: css` |
|
|
|
|
margin-top: ${theme.spacing.sm}; |
|
|
|
|