diff --git a/public/app/features/dashboard-scene/panel-edit/PanelEditor.tsx b/public/app/features/dashboard-scene/panel-edit/PanelEditor.tsx index e5a1e1db952..c7e6e8013aa 100644 --- a/public/app/features/dashboard-scene/panel-edit/PanelEditor.tsx +++ b/public/app/features/dashboard-scene/panel-edit/PanelEditor.tsx @@ -117,28 +117,6 @@ export class PanelEditor extends SceneObjectBase { }; } - private async _autoSelectVisualization(panel: VizPanel) { - const dataObject = sceneGraph.getData(panel); - - this._subs.add( - dataObject.subscribeToState(async () => { - const { data } = dataObject.state; - if (hasData(data) && panel.state.pluginId === UNCONFIGURED_PANEL_PLUGIN_ID) { - const { suggestions } = await getAllSuggestions(data); - - if (suggestions.length > 0) { - const defaultFirstSuggestion = suggestions[0]; - await panel.changePluginType( - defaultFirstSuggestion.pluginId, - defaultFirstSuggestion.options, - defaultFirstSuggestion.fieldConfig - ); - } - } - }) - ); - } - private commitChanges() { if (!this.state.isDirty && !this._changesHaveBeenMade) { // Nothing to commit @@ -150,7 +128,6 @@ export class PanelEditor extends SceneObjectBase { const originalState = this._layoutItemState!; this.setState({ editPreview: undefined }); - this.state.optionsPane?.setState({ editPreviewRef: undefined }); // Temp fix for old edit mode if (this._layoutItem instanceof DashboardGridItem && !config.featureToggles.dashboardNewLayouts) { diff --git a/public/app/features/dashboard-scene/utils/utils.ts b/public/app/features/dashboard-scene/utils/utils.ts index 11f490530d1..bdd792bcde3 100644 --- a/public/app/features/dashboard-scene/utils/utils.ts +++ b/public/app/features/dashboard-scene/utils/utils.ts @@ -293,6 +293,8 @@ export function getDefaultVizPanel(): VizPanel { ? '' : t('dashboard.new-panel-title', 'New panel'); + const datasourceSettings = getDataSourceSrv().getInstanceSettings(null); + return new VizPanel({ title: newPanelTitle, pluginId: defaultPluginId, @@ -310,14 +312,16 @@ export function getDefaultVizPanel(): VizPanel { headerActions: new VizPanelHeaderActions({ hideGroupByAction: !config.featureToggles.panelGroupBy, }), - $data: new SceneDataTransformer({ - $data: new SceneQueryRunner({ - queries: [{ refId: 'A' }], - datasource: getDataSourceRef(getDataSourceSrv().getInstanceSettings(null)!), - $behaviors: [new DashboardDatasourceBehaviour({})], - }), - transformations: [], - }), + $data: datasourceSettings + ? new SceneDataTransformer({ + $data: new SceneQueryRunner({ + queries: [{ refId: 'A' }], + datasource: getDataSourceRef(datasourceSettings), + $behaviors: [new DashboardDatasourceBehaviour({})], + }), + transformations: [], + }) + : undefined, }); }