Files
Josh Hunt 3c6e0e8ef8 Chore: ESlint import order (#44959)
* Add and configure eslint-plugin-import

* Fix the lint:ts npm command

* Autofix + prettier all the files

* Manually fix remaining files

* Move jquery code in jest-setup to external file to safely reorder imports

* Resolve issue caused by circular dependencies within Prometheus

* Update .betterer.results

* Fix missing // @ts-ignore

* ignore iconBundle.ts

* Fix missing // @ts-ignore
2022-04-22 14:33:13 +01:00

32 lines
814 B
TypeScript

import { debounce } from 'lodash';
import React, { FunctionComponent, useState } from 'react';
import { Input } from '@grafana/ui';
import { INPUT_WIDTH } from '../constants';
import { QueryEditorRow } from '.';
export interface Props {
refId: string;
onChange: (alias: any) => void;
value?: string;
}
export const AliasBy: FunctionComponent<Props> = ({ refId, 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" htmlFor={`${refId}-alias-by`}>
<Input id={`${refId}-alias-by`} width={INPUT_WIDTH} value={alias} onChange={onChange} />
</QueryEditorRow>
);
};