pluginMocks.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import { Plugin, PanelPlugin, PanelDataFormat } from 'app/types';
  2. export const getMockPlugins = (amount: number): Plugin[] => {
  3. const plugins = [];
  4. for (let i = 0; i <= amount; i++) {
  5. plugins.push({
  6. defaultNavUrl: 'some/url',
  7. enabled: false,
  8. hasUpdate: false,
  9. id: `${i}`,
  10. info: {
  11. author: {
  12. name: 'Grafana Labs',
  13. url: 'url/to/GrafanaLabs',
  14. },
  15. description: 'pretty decent plugin',
  16. links: ['one link'],
  17. logos: { small: 'small/logo', large: 'large/logo' },
  18. screenshots: [{ path: `screenshot/${i}` }],
  19. updated: '2018-09-26',
  20. version: '1',
  21. },
  22. latestVersion: `1.${i}`,
  23. name: `pretty cool plugin-${i}`,
  24. pinned: false,
  25. state: '',
  26. type: '',
  27. module: {},
  28. });
  29. }
  30. return plugins;
  31. };
  32. export const getPanelPlugin = (options: Partial<PanelPlugin>): PanelPlugin => {
  33. return {
  34. id: options.id,
  35. name: options.id,
  36. sort: options.sort || 1,
  37. dataFormats: [PanelDataFormat.TimeSeries],
  38. info: {
  39. author: {
  40. name: options.id + 'name',
  41. },
  42. description: '',
  43. links: [],
  44. logos: {
  45. large: '',
  46. small: '',
  47. },
  48. screenshots: [],
  49. updated: '',
  50. version: '',
  51. },
  52. hideFromList: options.hideFromList === true,
  53. module: '',
  54. baseUrl: '',
  55. reactPlugin: options.reactPlugin,
  56. angularPlugin: options.angularPlugin,
  57. };
  58. };
  59. export const getMockPlugin = () => {
  60. return {
  61. defaultNavUrl: 'some/url',
  62. enabled: false,
  63. hasUpdate: false,
  64. id: '1',
  65. info: {
  66. author: {
  67. name: 'Grafana Labs',
  68. url: 'url/to/GrafanaLabs',
  69. },
  70. description: 'pretty decent plugin',
  71. links: [{ name: 'project', url: 'one link' }],
  72. logos: { small: 'small/logo', large: 'large/logo' },
  73. screenshots: [{ path: `screenshot` }],
  74. updated: '2018-09-26',
  75. version: '1',
  76. },
  77. latestVersion: '1',
  78. name: 'pretty cool plugin 1',
  79. pinned: false,
  80. state: '',
  81. type: '',
  82. module: {},
  83. };
  84. };