mirror of
https://github.com/grafana/grafana.git
synced 2025-09-23 12:03:14 +08:00

* 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
32 lines
814 B
TypeScript
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>
|
|
);
|
|
};
|