pluginMocks.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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: { id: string; sort?: number; hideFromList?: boolean }): 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. };
  56. };
  57. export const getMockPlugin = () => {
  58. return {
  59. defaultNavUrl: 'some/url',
  60. enabled: false,
  61. hasUpdate: false,
  62. id: '1',
  63. info: {
  64. author: {
  65. name: 'Grafana Labs',
  66. url: 'url/to/GrafanaLabs',
  67. },
  68. description: 'pretty decent plugin',
  69. links: [{ name: 'project', url: 'one link' }],
  70. logos: { small: 'small/logo', large: 'large/logo' },
  71. screenshots: [{ path: `screenshot` }],
  72. updated: '2018-09-26',
  73. version: '1',
  74. },
  75. latestVersion: '1',
  76. name: 'pretty cool plugin 1',
  77. pinned: false,
  78. state: '',
  79. type: '',
  80. module: {},
  81. };
  82. };