You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
732 B
27 lines
732 B
import React, { FunctionComponent, useState } from 'react';
|
|
import { debounce } from 'lodash';
|
|
import { Input } from '@grafana/ui';
|
|
import { QueryEditorRow } from '.';
|
|
import { INPUT_WIDTH } from '../constants';
|
|
|
|
export interface Props {
|
|
onChange: (alias: any) => void;
|
|
value?: string;
|
|
}
|
|
|
|
export const AliasBy: FunctionComponent<Props> = ({ value = '', onChange }) => {
|
|
const [alias, setAlias] = useState(value ?? '');
|
|
|
|
const propagateOnChange = debounce(onChange, 1000);
|
|
|
|
onChange = (e: any) => {
|
|
setAlias(e.target.value);
|
|
propagateOnChange(e.target.value);
|
|
};
|
|
|
|
return (
|
|
<QueryEditorRow label="Alias by">
|
|
<Input width={INPUT_WIDTH} value={alias} onChange={onChange} />
|
|
</QueryEditorRow>
|
|
);
|
|
};
|
|
|