mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Moved defaultProps to ui/components
This commit is contained in:
parent
0b8165fee2
commit
5ceedc4ac4
@ -1,8 +1,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { shallow } from 'enzyme';
|
import { shallow } from 'enzyme';
|
||||||
import { BasicGaugeColor, GaugeOptions, PanelOptionsProps } from '@grafana/ui';
|
|
||||||
|
|
||||||
import { ThresholdsEditor } from './ThresholdsEditor';
|
import { ThresholdsEditor } from './ThresholdsEditor';
|
||||||
|
import { BasicGaugeColor, PanelOptionsProps, GaugeOptions } from '../../types';
|
||||||
|
|
||||||
const defaultProps = {
|
const defaultProps = {
|
||||||
options: {
|
options: {
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
import tinycolor, { ColorInput } from 'tinycolor2';
|
import tinycolor, { ColorInput } from 'tinycolor2';
|
||||||
import { BasicGaugeColor, ColorPicker, GaugeOptions, PanelOptionsProps, Threshold } from '@grafana/ui';
|
|
||||||
|
import { Threshold, PanelOptionsProps, GaugeOptions, BasicGaugeColor } from '../../types';
|
||||||
|
import { ColorPicker } from '../ColorPicker/ColorPicker';
|
||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
thresholds: Threshold[];
|
thresholds: Threshold[];
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { RangeMap, Threshold, ValueMap } from '@grafana/ui';
|
import { BasicGaugeColor, RangeMap, Threshold, ValueMap } from './panel';
|
||||||
|
|
||||||
export interface GaugeOptions {
|
export interface GaugeOptions {
|
||||||
baseColor: string;
|
baseColor: string;
|
||||||
@ -14,3 +14,20 @@ export interface GaugeOptions {
|
|||||||
thresholds: Threshold[];
|
thresholds: Threshold[];
|
||||||
unit: string;
|
unit: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const GaugePanelOptionsDefaultProps = {
|
||||||
|
options: {
|
||||||
|
baseColor: BasicGaugeColor.Green,
|
||||||
|
minValue: 0,
|
||||||
|
maxValue: 100,
|
||||||
|
prefix: '',
|
||||||
|
showThresholdMarkers: true,
|
||||||
|
showThresholdLabels: false,
|
||||||
|
suffix: '',
|
||||||
|
decimals: 0,
|
||||||
|
stat: 'avg',
|
||||||
|
unit: 'none',
|
||||||
|
mappings: [],
|
||||||
|
thresholds: [],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
@ -1,29 +1,12 @@
|
|||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
import { BasicGaugeColor, GaugeOptions, PanelOptionsProps, ThresholdsEditor } from '@grafana/ui';
|
import { GaugeOptions, GaugePanelOptionsDefaultProps, PanelOptionsProps, ThresholdsEditor } from '@grafana/ui';
|
||||||
|
|
||||||
import ValueOptions from 'app/plugins/panel/gauge/ValueOptions';
|
import ValueOptions from 'app/plugins/panel/gauge/ValueOptions';
|
||||||
import ValueMappings from 'app/plugins/panel/gauge/ValueMappings';
|
import ValueMappings from 'app/plugins/panel/gauge/ValueMappings';
|
||||||
import GaugeOptionsEditor from './GaugeOptionsEditor';
|
import GaugeOptionsEditor from './GaugeOptionsEditor';
|
||||||
|
|
||||||
export const defaultProps = {
|
|
||||||
options: {
|
|
||||||
baseColor: BasicGaugeColor.Green,
|
|
||||||
minValue: 0,
|
|
||||||
maxValue: 100,
|
|
||||||
prefix: '',
|
|
||||||
showThresholdMarkers: true,
|
|
||||||
showThresholdLabels: false,
|
|
||||||
suffix: '',
|
|
||||||
decimals: 0,
|
|
||||||
stat: 'avg',
|
|
||||||
unit: 'none',
|
|
||||||
mappings: [],
|
|
||||||
thresholds: [],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export default class GaugePanelOptions extends PureComponent<PanelOptionsProps<GaugeOptions>> {
|
export default class GaugePanelOptions extends PureComponent<PanelOptionsProps<GaugeOptions>> {
|
||||||
static defaultProps = defaultProps;
|
static defaultProps = GaugePanelOptionsDefaultProps;
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { onChange, options } = this.props;
|
const { onChange, options } = this.props;
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { shallow } from 'enzyme';
|
import { shallow } from 'enzyme';
|
||||||
import { GaugeOptions, MappingType, PanelOptionsProps } from '@grafana/ui';
|
import { GaugeOptions, MappingType, PanelOptionsProps } from '@grafana/ui';
|
||||||
|
import { GaugePanelOptionsDefaultProps } from '@grafana/ui/src/types/gauge';
|
||||||
|
|
||||||
import ValueMappings from './ValueMappings';
|
import ValueMappings from './ValueMappings';
|
||||||
import { defaultProps } from 'app/plugins/panel/gauge/GaugePanelOptions';
|
|
||||||
|
|
||||||
const setup = (propOverrides?: object) => {
|
const setup = (propOverrides?: object) => {
|
||||||
const props: PanelOptionsProps<GaugeOptions> = {
|
const props: PanelOptionsProps<GaugeOptions> = {
|
||||||
onChange: jest.fn(),
|
onChange: jest.fn(),
|
||||||
options: {
|
options: {
|
||||||
...defaultProps.options,
|
...GaugePanelOptionsDefaultProps.options,
|
||||||
mappings: [
|
mappings: [
|
||||||
{ id: 1, operator: '', type: MappingType.ValueToText, value: '20', text: 'Ok' },
|
{ id: 1, operator: '', type: MappingType.ValueToText, value: '20', text: 'Ok' },
|
||||||
{ id: 2, operator: '', type: MappingType.RangeToText, from: '21', to: '30', text: 'Meh' },
|
{ id: 2, operator: '', type: MappingType.RangeToText, from: '21', to: '30', text: 'Meh' },
|
||||||
@ -67,7 +67,7 @@ describe('Next id to add', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should default to 1', () => {
|
it('should default to 1', () => {
|
||||||
const { instance } = setup({ options: { ...defaultProps.options } });
|
const { instance } = setup({ options: { ...GaugePanelOptionsDefaultProps.options } });
|
||||||
|
|
||||||
expect(instance.state.nextIdToAdd).toEqual(1);
|
expect(instance.state.nextIdToAdd).toEqual(1);
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import GaugePanelOptions, { defaultProps } from './GaugePanelOptions';
|
import { GaugePanelOptionsDefaultProps } from '@grafana/ui';
|
||||||
|
|
||||||
|
import GaugePanelOptions from './GaugePanelOptions';
|
||||||
import { GaugePanel } from './GaugePanel';
|
import { GaugePanel } from './GaugePanel';
|
||||||
|
|
||||||
export { GaugePanel as Panel, GaugePanelOptions as PanelOptions, defaultProps as PanelDefaults };
|
export { GaugePanel as Panel, GaugePanelOptions as PanelOptions, GaugePanelOptionsDefaultProps as PanelDefaults };
|
||||||
|
Loading…
Reference in New Issue
Block a user