Forms migration: New datasource (#23221)

* Add Icon to Button and add newForms to FilterInput

* Reset button changes

* Update feedback

* Update Snapshots
This commit is contained in:
Tobias Skarhed
2020-04-01 15:55:23 +02:00
committed by GitHub
parent dcf6bbc14f
commit d7d94d13a0
8 changed files with 39 additions and 59 deletions

View File

@@ -1,5 +1,6 @@
import React, { forwardRef } from 'react';
import React, { FC } from 'react';
import { escapeStringForRegex, unEscapeStringFromRegex } from '@grafana/data';
import { Forms, Icon } from '@grafana/ui';
export interface Props {
value: string | undefined;
@@ -9,16 +10,15 @@ export interface Props {
onChange: (value: string) => void;
}
export const FilterInput = forwardRef<HTMLInputElement, Props>((props, ref) => (
<label className={props.labelClassName}>
<input
ref={ref}
type="text"
className={props.inputClassName}
value={props.value ? unEscapeStringFromRegex(props.value) : ''}
onChange={event => props.onChange(escapeStringForRegex(event.target.value))}
placeholder={props.placeholder ?? ''}
/>
<i className="gf-form-input-icon fa fa-search" />
</label>
));
export const FilterInput: FC<Props> = props => (
<Forms.Input
// Replaces the usage of ref
autoFocus
prefix={<Icon name="search" />}
type="text"
size="md"
value={props.value ? unEscapeStringFromRegex(props.value) : ''}
onChange={event => props.onChange(escapeStringForRegex(event.currentTarget.value))}
placeholder={props.placeholder ?? ''}
/>
);

View File

@@ -7,7 +7,7 @@ exports[`Render should render component 1`] = `
<div
className="gf-form gf-form--grow"
>
<ForwardRef
<Component
inputClassName="gf-form-input width-20"
labelClassName="gf-form--has-input-icon"
onChange={[MockFunction]}