mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
ColorPicker: Remove deprecated onColorChange prop (#49923)
This commit is contained in:
parent
0a48b92d28
commit
8d59ba2be9
@ -8,7 +8,7 @@ import { closePopover } from '../../utils/closePopover';
|
||||
import { Popover } from '../Tooltip/Popover';
|
||||
import { PopoverController } from '../Tooltip/PopoverController';
|
||||
|
||||
import { ColorPickerPopover, ColorPickerProps, ColorPickerChangeHandler } from './ColorPickerPopover';
|
||||
import { ColorPickerPopover, ColorPickerProps } from './ColorPickerPopover';
|
||||
import { ColorSwatch } from './ColorSwatch';
|
||||
import { SeriesColorPickerPopover } from './SeriesColorPickerPopover';
|
||||
|
||||
@ -34,19 +34,12 @@ export const colorPickerFactory = <T extends ColorPickerProps>(
|
||||
static displayName = displayName;
|
||||
pickerTriggerRef = createRef<any>();
|
||||
|
||||
onColorChange = (color: string) => {
|
||||
const { onColorChange, onChange } = this.props;
|
||||
const changeHandler = (onColorChange || onChange) as ColorPickerChangeHandler;
|
||||
|
||||
return changeHandler(color);
|
||||
};
|
||||
|
||||
render() {
|
||||
const { theme, children } = this.props;
|
||||
const { theme, children, onChange } = this.props;
|
||||
const styles = getStyles(theme);
|
||||
const popoverElement = React.createElement(popover, {
|
||||
...{ ...this.props, children: null },
|
||||
onChange: this.onColorChange,
|
||||
onChange,
|
||||
});
|
||||
|
||||
return (
|
||||
|
@ -10,7 +10,6 @@ import { PopoverContentProps } from '../Tooltip';
|
||||
|
||||
import { NamedColorsPalette } from './NamedColorsPalette';
|
||||
import SpectrumPalette from './SpectrumPalette';
|
||||
import { warnAboutColorPickerPropsDeprecation } from './warnAboutColorPickerPropsDeprecation';
|
||||
|
||||
export type ColorPickerChangeHandler = (color: string) => void;
|
||||
|
||||
@ -18,10 +17,6 @@ export interface ColorPickerProps extends Themeable2 {
|
||||
color: string;
|
||||
onChange: ColorPickerChangeHandler;
|
||||
|
||||
/**
|
||||
* @deprecated Use onChange instead
|
||||
*/
|
||||
onColorChange?: ColorPickerChangeHandler;
|
||||
enableNamedColors?: boolean;
|
||||
}
|
||||
|
||||
@ -48,7 +43,6 @@ class UnThemedColorPickerPopover<T extends CustomPickersDescriptor> extends Reac
|
||||
this.state = {
|
||||
activePicker: 'palette',
|
||||
};
|
||||
warnAboutColorPickerPropsDeprecation('ColorPickerPopover', props);
|
||||
}
|
||||
|
||||
getTabClassName = (tabName: PickerType | keyof T) => {
|
||||
@ -57,12 +51,11 @@ class UnThemedColorPickerPopover<T extends CustomPickersDescriptor> extends Reac
|
||||
};
|
||||
|
||||
handleChange = (color: any) => {
|
||||
const { onColorChange, onChange, enableNamedColors, theme } = this.props;
|
||||
const changeHandler = onColorChange || onChange;
|
||||
const { onChange, enableNamedColors, theme } = this.props;
|
||||
if (enableNamedColors) {
|
||||
return changeHandler(color);
|
||||
return onChange(color);
|
||||
}
|
||||
changeHandler(colorManipulator.asHexString(theme.visualization.getColorByName(color)));
|
||||
onChange(colorManipulator.asHexString(theme.visualization.getColorByName(color)));
|
||||
};
|
||||
|
||||
onTabChange = (tab: PickerType | keyof T) => {
|
||||
|
@ -1,10 +0,0 @@
|
||||
import { deprecationWarning } from '@grafana/data';
|
||||
|
||||
import { ColorPickerProps } from './ColorPickerPopover';
|
||||
|
||||
export const warnAboutColorPickerPropsDeprecation = (componentName: string, props: ColorPickerProps) => {
|
||||
const { onColorChange } = props;
|
||||
if (onColorChange) {
|
||||
deprecationWarning(componentName, 'onColorChange', 'onChange');
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user