Jelajahi Sumber

feat(plugins): fix for plugin logo to navbar on plugin page, #4452

Torkel Ödegaard 9 tahun lalu
induk
melakukan
35c853e906
1 mengubah file dengan 14 tambahan dan 10 penghapusan
  1. 14 10
      public/app/features/plugins/plugin_page_ctrl.ts

+ 14 - 10
public/app/features/plugins/plugin_page_ctrl.ts

@@ -16,23 +16,27 @@ export class AppPageCtrl {
     this.pluginId = $routeParams.pluginId;
 
     if (pluginInfoCache[this.pluginId]) {
-      this.appModel = pluginInfoCache[this.pluginId];
+      this.initPage(pluginInfoCache[this.pluginId]);
     } else {
       this.loadPluginInfo();
     }
   }
 
-  loadPluginInfo() {
-    this.backendSrv.get(`/api/plugins/${this.pluginId}/settings`).then(app => {
-      this.appModel = app;
-      this.page = _.findWhere(app.includes, {slug: this.$routeParams.slug});
-      this.appLogoUrl = app.info.logos.small;
+  initPage(app) {
+    this.appModel = app;
+    this.page = _.findWhere(app.includes, {slug: this.$routeParams.slug});
+    this.appLogoUrl = app.info.logos.small;
 
-      pluginInfoCache[this.pluginId] = app;
+    pluginInfoCache[this.pluginId] = app;
 
-      if (!this.page) {
-        this.$rootScope.appEvent('alert-error', ['App Page Not Found', '']);
-      }
+    if (!this.page) {
+      this.$rootScope.appEvent('alert-error', ['App Page Not Found', '']);
+    }
+  }
+
+  loadPluginInfo() {
+    this.backendSrv.get(`/api/plugins/${this.pluginId}/settings`).then(app => {
+      this.initPage(app);
     });
   }
 }