Browse Source

some cleanup of unused stuff and type fixes

Torkel Ödegaard 7 years ago
parent
commit
9820c7806c

+ 1 - 0
public/app/features/dashboard/dashgrid/AddPanelPanel.tsx

@@ -197,6 +197,7 @@ export class AddPanelPanel extends React.Component<AddPanelPanelProps, AddPanelP
     });
 
     let panelTab;
+    console.log('panel plugins', config.panels);
 
     if (this.state.tab === 'Add') {
       panelTab = this.state.panelPlugins.map(this.renderPanelItem);

+ 14 - 21
public/app/features/dashboard/dashgrid/PanelPluginNotFound.tsx

@@ -36,34 +36,27 @@ export function getPanelPluginNotFound(id: string): PanelPlugin {
     }
   };
 
-  const info = {
-    author: {
-      name: '',
-    },
-    description: '',
-    links: [],
-    logos: {
-      large: '',
-      small: '',
-    },
-    screenshots: [],
-    updated: '',
-    version: '',
-  };
-
   return {
     id: id,
     name: id,
     sort: 100,
     module: '',
     baseUrl: '',
-    meta: {
-      id: id,
-      name: id,
-      info: info,
-      includes: [],
+    info: {
+      author: {
+        name: '',
+      },
+      description: '',
+      links: [],
+      logos: {
+        large: '',
+        small: '',
+      },
+      screenshots: [],
+      updated: '',
+      version: '',
     },
-    info: info,
+
     exports: {
       PanelComponent: NotFound,
     },

+ 5 - 7
public/app/features/dashboard/specs/AddPanelPanel.test.tsx

@@ -20,7 +20,7 @@ describe('AddPanelPanel', () => {
   beforeEach(() => {
     config.panels = [
       getPanelPlugin({ id: 'singlestat', sort: 2 }),
-      getPanelPlugin({ id: 'hiddem', sort: 100, hideFromList: true }),
+      getPanelPlugin({ id: 'hidden', sort: 100, hideFromList: true }),
       getPanelPlugin({ id: 'graph', sort: 1 }),
       getPanelPlugin({ id: 'alexander_zabbix', sort: 100 }),
       getPanelPlugin({ id: 'piechart', sort: 100 }),
@@ -33,16 +33,14 @@ describe('AddPanelPanel', () => {
   });
 
   it('should fetch all panels sorted with core plugins first', () => {
-    //console.log(wrapper.debug());
-    //console.log(wrapper.find('.add-panel__item').get(0).props.title);
-    expect(wrapper.find('.add-panel__item').get(1).props.title).toBe('Singlestat');
-    expect(wrapper.find('.add-panel__item').get(4).props.title).toBe('Piechart');
+    expect(wrapper.find('.add-panel__item').get(1).props.title).toBe('singlestat');
+    expect(wrapper.find('.add-panel__item').get(4).props.title).toBe('piechart');
   });
 
   it('should filter', () => {
     wrapper.find('input').simulate('change', { target: { value: 'p' } });
 
-    expect(wrapper.find('.add-panel__item').get(1).props.title).toBe('Piechart');
-    expect(wrapper.find('.add-panel__item').get(0).props.title).toBe('Graph');
+    expect(wrapper.find('.add-panel__item').get(1).props.title).toBe('piechart');
+    expect(wrapper.find('.add-panel__item').get(0).props.title).toBe('graph');
   });
 });

+ 20 - 4
public/app/features/datasources/settings/__snapshots__/DataSourceSettings.test.tsx.snap

@@ -65,7 +65,11 @@ exports[`Render should render alpha info text 1`] = `
                   "large": "large/logo",
                   "small": "small/logo",
                 },
-                "screenshots": "screenshot/1",
+                "screenshots": Array [
+                  Object {
+                    "path": "screenshot",
+                  },
+                ],
                 "updated": "2018-09-26",
                 "version": "1",
               },
@@ -158,7 +162,11 @@ exports[`Render should render beta info text 1`] = `
                   "large": "large/logo",
                   "small": "small/logo",
                 },
-                "screenshots": "screenshot/1",
+                "screenshots": Array [
+                  Object {
+                    "path": "screenshot",
+                  },
+                ],
                 "updated": "2018-09-26",
                 "version": "1",
               },
@@ -246,7 +254,11 @@ exports[`Render should render component 1`] = `
                   "large": "large/logo",
                   "small": "small/logo",
                 },
-                "screenshots": "screenshot/1",
+                "screenshots": Array [
+                  Object {
+                    "path": "screenshot",
+                  },
+                ],
                 "updated": "2018-09-26",
                 "version": "1",
               },
@@ -339,7 +351,11 @@ exports[`Render should render is ready only message 1`] = `
                   "large": "large/logo",
                   "small": "small/logo",
                 },
-                "screenshots": "screenshot/1",
+                "screenshots": Array [
+                  Object {
+                    "path": "screenshot",
+                  },
+                ],
                 "updated": "2018-09-26",
                 "version": "1",
               },

+ 14 - 22
public/app/features/plugins/__mocks__/pluginMocks.ts

@@ -34,33 +34,25 @@ export const getMockPlugins = (amount: number): Plugin[] => {
 };
 
 export const getPanelPlugin = (options: { id: string; sort?: number; hideFromList?: boolean }): PanelPlugin => {
-  const info = {
-    author: {
-      name: options.id + 'name',
-    },
-    description: '',
-    links: [],
-    logos: {
-      large: '',
-      small: '',
-    },
-    screenshots: [],
-    updated: '',
-    version: '',
-  };
-
   return {
     id: options.id,
     name: options.id,
     sort: options.sort || 1,
-    meta: {
-      id: options.id,
-      name: options.id,
-      info: info,
-      includes: [],
+    info: {
+      author: {
+        name: options.id + 'name',
+      },
+      description: '',
+      links: [],
+      logos: {
+        large: '',
+        small: '',
+      },
+      screenshots: [],
+      updated: '',
+      version: '',
     },
-    info: info,
-    hideFromList: options.hideFromList,
+    hideFromList: options.hideFromList === true,
     module: '',
     baseUrl: '',
   };

+ 30 - 6
public/app/features/plugins/__snapshots__/PluginList.test.tsx.snap

@@ -28,7 +28,11 @@ exports[`Render should render component 1`] = `
               "large": "large/logo",
               "small": "small/logo",
             },
-            "screenshots": "screenshot/0",
+            "screenshots": Array [
+              Object {
+                "path": "screenshot/0",
+              },
+            ],
             "updated": "2018-09-26",
             "version": "1",
           },
@@ -62,7 +66,11 @@ exports[`Render should render component 1`] = `
               "large": "large/logo",
               "small": "small/logo",
             },
-            "screenshots": "screenshot/1",
+            "screenshots": Array [
+              Object {
+                "path": "screenshot/1",
+              },
+            ],
             "updated": "2018-09-26",
             "version": "1",
           },
@@ -96,7 +104,11 @@ exports[`Render should render component 1`] = `
               "large": "large/logo",
               "small": "small/logo",
             },
-            "screenshots": "screenshot/2",
+            "screenshots": Array [
+              Object {
+                "path": "screenshot/2",
+              },
+            ],
             "updated": "2018-09-26",
             "version": "1",
           },
@@ -130,7 +142,11 @@ exports[`Render should render component 1`] = `
               "large": "large/logo",
               "small": "small/logo",
             },
