mirror of
https://github.com/grafana/grafana.git
synced 2025-08-06 04:19:26 +08:00
Plugins: Adds back getMappedValue to @grafana/data (#34746)
* Plugins: Adds back getMappedValue to @grafana/data * Chore: fixes doc errors * Tests: fixes snapshot * Tests: dummy change to restart Drone * Tests: tries to fix snapshot
This commit is contained in:
@ -1,20 +1,20 @@
|
||||
import { cloneDeep, isNumber, omit } from 'lodash';
|
||||
|
||||
import {
|
||||
fieldReducers,
|
||||
Threshold,
|
||||
sortThresholds,
|
||||
convertOldAngularValueMappings,
|
||||
FieldColorModeId,
|
||||
FieldConfig,
|
||||
ReducerID,
|
||||
ValueMapping,
|
||||
MappingType,
|
||||
VizOrientation,
|
||||
fieldReducers,
|
||||
PanelModel,
|
||||
ReduceDataOptions,
|
||||
ThresholdsMode,
|
||||
ReducerID,
|
||||
sortThresholds,
|
||||
Threshold,
|
||||
ThresholdsConfig,
|
||||
ThresholdsMode,
|
||||
validateFieldConfig,
|
||||
FieldColorModeId,
|
||||
ValueMapping,
|
||||
VizOrientation,
|
||||
} from '@grafana/data';
|
||||
import { OptionsWithTextFormatting } from '../../options';
|
||||
|
||||
@ -325,41 +325,9 @@ export function migrateOldThresholds(thresholds?: any[]): Threshold[] | undefine
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use convertOldAngularValueMappings instead
|
||||
* Convert the angular single stat mapping to new react style
|
||||
*/
|
||||
export function convertOldAngularValueMapping(panel: any): ValueMapping[] {
|
||||
const mappings: ValueMapping[] = [];
|
||||
|
||||
// Guess the right type based on options
|
||||
let mappingType = panel.mappingType;
|
||||
if (!panel.mappingType) {
|
||||
if (panel.valueMaps && panel.valueMaps.length) {
|
||||
mappingType = 1;
|
||||
} else if (panel.rangeMaps && panel.rangeMaps.length) {
|
||||
mappingType = 2;
|
||||
}
|
||||
}
|
||||
|
||||
// check value to text mappings if its enabled
|
||||
if (mappingType === 1) {
|
||||
for (let i = 0; i < panel.valueMaps.length; i++) {
|
||||
const map = panel.valueMaps[i];
|
||||
mappings.push({
|
||||
...map,
|
||||
id: i, // used for order
|
||||
type: MappingType.ValueToText,
|
||||
});
|
||||
}
|
||||
} else if (mappingType === 2) {
|
||||
for (let i = 0; i < panel.rangeMaps.length; i++) {
|
||||
const map = panel.rangeMaps[i];
|
||||
mappings.push({
|
||||
...map,
|
||||
id: i, // used for order
|
||||
type: MappingType.RangeToText,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return mappings;
|
||||
return convertOldAngularValueMappings(panel);
|
||||
}
|
||||
|
Reference in New Issue
Block a user