v8: remove Singlestat panel and add automatic migration to stat/gauge(#31904)

* Remove singlestat panel from the codebase

* Automatically migrate deprecated panels

* Migrate singlestat to stat when initializing panel

* Singlestat -> gauge detection

* Missing await

* Throw error when panel plugin not found and allow new panels to take names of the deprecated ones

* Make it pretty

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
This commit is contained in:
Dominik Prokop
2021-04-12 12:47:17 +02:00
committed by GitHub
parent a6fcd37a20
commit b47fba4b68
16 changed files with 53 additions and 2434 deletions

View File

@@ -15,6 +15,9 @@ import { loadPanelPlugin } from 'app/features/plugins/state/actions';
import { DashboardAcl, DashboardAclUpdateDTO, NewDashboardAclItem, PermissionLevel, ThunkResult } from 'app/types';
import { PanelModel } from './PanelModel';
import { cancelVariables } from '../../variables/state/actions';
import { isDeprecatedPanel } from '../utils/panel';
import { DEPRECATED_PANELS } from '../../../core/constants';
import { getPanelPluginNotFound } from '../dashgrid/PanelPluginError';
import { getTimeSrv } from '../services/TimeSrv';
export function getDashboardPermissions(id: number): ThunkResult<void> {
@@ -120,10 +123,27 @@ export function removeDashboard(uri: string): ThunkResult<void> {
export function initDashboardPanel(panel: PanelModel): ThunkResult<void> {
return async (dispatch, getStore) => {
let plugin = getStore().plugins.panels[panel.type];
let pluginToLoad = panel.type;
const isDeprecated = isDeprecatedPanel(panel.type);
let notFound = false;
let plugin = getStore().plugins.panels[pluginToLoad];
if (!plugin) {
plugin = await dispatch(loadPanelPlugin(panel.type));
try {
plugin = await dispatch(loadPanelPlugin(pluginToLoad));
} catch (e) {
// When plugin not found
plugin = getPanelPluginNotFound(pluginToLoad);
notFound = true;
}
}
// if there isn't an "external" plugin with the same name as deprecated one, load the deprecated panel replacement
if (notFound && isDeprecated) {
pluginToLoad = DEPRECATED_PANELS[panel.type](panel);
plugin = await dispatch(loadPanelPlugin(pluginToLoad));
await dispatch(changePanelPlugin(panel, pluginToLoad));
}
if (!panel.plugin) {