-            "screenshots": "screenshot/3",
+            "screenshots": Array [
+              Object {
+                "path": "screenshot/3",
+              },
+            ],
             "updated": "2018-09-26",
             "version": "1",
           },
@@ -164,7 +180,11 @@ exports[`Render should render component 1`] = `
               "large": "large/logo",
               "small": "small/logo",
             },
-            "screenshots": "screenshot/4",
+            "screenshots": Array [
+              Object {
+                "path": "screenshot/4",
+              },
+            ],
             "updated": "2018-09-26",
             "version": "1",
           },
@@ -198,7 +218,11 @@ exports[`Render should render component 1`] = `
               "large": "large/logo",
               "small": "small/logo",
             },
-            "screenshots": "screenshot/5",
+            "screenshots": Array [
+              Object {
+                "path": "screenshot/5",
+              },
+            ],
             "updated": "2018-09-26",
             "version": "1",
           },

+ 1 - 3
public/app/features/plugins/plugin_component.ts

@@ -5,8 +5,6 @@ import config from 'app/core/config';
 import coreModule from 'app/core/core_module';
 import { importPluginModule } from './plugin_loader';
 
-import { UnknownPanelCtrl } from 'app/plugins/panel/unknown/module';
-
 /** @ngInject */
 function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $templateCache, $timeout) {
   function getTemplate(component) {
@@ -69,7 +67,7 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
     };
 
     const panelInfo = config.panels[scope.panel.type];
-    let panelCtrlPromise = Promise.resolve(UnknownPanelCtrl);
+    let panelCtrlPromise = Promise.resolve(null);
     if (panelInfo) {
       panelCtrlPromise = importPluginModule(panelInfo.module).then(panelModule => {
         return panelModule.PanelCtrl;

+ 0 - 5
public/app/plugins/panel/unknown/module.html

@@ -1,5 +0,0 @@
-<div class="text-center" style="padding-top: 2rem">
-	Unknown panel type: <strong>{{ctrl.panel.type}}</strong>
-</div>
-
-

+ 0 - 10
public/app/plugins/panel/unknown/module.ts

@@ -1,10 +0,0 @@
-import { PanelCtrl } from 'app/features/panel/panel_ctrl';
-
-export class UnknownPanelCtrl extends PanelCtrl {
-  static templateUrl = 'public/app/plugins/panel/unknown/module.html';
-
-  /** @ngInject */
-  constructor($scope, $injector) {
-    super($scope, $injector);
-  }
-}

+ 0 - 1
public/app/types/plugins.ts

@@ -18,7 +18,6 @@ export interface PluginExports {
 export interface PanelPlugin {
   id: string;
   name: string;
-  meta: PluginMeta;
   hideFromList?: boolean;
   module: string;
   baseUrl: string;