mirror of https://github.com/grafana/grafana
Field overrides: Filter by field name using regex (#27070)
* Add filter name by regex matcher for overrides * Update docs * rever schema change * add docs for by type * add docs for by type * add docs for by type Co-authored-by: Ryan McKinley <ryantxu@gmail.com>pull/27086/head
parent
5aba6fde41
commit
ed1b929fe5
@ -0,0 +1,25 @@ |
||||
import React, { memo, useCallback } from 'react'; |
||||
import { MatcherUIProps, FieldMatcherUIRegistryItem } from './types'; |
||||
import { FieldMatcherID, fieldMatchers } from '@grafana/data'; |
||||
import { Input } from '../Input/Input'; |
||||
|
||||
export const FieldNameByRegexMatcherEditor = memo<MatcherUIProps<string>>(props => { |
||||
const { options } = props; |
||||
|
||||
const onBlur = useCallback( |
||||
(e: React.FocusEvent<HTMLInputElement>) => { |
||||
return props.onChange(e.target.value); |
||||
}, |
||||
[props.onChange] |
||||
); |
||||
|
||||
return <Input placeholder="Enter regular expression" defaultValue={options} onBlur={onBlur} />; |
||||
}); |
||||
|
||||
export const fieldNameByRegexMatcherItem: FieldMatcherUIRegistryItem<string> = { |
||||
id: FieldMatcherID.byRegexp, |
||||
component: FieldNameByRegexMatcherEditor, |
||||
matcher: fieldMatchers.get(FieldMatcherID.byRegexp), |
||||
name: 'Filter by field using regex', |
||||
description: 'Set properties for fields with names matching provided regex', |
||||
}; |
||||
@ -1,8 +1,9 @@ |
||||
import { Registry } from '@grafana/data'; |
||||
import { fieldNameMatcherItem } from './FieldNameMatcherEditor'; |
||||
import { FieldMatcherUIRegistryItem } from './types'; |
||||
import { fieldNameByRegexMatcherItem } from './FieldNameByRegexMatcherEditor'; |
||||
import { fieldTypeMatcherItem } from './FieldTypeMatcherEditor'; |
||||
|
||||
export const fieldMatchersUI = new Registry<FieldMatcherUIRegistryItem<any>>(() => { |
||||
return [fieldNameMatcherItem, fieldTypeMatcherItem]; |
||||
return [fieldNameMatcherItem, fieldNameByRegexMatcherItem, fieldTypeMatcherItem]; |
||||
}); |
||||
|
||||
Loading…
Reference in new issue