grafana/data: Move getPanelOptionsWithDefaults from core (#60813)

* grafana/data: Move getPanelOptionsWithDefaults from core

* Add internal comments
pull/60820/head
Dominik Prokop 3 years ago committed by GitHub
parent 168afa99d1
commit c3c4a57c79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 42
      .betterer.results
  2. 8
      packages/grafana-data/src/index.ts
  3. 6
      packages/grafana-data/src/panel/getPanelOptionsWithDefaults.test.ts
  4. 37
      packages/grafana-data/src/panel/getPanelOptionsWithDefaults.ts
  5. 17
      packages/grafana-data/test/__mocks__/pluginMocks.ts
  6. 112
      packages/grafana-data/test/helpers/fieldConfig.ts
  7. 2
      packages/grafana-data/tsconfig.build.json
  8. 2
      public/app/features/dashboard/components/DashboardPrompt/DashboardPrompt.test.tsx
  9. 2
      public/app/features/dashboard/components/HelpWizard/HelpWizard.test.tsx
  10. 2
      public/app/features/dashboard/components/PanelEditor/OptionsPaneOptions.test.tsx
  11. 2
      public/app/features/dashboard/components/PanelEditor/state/actions.test.ts
  12. 2
      public/app/features/dashboard/state/DashboardMigrator.test.ts
  13. 4
      public/app/features/dashboard/state/PanelModel.test.ts
  14. 11
      public/app/features/dashboard/state/PanelModel.ts
  15. 2
      public/app/features/dashboard/utils/panel.test.ts
  16. 2
      public/app/features/datasources/state/buildCategories.test.ts
  17. 2
      public/app/features/datasources/utils.test.ts
  18. 3
      public/app/features/panel/components/PanelRenderer.tsx
  19. 5
      public/app/features/panel/state/actions.test.ts
  20. 3
      public/app/features/panel/state/actions.ts
  21. 2
      public/app/features/plugins/components/AppRootPage.test.tsx
  22. 2
      public/app/features/scenes/components/VizPanel/VizPanel.test.tsx
  23. 10
      public/app/features/scenes/components/VizPanel/VizPanel.tsx
  24. 2
      public/app/features/scenes/variables/variants/DataSourceVariable.test.ts
  25. 2
      public/app/features/variables/datasource/actions.test.ts
  26. 2
      public/app/features/variables/datasource/reducer.test.ts
  27. 112
      public/test/helpers/fieldConfig.ts

@ -313,6 +313,23 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "6"],
[0, 0, 0, "Do not use any type assertions.", "7"]
],
"packages/grafana-data/src/panel/getPanelOptionsWithDefaults.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"packages/grafana-data/src/panel/getPanelOptionsWithDefaults.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
[0, 0, 0, "Do not use any type assertions.", "8"],
[0, 0, 0, "Unexpected any. Specify a different type.", "9"],
[0, 0, 0, "Do not use any type assertions.", "10"]
],
"packages/grafana-data/src/panel/registryFactories.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
@ -833,6 +850,10 @@ exports[`better eslint`] = {
"packages/grafana-data/src/vector/SortedVector.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"packages/grafana-data/test/__mocks__/pluginMocks.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"packages/grafana-e2e/cypress/plugins/benchmark/formatting.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
@ -3531,23 +3552,6 @@ exports[`better eslint`] = {
"public/app/features/dashboard/state/actions.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/features/dashboard/state/getPanelOptionsWithDefaults.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/features/dashboard/state/getPanelOptionsWithDefaults.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
[0, 0, 0, "Do not use any type assertions.", "8"],
[0, 0, 0, "Unexpected any. Specify a different type.", "9"],
[0, 0, 0, "Do not use any type assertions.", "10"]
],
"public/app/features/dashboard/state/initDashboard.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
@ -4138,10 +4142,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
],
"public/app/features/plugins/__mocks__/pluginMocks.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/features/plugins/admin/components/AppConfigWrapper.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]

