mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 08:35:43 -06:00
* Chore: Fix typescript strict null errors * Added new limit * Fixed ts issue * fixed tests * trying to fix type inference * Fixing more ts errors * Revert tsconfig option * Fix * Fixed code * More fixes * fix tests * Updated snapshot * Chore: More ts strict null fixes * More fixes in some really messed up azure config components * More fixes, current count: 441 * 419 * More fixes * Fixed invalid initial state in explore * Fixing tests * Fixed tests * Explore fix * More fixes * Progress * Sub 300 * Now at 218 * Progress * Update * Progress * Updated tests * at 159 * fixed tests * Progress * YAy blow 100! at 94 * 10,9,8,7,6,5,4,3,2,1... lift off * Fixed tests * Fixed more type errors Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
99 lines
2.4 KiB
TypeScript
99 lines
2.4 KiB
TypeScript
import { defaultsDeep } from 'lodash';
|
|
import { PanelPluginMeta, PluginMeta, PluginType, PanelPlugin, PanelProps } from '@grafana/data';
|
|
import { ComponentType } from 'enzyme';
|
|
|
|
export const getMockPlugins = (amount: number): PluginMeta[] => {
|
|
const plugins = [];
|
|
|
|
for (let i = 0; i <= amount; i++) {
|
|
plugins.push({
|
|
defaultNavUrl: 'some/url',
|
|
enabled: false,
|
|
hasUpdate: false,
|
|
id: `${i}`,
|
|
info: {
|
|
author: {
|
|
name: 'Grafana Labs',
|
|
url: 'url/to/GrafanaLabs',
|
|
},
|
|
description: 'pretty decent plugin',
|
|
links: ['one link'],
|
|
logos: { small: 'small/logo', large: 'large/logo' },
|
|
screenshots: [{ path: `screenshot/${i}` }],
|
|
updated: '2018-09-26',
|
|
version: '1',
|
|
},
|
|
latestVersion: `1.${i}`,
|
|
name: `pretty cool plugin-${i}`,
|
|
pinned: false,
|
|
state: '',
|
|
type: '',
|
|
module: {},
|
|
});
|
|
}
|
|
|
|
return plugins as any;
|
|
};
|
|
|
|
export function getPanelPlugin(
|
|
options: Partial<PanelPluginMeta>,
|
|
reactPanel?: ComponentType<PanelProps>,
|
|
angularPanel?: any
|
|
): PanelPlugin {
|
|
const plugin = new PanelPlugin(reactPanel!);
|
|
plugin.angularPanelCtrl = angularPanel;
|
|
plugin.meta = {
|
|
id: options.id!,
|
|
type: PluginType.panel,
|
|
name: options.id!,
|
|
sort: options.sort || 1,
|
|
info: {
|
|
author: {
|
|
name: options.id + 'name',
|
|
},
|
|
description: '',
|
|
links: [],
|
|
logos: {
|
|
large: '',
|
|
small: '',
|
|
},
|
|
screenshots: [],
|
|
updated: '',
|
|
version: '',
|
|
},
|
|
hideFromList: options.hideFromList === true,
|
|
module: '',
|
|
baseUrl: '',
|
|
};
|
|
return plugin;
|
|
}
|
|
|
|
export function getMockPlugin(overrides?: Partial<PluginMeta>): PluginMeta {
|
|
const defaults: PluginMeta = {
|
|
defaultNavUrl: 'some/url',
|
|
enabled: false,
|
|
hasUpdate: false,
|
|
id: '1',
|
|
info: {
|
|
author: {
|
|
name: 'Grafana Labs',
|
|
url: 'url/to/GrafanaLabs',
|
|
},
|
|
description: 'pretty decent plugin',
|
|
links: [{ name: 'project', url: 'one link' }],
|
|
logos: { small: 'small/logo', large: 'large/logo' },
|
|
screenshots: [{ path: `screenshot`, name: 'test' }],
|
|
updated: '2018-09-26',
|
|
version: '1',
|
|
},
|
|
latestVersion: '1',
|
|
name: 'pretty cool plugin 1',
|
|
baseUrl: 'path/to/plugin',
|
|
pinned: false,
|
|
type: PluginType.panel,
|
|
module: 'path/to/module',
|
|
};
|
|
|
|
return defaultsDeep(overrides || {}, defaults) as PluginMeta;
|
|
}
|