Commit c90979a8 by Hugo Häggmark

Moved ValueMappings to grafana/ui/component and renamed it ValueMappingsEditor

parent 639dc6c3
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 {
mapping: ValueMap | RangeMap;
......
import React from 'react';
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 props: PanelOptionsProps<GaugeOptions> = {
......@@ -19,9 +20,9 @@ const setup = (propOverrides?: object) => {
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 {
instance,
......
import React, { PureComponent } from 'react';
import { GaugeOptions, PanelOptionsProps, MappingType, RangeMap, ValueMap, PanelOptionsGroup } from '@grafana/ui';
import MappingRow from './MappingRow';
import { PanelOptionsProps, ValueMap, RangeMap, MappingType } from '../../types/panel';
import { GaugeOptions } from '../../types/gauge';
import { PanelOptionsGroup } from '../PanelOptionsGroup/PanelOptionsGroup';
interface State {
mappings: Array<ValueMap | RangeMap>;
nextIdToAdd: number;
}
export default class ValueMappings extends PureComponent<PanelOptionsProps<GaugeOptions>, State> {
export class ValueMappingsEditor extends PureComponent<PanelOptionsProps<GaugeOptions>, State> {
constructor(props) {
super(props);
......
// 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 'PanelOptionsGrid/PanelOptionsGrid';
@import 'ColorPicker/ColorPicker';
@import 'ValueMappingsEditor/ValueMappingsEditor';
......@@ -19,3 +19,4 @@ export { GfFormLabel } from './GfFormLabel/GfFormLabel';
export { Graph } from './Graph/Graph';
export { PanelOptionsGroup } from './PanelOptionsGroup/PanelOptionsGroup';
export { PanelOptionsGrid } from './PanelOptionsGrid/PanelOptionsGrid';
export { ValueMappingsEditor } from './ValueMappingsEditor/ValueMappingsEditor';
......@@ -6,10 +6,10 @@ import {
ThresholdsEditor,
Threshold,
PanelOptionsGrid,
ValueMappingsEditor,
} from '@grafana/ui';
import ValueOptions from 'app/plugins/panel/gauge/ValueOptions';
import ValueMappings from 'app/plugins/panel/gauge/ValueMappings';
import GaugeOptionsEditor from './GaugeOptionsEditor';
export const defaultProps = {
......@@ -44,7 +44,7 @@ export default class GaugePanelOptions extends PureComponent<PanelOptionsProps<G
<ThresholdsEditor onChange={this.onThresholdsChanged} thresholds={options.thresholds} />
</PanelOptionsGrid>
<ValueMappings onChange={onChange} options={options} />
<ValueMappingsEditor onChange={onChange} options={options} />
</>
);
}
......
// DEPENDENCIES
// DEPENDENCIES
@import '../../node_modules/react-table/react-table.css';
// VENDOR
......@@ -97,7 +97,6 @@
@import 'components/add_data_source.scss';
@import 'components/page_loader';
@import 'components/toggle_button_group';
@import 'components/value-mappings';
@import 'components/popover-box';
// LOAD @grafana/ui components
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment