grafana/public/app/plugins/datasource/cloudwatch/components/MetricsQueryEditor/Alias.tsx
Erik Sundell 0d60b1ce0a
CloudWatch: Display dynamic label field in case feature is enabled (#48614)
* move metrics editor related files to a separate folder

* cleanup

* add tests

* remove snapshot test

* nit

* remove unsued import

* remove snapshot
2022-05-04 07:36:18 +02:00

24 lines
619 B
TypeScript

import { debounce } from 'lodash';
import React, { FunctionComponent, useState } from 'react';
import { Input } from '@grafana/ui';
export interface Props {
onChange: (alias: any) => void;
value: string;
id?: string;
}
export const Alias: FunctionComponent<Props> = ({ value = '', onChange, id }) => {
const [alias, setAlias] = useState(value);
const propagateOnChange = debounce(onChange, 1500);
onChange = (e: any) => {
setAlias(e.target.value);
propagateOnChange(e.target.value);
};
return <Input id={id} type="text" value={alias} onChange={onChange} aria-label="Optional alias" />;
};