StatPanel: Add migration for singlestat tableColumn to to fields property (#25901)
This commit is contained in:
@@ -198,6 +198,18 @@ describe('sharedSingleStatMigrationHandler', () => {
|
||||
expect(panel.fieldConfig.defaults.max).toBe(undefined);
|
||||
});
|
||||
|
||||
it('change from angular singlestat with tableColumn set', () => {
|
||||
const old: any = {
|
||||
angular: {
|
||||
tableColumn: 'info',
|
||||
},
|
||||
};
|
||||
const panel = {} as PanelModel;
|
||||
const newOptions = sharedSingleStatPanelChangedHandler(panel, 'singlestat', old);
|
||||
expect(newOptions.reduceOptions.calcs).toEqual(['mean']);
|
||||
expect(newOptions.reduceOptions.fields).toBe('/^info$/');
|
||||
});
|
||||
|
||||
it('change from angular singlestat with no enabled gauge', () => {
|
||||
const old: any = {
|
||||
angular: {
|
||||
|
||||
@@ -55,7 +55,7 @@ function migrateFromAngularSinglestat(panel: PanelModel<Partial<SingleStatBaseOp
|
||||
const prevPanel = prevOptions.angular;
|
||||
const reducer = fieldReducers.getIfExists(prevPanel.valueName);
|
||||
const options = {
|
||||
fieldOptions: {
|
||||
reduceOptions: {
|
||||
calcs: [reducer ? reducer.id : ReducerID.mean],
|
||||
},
|
||||
orientation: VizOrientation.Horizontal,
|
||||
@@ -67,6 +67,10 @@ function migrateFromAngularSinglestat(panel: PanelModel<Partial<SingleStatBaseOp
|
||||
defaults.unit = prevPanel.format;
|
||||
}
|
||||
|
||||
if (prevPanel.tableColumn) {
|
||||
options.reduceOptions.fields = `/^${prevPanel.tableColumn}$/`;
|
||||
}
|
||||
|
||||
if (prevPanel.nullPointMode) {
|
||||
defaults.nullValueMode = prevPanel.nullPointMode;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user