grafana/public/app/plugins/panel/gauge/GaugeMigrations.ts
Ashley Harrison 2a34293689
Chore: more type fixes (#62952)
* fix some more any/type assertions

* more any/type assertion fixes

* implement review comments
2023-02-09 09:03:13 +00:00

30 lines
1.0 KiB
TypeScript

import { PanelModel } from '@grafana/data';
import { sharedSingleStatPanelChangedHandler, sharedSingleStatMigrationHandler } from '@grafana/ui';
import { PanelOptions } from './panelcfg.gen';
// This is called when the panel first loads
export const gaugePanelMigrationHandler = (panel: PanelModel<PanelOptions>): Partial<PanelOptions> => {
return sharedSingleStatMigrationHandler(panel);
};
// This is called when the panel changes from another panel
export const gaugePanelChangedHandler = (
panel: PanelModel<Partial<PanelOptions>>,
prevPluginId: string,
prevOptions: any
) => {
// This handles most config changes
const opts: PanelOptions = sharedSingleStatPanelChangedHandler(panel, prevPluginId, prevOptions);
// Changing from angular singlestat
if (prevPluginId === 'singlestat' && prevOptions.angular) {
const gauge = prevOptions.angular.gauge;
if (gauge) {
opts.showThresholdMarkers = gauge.thresholdMarkers;
opts.showThresholdLabels = gauge.thresholdLabels;
}
}
return opts;
};