浏览代码

Moved Thresholds and styles to grafana/ui/components

Hugo Häggmark 7 年之前
父节点
当前提交
1581662a6c

+ 4 - 4
public/app/plugins/panel/gauge/Threshold.test.tsx → packages/grafana-ui/src/components/Thresholds/Threshold.test.tsx

@@ -1,10 +1,10 @@
 import React from 'react';
 import React from 'react';
 import { shallow } from 'enzyme';
 import { shallow } from 'enzyme';
-import Thresholds from './Thresholds';
-import { defaultProps } from './GaugePanelOptions';
-import { BasicGaugeColor } from 'app/types';
 import { PanelOptionsProps } from '@grafana/ui';
 import { PanelOptionsProps } from '@grafana/ui';
-import { Options } from './types';
+import { defaultProps } from 'app/plugins/panel/gauge/GaugePanelOptions';
+import { Options } from 'app/plugins/panel/gauge/types';
+import { BasicGaugeColor } from 'app/types';
+import { Thresholds } from './Thresholds';
 
 
 const setup = (propOverrides?: object) => {
 const setup = (propOverrides?: object) => {
   const props: PanelOptionsProps<Options> = {
   const props: PanelOptionsProps<Options> = {

+ 4 - 4
public/app/plugins/panel/gauge/Thresholds.tsx → packages/grafana-ui/src/components/Thresholds/Thresholds.tsx

@@ -1,16 +1,16 @@
 import React, { PureComponent } from 'react';
 import React, { PureComponent } from 'react';
 import tinycolor from 'tinycolor2';
 import tinycolor from 'tinycolor2';
 import { ColorPicker } from '@grafana/ui';
 import { ColorPicker } from '@grafana/ui';
-import { BasicGaugeColor, Threshold } from 'app/types';
-import { PanelOptionsProps } from '@grafana/ui';
-import { Options } from './types';
+import { BasicGaugeColor } from 'app/types';
+import { PanelOptionsProps, Threshold } from '@grafana/ui';
+import { Options } from 'app/plugins/panel/gauge/types';
 
 
 interface State {
 interface State {
   thresholds: Threshold[];
   thresholds: Threshold[];
   baseColor: string;
   baseColor: string;
 }
 }
 
 
-export default class Thresholds extends PureComponent<PanelOptionsProps<Options>, State> {
+export class Thresholds extends PureComponent<PanelOptionsProps<Options>, State> {
   constructor(props) {
   constructor(props) {
     super(props);
     super(props);
 
 

+ 0 - 0
public/sass/components/_thresholds.scss → packages/grafana-ui/src/components/Thresholds/_Thresholds.scss


+ 1 - 0
packages/grafana-ui/src/components/index.scss

@@ -1,3 +1,4 @@
 @import 'CustomScrollbar/CustomScrollbar';
 @import 'CustomScrollbar/CustomScrollbar';
 @import 'DeleteButton/DeleteButton';
 @import 'DeleteButton/DeleteButton';
+@import 'Thresholds/Thresholds';
 @import 'Tooltip/Tooltip';
 @import 'Tooltip/Tooltip';

+ 1 - 0
packages/grafana-ui/src/components/index.ts

@@ -5,3 +5,4 @@ export { CustomScrollbar } from './CustomScrollbar/CustomScrollbar';
 export { ColorPicker } from './ColorPicker/ColorPicker';
 export { ColorPicker } from './ColorPicker/ColorPicker';
 export { SeriesColorPickerPopover } from './ColorPicker/SeriesColorPickerPopover';
 export { SeriesColorPickerPopover } from './ColorPicker/SeriesColorPickerPopover';
 export { SeriesColorPicker } from './ColorPicker/SeriesColorPicker';
 export { SeriesColorPicker } from './ColorPicker/SeriesColorPicker';
+export { Thresholds } from './Thresholds/Thresholds';

+ 6 - 0
packages/grafana-ui/src/types/panel.ts

@@ -29,3 +29,9 @@ export interface PanelMenuItem {
   shortcut?: string;
   shortcut?: string;
   subMenu?: PanelMenuItem[];
   subMenu?: PanelMenuItem[];
 }
 }
+
+export interface Threshold {
+  index: number;
+  value: number;
+  color?: string;
+}

+ 1 - 2
public/app/plugins/panel/gauge/GaugePanelOptions.tsx

@@ -1,8 +1,7 @@
 import React, { PureComponent } from 'react';
 import React, { PureComponent } from 'react';
 import ValueOptions from 'app/plugins/panel/gauge/ValueOptions';
 import ValueOptions from 'app/plugins/panel/gauge/ValueOptions';
-import Thresholds from 'app/plugins/panel/gauge/Thresholds';
 import { BasicGaugeColor } from 'app/types';
 import { BasicGaugeColor } from 'app/types';
-import { PanelOptionsProps } from '@grafana/ui';
+import { PanelOptionsProps, Thresholds } from '@grafana/ui';
 import ValueMappings from 'app/plugins/panel/gauge/ValueMappings';
 import ValueMappings from 'app/plugins/panel/gauge/ValueMappings';
 import { Options } from './types';
 import { Options } from './types';
 import GaugeOptions from './GaugeOptions';
 import GaugeOptions from './GaugeOptions';

+ 2 - 1
public/app/types/index.ts

@@ -9,7 +9,7 @@ import { ApiKey, ApiKeysState, NewApiKey } from './apiKeys';
 import { Invitee, OrgUser, User, UsersState, UserState } from './user';
 import { Invitee, OrgUser, User, UsersState, UserState } from './user';
 import { DataSource, DataSourceSelectItem, DataSourcesState } from './datasources';
 import { DataSource, DataSourceSelectItem, DataSourcesState } from './datasources';
 import { DataQuery, DataQueryResponse, DataQueryOptions } from './series';
 import { DataQuery, DataQueryResponse, DataQueryOptions } from './series';
-import { BasicGaugeColor, MappingType, RangeMap, Threshold, ValueMap } from './panel';
+import { BasicGaugeColor, MappingType, RangeMap, ValueMap } from './panel';
 import { PluginDashboard, PluginMeta, Plugin, PanelPlugin, PluginsState } from './plugins';
 import { PluginDashboard, PluginMeta, Plugin, PanelPlugin, PluginsState } from './plugins';
 import { Organization, OrganizationState } from './organization';
 import { Organization, OrganizationState } from './organization';
 import {
 import {
@@ -20,6 +20,7 @@ import {
 } from './appNotifications';
 } from './appNotifications';
 import { DashboardSearchHit } from './search';
 import { DashboardSearchHit } from './search';
 import { ValidationEvents, ValidationRule } from './form';
 import { ValidationEvents, ValidationRule } from './form';
+import { Threshold } from '@grafana/ui';
 export {
 export {
   Team,
   Team,
   TeamsState,
   TeamsState,

+ 0 - 6
public/app/types/panel.ts

@@ -1,9 +1,3 @@
-export interface Threshold {
-  index: number;
-  value: number;
-  color?: string;
-}
-
 export enum MappingType {
 export enum MappingType {
   ValueToText = 1,
   ValueToText = 1,
   RangeToText = 2,
   RangeToText = 2,

+ 0 - 1
public/sass/_grafana.scss

@@ -102,7 +102,6 @@
 @import 'components/toolbar';
 @import 'components/toolbar';
 @import 'components/add_data_source.scss';
 @import 'components/add_data_source.scss';
 @import 'components/page_loader';
 @import 'components/page_loader';
-@import 'components/thresholds';
 @import 'components/toggle_button_group';
 @import 'components/toggle_button_group';
 @import 'components/value-mappings';
 @import 'components/value-mappings';
 @import 'components/popover-box';
 @import 'components/popover-box';