@ -23,6 +23,14 @@ export {
} from './transformations/matchers/valueMatchers/types';
export { LayoutModes, type LayoutMode } from './types/layout';
export { PanelPlugin, type SetFieldConfigOptionsArgs, type StandardOptionConfig } from './panel/PanelPlugin';
export {
getPanelOptionsWithDefaults,
filterFieldConfigOverrides,
restoreCustomOverrideRules,
isCustomFieldProp,
isStandardFieldProp,
type OptionDefaults,
} from './panel/getPanelOptionsWithDefaults';
export { createFieldConfigRegistry } from './panel/registryFactories';
export { type QueryRunner, type QueryRunnerOptions } from './types/queryRunner';
export { type GroupingToMatrixTransformerOptions } from './transformations/transformers/groupingToMatrix';

@ -1,5 +1,3 @@
import { mockStandardFieldConfigOptions } from 'test/helpers/fieldConfig';
import {
ConfigOverrideRule,
FieldColorModeId,
@ -12,7 +10,9 @@ import {
StandardOptionConfig,
ThresholdsMode,
} from '@grafana/data';
import { getPanelPlugin } from 'app/features/plugins/__mocks__/pluginMocks';
import { getPanelPlugin } from '../../test/__mocks__/pluginMocks';
import { mockStandardFieldConfigOptions } from '../../test/helpers/fieldConfig';
import { getPanelOptionsWithDefaults, restoreCustomOverrideRules } from './getPanelOptionsWithDefaults';

@ -1,18 +1,18 @@
import { mergeWith, isArray, isObject, unset, isEqual } from 'lodash';
import { FieldConfigOptionsRegistry } from '../field/FieldConfigOptionsRegistry';
import { fieldColorModeRegistry } from '../field/fieldColor';
import { FieldColorConfigSettings } from '../field/overrides/processors';
import { FieldColorModeId } from '../types/fieldColor';
import {
ConfigOverrideRule,
DynamicConfigValue,
FieldColorConfigSettings,
FieldColorModeId,
fieldColorModeRegistry,
FieldConfigOptionsRegistry,
FieldConfigProperty,
FieldConfigSource,
PanelPlugin,
ThresholdsConfig,
ThresholdsMode,
} from '@grafana/data';
} from '../types/fieldOverrides';
import { ThresholdsConfig, ThresholdsMode } from '../types/thresholds';
import { PanelPlugin } from './PanelPlugin';
export interface Props {
plugin: PanelPlugin;
@ -26,6 +26,11 @@ export interface OptionDefaults {
fieldConfig: FieldConfigSource;
}
/**
* This will return the panel options with defaults applied.
* Used internally, not intended for external use.
* @internal
*/
export function getPanelOptionsWithDefaults({
plugin,
currentOptions,
@ -89,6 +94,10 @@ function applyFieldConfigDefaults(existingFieldConfig: FieldConfigSource, plugin
return result;
}
/**
* Used internally, not intended for external use.
* @internal
*/
export function filterFieldConfigOverrides(
overrides: ConfigOverrideRule[],
condition: (value: DynamicConfigValue) => boolean
@ -194,6 +203,10 @@ function fixThresholds(thresholds: ThresholdsConfig) {
}
}
/**
* Used internally, not intended for external use.
* @internal
*/
export function restoreCustomOverrideRules(current: FieldConfigSource, old: FieldConfigSource): FieldConfigSource {
const result = {
defaults: {
@ -221,10 +234,18 @@ export function restoreCustomOverrideRules(current: FieldConfigSource, old: Fiel
return result;
}
/**
* Used internally, not intended for external use.
* @internal
*/
export function isCustomFieldProp(prop: DynamicConfigValue): boolean {
return prop.id.startsWith('custom.');
}
/**
* Used internally, not intended for external use.
* @internal
*/
export function isStandardFieldProp(prop: DynamicConfigValue): boolean {
return !isCustomFieldProp(prop);
}

@ -1,10 +1,10 @@
import { ComponentType } from 'enzyme';
import { defaultsDeep } from 'lodash';
import { ComponentType } from 'react';
import { PanelPluginMeta, PluginMeta, PluginType, PanelPlugin, PanelProps } from '@grafana/data';
import { PanelPluginMeta, PluginMeta, PluginType, PanelPlugin, PanelProps } from '../../src';
export const getMockPlugins = (amount: number): PluginMeta[] => {
const plugins = [];
const plugins: PluginMeta[] = [];
for (let i = 0; i <= amount; i++) {
plugins.push({
@ -18,18 +18,19 @@ export const getMockPlugins = (amount: number): PluginMeta[] => {
url: 'url/to/GrafanaLabs',
},
description: 'pretty decent plugin',
links: ['one link'],
links: [{ name: 'one link', url: 'one link' }],
logos: { small: 'small/logo', large: 'large/logo' },
screenshots: [{ path: `screenshot/${i}` }],
screenshots: [{ path: `screenshot/${i}`, name: 'test' }],
updated: '2018-09-26',
version: '1',
},
latestVersion: `1.${i}`,
name: `pretty cool plugin-${i}`,
pinned: false,
state: '',
type: '',
module: {},
state: undefined,
type: PluginType.panel,
module: '',
baseUrl: '',
});
}

@ -0,0 +1,112 @@
import { identityOverrideProcessor, ThresholdsMode } from '../../src';
export function mockStandardFieldConfigOptions() {
const category = ['Standard options'];
const unit = {
category,
id: 'unit',
path: 'unit',
name: 'Unit',
description: 'Value units',
// @ts-ignore
editor: () => null,
// @ts-ignore
override: () => null,
process: identityOverrideProcessor,
shouldApply: () => true,
};
const decimals = {
category,
id: 'decimals',
path: 'decimals',
name: 'Decimals',
description: 'Number of decimal to be shown for a value',
// @ts-ignore
editor: () => null,
// @ts-ignore
override: () => null,
process: identityOverrideProcessor,
shouldApply: () => true,
};
const boolean = {
category,
id: 'boolean',
path: 'boolean',
name: 'Boolean',
description: '',
// @ts-ignore
editor: () => null,
// @ts-ignore
override: () => null,
process: identityOverrideProcessor,
shouldApply: () => true,
};
const fieldColor = {
category,
id: 'color',
path: 'color',
name: 'color',
description: '',
// @ts-ignore
editor: () => null,
// @ts-ignore
override: () => null,
process: identityOverrideProcessor,
shouldApply: () => true,
};
const text = {
category,
id: 'text',
path: 'text',
name: 'text',
description: '',
// @ts-ignore
editor: () => null,
// @ts-ignore
override: () => null,
process: identityOverrideProcessor,
shouldApply: () => true,
};
const number = {
category,
id: 'number',
path: 'number',
name: 'number',
description: '',
// @ts-ignore
editor: () => null,
// @ts-ignore
override: () => null,
process: identityOverrideProcessor,
shouldApply: () => true,
};
const thresholds = {
category: ['Thresholds'],
id: 'thresholds',
path: 'thresholds',
name: 'thresholds',
description: '',
// @ts-ignore
editor: () => null,
// @ts-ignore
override: () => null,
process: identityOverrideProcessor,
shouldApply: () => true,
defaultValue: {
mode: ThresholdsMode.Absolute,
steps: [
{ value: -Infinity, color: 'green' },
{ value: 80, color: 'red' },
],
},
};
return [unit, decimals, boolean, fieldColor, text, number, thresholds];
}

@ -1,4 +1,4 @@
{
"exclude": ["dist", "node_modules", "**/*.test.ts*"],
"exclude": ["dist", "node_modules", "test", "**/*.test.ts*"],
"extends": "./tsconfig.json"
}

@ -1,4 +1,4 @@
import { getPanelPlugin } from 'app/features/plugins/__mocks__/pluginMocks';
import { getPanelPlugin } from '@grafana/data/test/__mocks__/pluginMocks';
import { setContextSrv } from '../../../../core/services/context_srv';
import { PanelModel } from '../../state/PanelModel';

@ -2,7 +2,7 @@ import { render, screen } from '@testing-library/react';
import React from 'react';
import { FieldType, getDefaultTimeRange, LoadingState, toDataFrame } from '@grafana/data';
import { getPanelPlugin } from 'app/features/plugins/__mocks__/pluginMocks';
import { getPanelPlugin } from '@grafana/data/test/__mocks__/pluginMocks';
import { PanelModel } from '../../state/PanelModel';

@ -12,9 +12,9 @@ import {
standardFieldConfigEditorRegistry,
toDataFrame,
} from '@grafana/data';
import { getPanelPlugin } from '@grafana/data/test/__mocks__/pluginMocks';
import { selectors } from '@grafana/e2e-selectors';
import { getAllOptionEditors, getAllStandardFieldConfigs } from 'app/core/components/OptionsUI/registry';
import { getPanelPlugin } from 'app/features/plugins/__mocks__/pluginMocks';
import { PanelModel } from '../../state';
import { createDashboardModelFixture } from '../../state/__fixtures__/dashboardFixtures';

@ -1,6 +1,6 @@
import { getPanelPlugin } from '@grafana/data/test/__mocks__/pluginMocks';
import { createDashboardModelFixture } from 'app/features/dashboard/state/__fixtures__/dashboardFixtures';
import { panelModelAndPluginReady, removePanel } from 'app/features/panel/state/reducers';
import { getPanelPlugin } from 'app/features/plugins/__mocks__/pluginMocks';
import { thunkTester } from '../../../../../../test/core/thunk/thunkTester';
import { PanelModel } from '../../../state';

@ -1,11 +1,11 @@
import { each, map } from 'lodash';
import { DataLinkBuiltInVars, MappingType } from '@grafana/data';
import { getPanelPlugin } from '@grafana/data/test/__mocks__/pluginMocks';
import { setDataSourceSrv } from '@grafana/runtime';
import { config } from 'app/core/config';
import { GRID_CELL_HEIGHT, GRID_CELL_VMARGIN } from 'app/core/constants';
import { mockDataSource, MockDataSourceSrv } from 'app/features/alerting/unified/mocks';
import { getPanelPlugin } from 'app/features/plugins/__mocks__/pluginMocks';
import { MIXED_DATASOURCE_NAME } from 'app/plugins/datasource/mixed/MixedDataSource';
import { VariableHide } from '../../variables/types';

@ -10,11 +10,11 @@ import {
dateTime,
TimeRange,
} from '@grafana/data';
import { getPanelPlugin } from '@grafana/data/test/__mocks__/pluginMocks';
import { mockStandardFieldConfigOptions } from '@grafana/data/test/helpers/fieldConfig';
import { setTemplateSrv } from '@grafana/runtime';
import { queryBuilder } from 'app/features/variables/shared/testing/builders';
import { mockStandardFieldConfigOptions } from '../../../../test/helpers/fieldConfig';
import { getPanelPlugin } from '../../plugins/__mocks__/pluginMocks';
import { PanelQueryRunner } from '../../query/state/PanelQueryRunner';
import { TemplateSrv } from '../../templating/template_srv';
import { variableAdapters } from '../../variables/adapters';

@ -17,6 +17,10 @@ import {
PanelModel as IPanelModel,
DataSourceRef,
CoreApp,
filterFieldConfigOverrides,
getPanelOptionsWithDefaults,
isStandardFieldProp,
restoreCustomOverrideRules,
} from '@grafana/data';
import { getTemplateSrv, RefreshEvent } from '@grafana/runtime';
import config from 'app/core/config';
@ -37,13 +41,6 @@ import { getVariablesUrlParams } from '../../variables/getAllVariableValuesForUr
import { getTimeSrv } from '../services/TimeSrv';
import { TimeOverrideResult } from '../utils/panel';
import {
filterFieldConfigOverrides,
getPanelOptionsWithDefaults,
isStandardFieldProp,
restoreCustomOverrideRules,
} from './getPanelOptionsWithDefaults';
export interface GridPos {
x: number;
y: number;

@ -2,9 +2,9 @@ import { advanceTo, clear } from 'jest-date-mock';
import { ComponentClass } from 'react';
import { dateTime, DateTime, PanelProps, TimeRange } from '@grafana/data';
import { getPanelPlugin } from '@grafana/data/test/__mocks__/pluginMocks';
import { applyPanelTimeOverrides, calculateInnerPanelHeight } from 'app/features/dashboard/utils/panel';
import { getPanelPlugin } from '../../plugins/__mocks__/pluginMocks';
import { PanelModel } from '../state';
const dashboardTimeRange: TimeRange = {

@ -1,5 +1,5 @@
import { DataSourcePluginMeta } from '@grafana/data';
import { getMockPlugin } from 'app/features/plugins/__mocks__/pluginMocks';
import { getMockPlugin } from '@grafana/data/test/__mocks__/pluginMocks';
import { buildCategories } from './buildCategories';

@ -1,4 +1,4 @@
import { getMockPlugin, getMockPlugins } from 'app/features/plugins/__mocks__/pluginMocks';
import { getMockPlugin, getMockPlugins } from '@grafana/data/test/__mocks__/pluginMocks';
import { nameExits, findNewName } from './utils';

@ -11,12 +11,13 @@ import {
compareDataFrameStructures,
PluginContextProvider,
ScopedVars,
getPanelOptionsWithDefaults,
OptionDefaults,
} from '@grafana/data';
import { getTemplateSrv, PanelRendererProps } from '@grafana/runtime';
import { ErrorBoundaryAlert, useTheme2 } from '@grafana/ui';
import { appEvents } from 'app/core/core';
import { getPanelOptionsWithDefaults, OptionDefaults } from '../../dashboard/state/getPanelOptionsWithDefaults';
import { importPanelPlugin, syncGetPanelPlugin } from '../../plugins/importPanelPlugin';
const defaultFieldConfig = { defaults: {}, overrides: [] };

@ -1,8 +1,7 @@
import { mockStandardFieldConfigOptions } from 'test/helpers/fieldConfig';
import { standardEditorsRegistry, standardFieldConfigEditorRegistry } from '@grafana/data';
import { getPanelPlugin } from '@grafana/data/test/__mocks__/pluginMocks';
import { mockStandardFieldConfigOptions } from '@grafana/data/test/helpers/fieldConfig';
import { PanelModel } from 'app/features/dashboard/state';
import { getPanelPlugin } from 'app/features/plugins/__mocks__/pluginMocks';
import { panelPluginLoaded } from 'app/features/plugins/admin/state/actions';
import { thunkTester } from '../../../../test/core/thunk/thunkTester';

@ -1,6 +1,5 @@
import { DataTransformerConfig, FieldConfigSource } from '@grafana/data';
import { DataTransformerConfig, FieldConfigSource, getPanelOptionsWithDefaults } from '@grafana/data';
import { PanelModel } from 'app/features/dashboard/state/PanelModel';
import { getPanelOptionsWithDefaults } from 'app/features/dashboard/state/getPanelOptionsWithDefaults';
import { getLibraryPanel } from 'app/features/library-panels/state/api';
import { LibraryElementDTO } from 'app/features/library-panels/types';
import { getPanelPluginNotFound } from 'app/features/panel/components/PanelPluginError';

@ -5,13 +5,13 @@ import { Route, Router } from 'react-router-dom';
import { getGrafanaContextMock } from 'test/mocks/getGrafanaContextMock';
import { AppPlugin, PluginType, AppRootProps, NavModelItem } from '@grafana/data';
import { getMockPlugin } from '@grafana/data/test/__mocks__/pluginMocks';
import { locationService, setEchoSrv } from '@grafana/runtime';
import { GrafanaContext } from 'app/core/context/GrafanaContext';
import { GrafanaRoute } from 'app/core/navigation/GrafanaRoute';
import { Echo } from 'app/core/services/echo/Echo';
import { configureStore } from 'app/store/configureStore';
import { getMockPlugin } from '../__mocks__/pluginMocks';
import { getPluginSettings } from '../pluginSettings';
import { importAppPlugin } from '../plugin_loader';

@ -1,7 +1,7 @@
import React from 'react';
import { FieldConfigProperty, PanelPlugin } from '@grafana/data';
import { getPanelPlugin } from 'app/features/plugins/__mocks__/pluginMocks';
import { getPanelPlugin } from '@grafana/data/test/__mocks__/pluginMocks';
import { VizPanel } from './VizPanel';

@ -1,12 +1,18 @@
import { DeepPartial } from '@reduxjs/toolkit';
import React from 'react';
import { AbsoluteTimeRange, FieldConfigSource, PanelModel, PanelPlugin, toUtc } from '@grafana/data';
import {
AbsoluteTimeRange,
FieldConfigSource,
PanelModel,
PanelPlugin,
toUtc,
getPanelOptionsWithDefaults,
} from '@grafana/data';
import { config } from '@grafana/runtime';
import { Field, Input } from '@grafana/ui';
import { importPanelPlugin, syncGetPanelPlugin } from 'app/features/plugins/importPanelPlugin';
import { getPanelOptionsWithDefaults } from '../../../dashboard/state/getPanelOptionsWithDefaults';
import { SceneObjectBase } from '../../core/SceneObjectBase';
import { sceneGraph } from '../../core/sceneGraph';
import { SceneComponentProps, SceneLayoutChildState } from '../../core/types';

@ -1,7 +1,7 @@
import { lastValueFrom } from 'rxjs';
import { DataSourceInstanceSettings, ScopedVars } from '@grafana/data';
import { getMockPlugin } from 'app/features/plugins/__mocks__/pluginMocks';
import { getMockPlugin } from '@grafana/data/test/__mocks__/pluginMocks';
import { SceneObject } from '../../core/types';
import { CustomFormatterFn } from '../interpolation/sceneInterpolator';

@ -1,7 +1,7 @@
import { DataSourceInstanceSettings } from '@grafana/data';
import { getMockPlugin } from '@grafana/data/test/__mocks__/pluginMocks';
import { reduxTester } from '../../../../test/core/redux/reduxTester';
import { getMockPlugin } from '../../plugins/__mocks__/pluginMocks';
import { variableAdapters } from '../adapters';
import { changeVariableEditorExtended } from '../editor/reducer';
import { datasourceBuilder } from '../shared/testing/builders';

@ -1,9 +1,9 @@
import { cloneDeep } from 'lodash';
import { DataSourceInstanceSettings } from '@grafana/data';
import { getMockPlugins } from '@grafana/data/test/__mocks__/pluginMocks';
import { reducerTester } from '../../../../test/core/redux/reducerTester';
import { getMockPlugins } from '../../plugins/__mocks__/pluginMocks';
import { getDataSourceInstanceSetting } from '../shared/testing/helpers';
import { getVariableTestContext } from '../state/helpers';
import { VariablesState } from '../state/types';

@ -1,112 +0,0 @@
import { identityOverrideProcessor, ThresholdsMode } from '@grafana/data';
export function mockStandardFieldConfigOptions() {
const category = ['Standard options'];
const unit = {
category,
id: 'unit',
path: 'unit',
name: 'Unit',
description: 'Value units',
// @ts-ignore
editor: () => null,
// @ts-ignore
override: () => null,
process: identityOverrideProcessor,
shouldApply: () => true,
};
const decimals = {
category,
id: 'decimals',
path: 'decimals',
name: 'Decimals',
description: 'Number of decimal to be shown for a value',
// @ts-ignore
editor: () => null,
// @ts-ignore
override: () => null,
process: identityOverrideProcessor,
shouldApply: () => true,
};
const boolean = {
category,
id: 'boolean',
path: 'boolean',
name: 'Boolean',
description: '',
// @ts-ignore
editor: () => null,
// @ts-ignore
override: () => null,
process: identityOverrideProcessor,
shouldApply: () => true,
};
const fieldColor = {
category,
id: 'color',
path: 'color',
name: 'color',
description: '',
// @ts-ignore
editor: () => null,
// @ts-ignore
override: () => null,
process: identityOverrideProcessor,
shouldApply: () => true,
};
const text = {
category,
id: 'text',
path: 'text',
name: 'text',
description: '',
// @ts-ignore
editor: () => null,
// @ts-ignore
override: () => null,
process: identityOverrideProcessor,
shouldApply: () => true,
};
const number = {
category,
id: 'number',
path: 'number',
name: 'number',
description: '',
// @ts-ignore
editor: () => null,
// @ts-ignore
override: () => null,
process: identityOverrideProcessor,
shouldApply: () => true,
};
const thresholds = {
category: ['Thresholds'],
id: 'thresholds',
path: 'thresholds',
name: 'thresholds',
description: '',
// @ts-ignore
editor: () => null,
// @ts-ignore
override: () => null,
process: identityOverrideProcessor,
shouldApply: () => true,
defaultValue: {
mode: ThresholdsMode.Absolute,
steps: [
{ value: -Infinity, color: 'green' },
{ value: 80, color: 'red' },
],
},
};
return [unit, decimals, boolean, fieldColor, text, number, thresholds];
}
Loading…
Cancel
Save