fieldConfig.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. import { identityOverrideProcessor, ThresholdsMode } from '@grafana/data';
  2. export function mockStandardFieldConfigOptions() {
  3. const category = ['Standard options'];
  4. const unit = {
  5. category,
  6. id: 'unit',
  7. path: 'unit',
  8. name: 'Unit',
  9. description: 'Value units',
  10. // @ts-ignore
  11. editor: () => null,
  12. // @ts-ignore
  13. override: () => null,
  14. process: identityOverrideProcessor,
  15. shouldApply: () => true,
  16. };
  17. const decimals = {
  18. category,
  19. id: 'decimals',
  20. path: 'decimals',
  21. name: 'Decimals',
  22. description: 'Number of decimal to be shown for a value',
  23. // @ts-ignore
  24. editor: () => null,
  25. // @ts-ignore
  26. override: () => null,
  27. process: identityOverrideProcessor,
  28. shouldApply: () => true,
  29. };
  30. const boolean = {
  31. category,
  32. id: 'boolean',
  33. path: 'boolean',
  34. name: 'Boolean',
  35. description: '',
  36. // @ts-ignore
  37. editor: () => null,
  38. // @ts-ignore
  39. override: () => null,
  40. process: identityOverrideProcessor,
  41. shouldApply: () => true,
  42. };
  43. const fieldColor = {
  44. category,
  45. id: 'color',
  46. path: 'color',
  47. name: 'color',
  48. description: '',
  49. // @ts-ignore
  50. editor: () => null,
  51. // @ts-ignore
  52. override: () => null,
  53. process: identityOverrideProcessor,
  54. shouldApply: () => true,
  55. };
  56. const text = {
  57. category,
  58. id: 'text',
  59. path: 'text',
  60. name: 'text',
  61. description: '',
  62. // @ts-ignore
  63. editor: () => null,
  64. // @ts-ignore
  65. override: () => null,
  66. process: identityOverrideProcessor,
  67. shouldApply: () => true,
  68. };
  69. const number = {
  70. category,
  71. id: 'number',
  72. path: 'number',
  73. name: 'number',
  74. description: '',
  75. // @ts-ignore
  76. editor: () => null,
  77. // @ts-ignore
  78. override: () => null,
  79. process: identityOverrideProcessor,
  80. shouldApply: () => true,
  81. };
  82. const thresholds = {
  83. category: ['Thresholds'],
  84. id: 'thresholds',
  85. path: 'thresholds',
  86. name: 'thresholds',
  87. description: '',
  88. // @ts-ignore
  89. editor: () => null,
  90. // @ts-ignore
  91. override: () => null,
  92. process: identityOverrideProcessor,
  93. shouldApply: () => true,
  94. defaultValue: {
  95. mode: ThresholdsMode.Absolute,
  96. steps: [
  97. { value: -Infinity, color: 'green' },
  98. { value: 80, color: 'red' },
  99. ],
  100. },
  101. };
  102. return [unit, decimals, boolean, fieldColor, text, number, thresholds];
  103. }