Merge pull request #15774 from ryantxu/set-options

Rename PanelEditorProps.onChange to onOptionsChange
This commit is contained in:
Torkel Ödegaard 2019-03-05 09:11:56 +01:00 committed by GitHub
commit 0016ad2cb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 14 deletions

View File

@ -22,7 +22,7 @@ export interface PanelData {
export interface PanelEditorProps<T = any> {
options: T;
onChange: (options: T) => void;
onOptionsChange: (options: T) => void;
}
export class ReactPanelPlugin<TOptions = any> {

View File

@ -66,7 +66,7 @@ export class VisualizationTab extends PureComponent<Props, State> {
const PanelEditor = plugin.exports.reactPanel.editor;
if (PanelEditor) {
return <PanelEditor options={this.getReactPanelOptions()} onChange={this.onPanelOptionsChanged} />;
return <PanelEditor options={this.getReactPanelOptions()} onOptionsChange={this.onPanelOptionsChanged} />;
}
}

View File

@ -10,14 +10,17 @@ import { GaugeOptions } from './types';
export class GaugeOptionsBox extends PureComponent<PanelEditorProps<GaugeOptions>> {
onToggleThresholdLabels = () =>
this.props.onChange({ ...this.props.options, showThresholdLabels: !this.props.options.showThresholdLabels });
this.props.onOptionsChange({ ...this.props.options, showThresholdLabels: !this.props.options.showThresholdLabels });
onToggleThresholdMarkers = () =>
this.props.onChange({ ...this.props.options, showThresholdMarkers: !this.props.options.showThresholdMarkers });
this.props.onOptionsChange({
...this.props.options,
showThresholdMarkers: !this.props.options.showThresholdMarkers,
});
onMinValueChange = ({ target }) => this.props.onChange({ ...this.props.options, minValue: target.value });
onMinValueChange = ({ target }) => this.props.onOptionsChange({ ...this.props.options, minValue: target.value });
onMaxValueChange = ({ target }) => this.props.onChange({ ...this.props.options, maxValue: target.value });
onMaxValueChange = ({ target }) => this.props.onOptionsChange({ ...this.props.options, maxValue: target.value });
render() {
const { options } = this.props;

View File

@ -14,31 +14,31 @@ import { GaugeOptions, SingleStatValueOptions } from './types';
export class GaugePanelEditor extends PureComponent<PanelEditorProps<GaugeOptions>> {
onThresholdsChanged = (thresholds: Threshold[]) =>
this.props.onChange({
this.props.onOptionsChange({
...this.props.options,
thresholds,
});
onValueMappingsChanged = (valueMappings: ValueMapping[]) =>
this.props.onChange({
this.props.onOptionsChange({
...this.props.options,
valueMappings,
});
onValueOptionsChanged = (valueOptions: SingleStatValueOptions) =>
this.props.onChange({
this.props.onOptionsChange({
...this.props.options,
valueOptions,
});
render() {
const { onChange, options } = this.props;
const { onOptionsChange, options } = this.props;
return (
<>
<PanelOptionsGrid>
<SingleStatValueEditor onChange={this.onValueOptionsChanged} options={options.valueOptions} />
<GaugeOptionsBox onChange={onChange} options={options} />
<GaugeOptionsBox onOptionsChange={onOptionsChange} options={options} />
<ThresholdsEditor onChange={this.onThresholdsChanged} thresholds={options.thresholds} />
</PanelOptionsGrid>

View File

@ -8,15 +8,15 @@ import { Options } from './types';
export class GraphPanelEditor extends PureComponent<PanelEditorProps<Options>> {
onToggleLines = () => {
this.props.onChange({ ...this.props.options, showLines: !this.props.options.showLines });
this.props.onOptionsChange({ ...this.props.options, showLines: !this.props.options.showLines });
};
onToggleBars = () => {
this.props.onChange({ ...this.props.options, showBars: !this.props.options.showBars });
this.props.onOptionsChange({ ...this.props.options, showBars: !this.props.options.showBars });
};
onTogglePoints = () => {
this.props.onChange({ ...this.props.options, showPoints: !this.props.options.showPoints });
this.props.onOptionsChange({ ...this.props.options, showPoints: !this.props.options.showPoints });
};
render() {