mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Moved ValueMappings to grafana/ui/component and renamed it ValueMappingsEditor
This commit is contained in:
parent
639dc6c3c3
commit
c90979a8f0
@ -1,5 +1,8 @@
|
|||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
import { MappingType, RangeMap, Select, ValueMap, Label } from '@grafana/ui';
|
|
||||||
|
import { ValueMap, RangeMap, MappingType } from '../../types/panel';
|
||||||
|
import { Label } from '../Label/Label';
|
||||||
|
import { Select } from '../Select/Select';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
mapping: ValueMap | RangeMap;
|
mapping: ValueMap | RangeMap;
|
@ -1,9 +1,10 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { shallow } from 'enzyme';
|
import { shallow } from 'enzyme';
|
||||||
import { GaugeOptions, MappingType, PanelOptionsProps } from '@grafana/ui';
|
|
||||||
import { defaultProps } from 'app/plugins/panel/gauge/GaugePanelOptions';
|
|
||||||
|
|
||||||
import ValueMappings from './ValueMappings';
|
import { defaultProps } from 'app/plugins/panel/gauge/GaugePanelOptions';
|
||||||
|
import { ValueMappingsEditor } from './ValueMappingsEditor';
|
||||||
|
import { PanelOptionsProps, MappingType } from '../../types/panel';
|
||||||
|
import { GaugeOptions } from '../../types/gauge';
|
||||||
|
|
||||||
const setup = (propOverrides?: object) => {
|
const setup = (propOverrides?: object) => {
|
||||||
const props: PanelOptionsProps<GaugeOptions> = {
|
const props: PanelOptionsProps<GaugeOptions> = {
|
||||||
@ -19,9 +20,9 @@ const setup = (propOverrides?: object) => {
|
|||||||
|
|
||||||
Object.assign(props, propOverrides);
|
Object.assign(props, propOverrides);
|
||||||
|
|
||||||
const wrapper = shallow(<ValueMappings {...props} />);
|
const wrapper = shallow(<ValueMappingsEditor {...props} />);
|
||||||
|
|
||||||
const instance = wrapper.instance() as ValueMappings;
|
const instance = wrapper.instance() as ValueMappingsEditor;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
instance,
|
instance,
|
@ -1,14 +1,16 @@
|
|||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
import { GaugeOptions, PanelOptionsProps, MappingType, RangeMap, ValueMap, PanelOptionsGroup } from '@grafana/ui';
|
|
||||||
|
|
||||||
import MappingRow from './MappingRow';
|
import MappingRow from './MappingRow';
|
||||||
|
import { PanelOptionsProps, ValueMap, RangeMap, MappingType } from '../../types/panel';
|
||||||
|
import { GaugeOptions } from '../../types/gauge';
|
||||||
|
import { PanelOptionsGroup } from '../PanelOptionsGroup/PanelOptionsGroup';
|
||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
mappings: Array<ValueMap | RangeMap>;
|
mappings: Array<ValueMap | RangeMap>;
|
||||||
nextIdToAdd: number;
|
nextIdToAdd: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class ValueMappings extends PureComponent<PanelOptionsProps<GaugeOptions>, State> {
|
export class ValueMappingsEditor extends PureComponent<PanelOptionsProps<GaugeOptions>, State> {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
@ -0,0 +1,56 @@
|
|||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`Render should render component 1`] = `
|
||||||
|
<Component
|
||||||
|
title="Value Mappings"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<MappingRow
|
||||||
|
key="Ok-0"
|
||||||
|
mapping={
|
||||||
|
Object {
|
||||||
|
"id": 1,
|
||||||
|
"operator": "",
|
||||||
|
"text": "Ok",
|
||||||
|
"type": 1,
|
||||||
|
"value": "20",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
removeMapping={[Function]}
|
||||||
|
updateMapping={[Function]}
|
||||||
|
/>
|
||||||
|
<MappingRow
|
||||||
|
key="Meh-1"
|
||||||
|
mapping={
|
||||||
|
Object {
|
||||||
|
"from": "21",
|
||||||
|
"id": 2,
|
||||||
|
"operator": "",
|
||||||
|
"text": "Meh",
|
||||||
|
"to": "30",
|
||||||
|
"type": 2,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
removeMapping={[Function]}
|
||||||
|
updateMapping={[Function]}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="add-mapping-row"
|
||||||
|
onClick={[Function]}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="add-mapping-row-icon"
|
||||||
|
>
|
||||||
|
<i
|
||||||
|
className="fa fa-plus"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="add-mapping-row-label"
|
||||||
|
>
|
||||||
|
Add mapping
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Component>
|
||||||
|
`;
|
@ -6,3 +6,4 @@
|
|||||||
@import 'PanelOptionsGroup/PanelOptionsGroup';
|
@import 'PanelOptionsGroup/PanelOptionsGroup';
|
||||||
@import 'PanelOptionsGrid/PanelOptionsGrid';
|
@import 'PanelOptionsGrid/PanelOptionsGrid';
|
||||||
@import 'ColorPicker/ColorPicker';
|
@import 'ColorPicker/ColorPicker';
|
||||||
|
@import 'ValueMappingsEditor/ValueMappingsEditor';
|
||||||
|
@ -19,3 +19,4 @@ export { GfFormLabel } from './GfFormLabel/GfFormLabel';
|
|||||||
export { Graph } from './Graph/Graph';
|
export { Graph } from './Graph/Graph';
|
||||||
export { PanelOptionsGroup } from './PanelOptionsGroup/PanelOptionsGroup';
|
export { PanelOptionsGroup } from './PanelOptionsGroup/PanelOptionsGroup';
|
||||||
export { PanelOptionsGrid } from './PanelOptionsGrid/PanelOptionsGrid';
|
export { PanelOptionsGrid } from './PanelOptionsGrid/PanelOptionsGrid';
|
||||||
|
export { ValueMappingsEditor } from './ValueMappingsEditor/ValueMappingsEditor';
|
||||||
|
@ -6,10 +6,10 @@ import {
|
|||||||
ThresholdsEditor,
|
ThresholdsEditor,
|
||||||
Threshold,
|
Threshold,
|
||||||
PanelOptionsGrid,
|
PanelOptionsGrid,
|
||||||
|
ValueMappingsEditor,
|
||||||
} from '@grafana/ui';
|
} 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 GaugeOptionsEditor from './GaugeOptionsEditor';
|
import GaugeOptionsEditor from './GaugeOptionsEditor';
|
||||||
|
|
||||||
export const defaultProps = {
|
export const defaultProps = {
|
||||||
@ -44,7 +44,7 @@ export default class GaugePanelOptions extends PureComponent<PanelOptionsProps<G
|
|||||||
<ThresholdsEditor onChange={this.onThresholdsChanged} thresholds={options.thresholds} />
|
<ThresholdsEditor onChange={this.onThresholdsChanged} thresholds={options.thresholds} />
|
||||||
</PanelOptionsGrid>
|
</PanelOptionsGrid>
|
||||||
|
|
||||||
<ValueMappings onChange={onChange} options={options} />
|
<ValueMappingsEditor onChange={onChange} options={options} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// DEPENDENCIES
|
// DEPENDENCIES
|
||||||
@import '../../node_modules/react-table/react-table.css';
|
@import '../../node_modules/react-table/react-table.css';
|
||||||
|
|
||||||
// VENDOR
|
// VENDOR
|
||||||
@ -97,7 +97,6 @@
|
|||||||
@import 'components/add_data_source.scss';
|
@import 'components/add_data_source.scss';
|
||||||
@import 'components/page_loader';
|
@import 'components/page_loader';
|
||||||
@import 'components/toggle_button_group';
|
@import 'components/toggle_button_group';
|
||||||
@import 'components/value-mappings';
|
|
||||||
@import 'components/popover-box';
|
@import 'components/popover-box';
|
||||||
|
|
||||||
// LOAD @grafana/ui components
|
// LOAD @grafana/ui components
|
||||||
|
Loading…
Reference in New Issue
Block a user