浏览代码

Merge pull request #15354 from grafana/fix/plugin-loading-failure

Fix plugin loading failure message not being displayed
Torkel Ödegaard 6 年之前
父节点
当前提交
6f16f70456
共有 1 个文件被更改,包括 9 次插入4 次删除
  1. 9 4
      public/app/features/dashboard/dashgrid/DashboardPanel.tsx

+ 9 - 4
public/app/features/dashboard/dashgrid/DashboardPanel.tsx

@@ -68,7 +68,7 @@ export class DashboardPanel extends PureComponent<Props, State> {
 
     // handle plugin loading & changing of plugin type
     if (!this.state.plugin || this.state.plugin.id !== pluginId) {
-      const plugin = config.panels[pluginId] || getPanelPluginNotFound(pluginId);
+      let plugin = config.panels[pluginId] || getPanelPluginNotFound(pluginId);
 
       // remember if this is from an angular panel
       const fromAngularPanel = this.state.angularPanel != null;
@@ -81,10 +81,15 @@ export class DashboardPanel extends PureComponent<Props, State> {
       }
 
       if (plugin.exports) {
-        this.setState({ plugin: plugin, angularPanel: null });
+        this.setState({ plugin, angularPanel: null });
       } else {
-        plugin.exports = await importPluginModule(plugin.module);
-        this.setState({ plugin: plugin, angularPanel: null });
+        try {
+          plugin.exports = await importPluginModule(plugin.module);
+        } catch (e) {
+          plugin = getPanelPluginNotFound(pluginId);
+        }
+
+        this.setState({ plugin, angularPanel: null });
       }
     }
   }