adapter.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { ComponentType } from 'react';
  2. import { LoadingState } from '@grafana/data';
  3. import { VariableAdapter } from '../adapters';
  4. import { VariableEditorProps } from '../editor/types';
  5. import { VariablePickerProps } from '../pickers/types';
  6. import { initialVariableModelState, SystemVariable, VariableHide } from '../types';
  7. export const createSystemVariableAdapter = (): VariableAdapter<SystemVariable<any>> => {
  8. return {
  9. id: 'system',
  10. description: '',
  11. name: 'system',
  12. initialState: {
  13. ...initialVariableModelState,
  14. type: 'system',
  15. hide: VariableHide.hideVariable,
  16. skipUrlSync: true,
  17. current: { value: { toString: () => '' } },
  18. state: LoadingState.Done,
  19. },
  20. reducer: (state: any, action: any) => state,
  21. picker: null as unknown as ComponentType<VariablePickerProps<SystemVariable<any>>>,
  22. editor: null as unknown as ComponentType<VariableEditorProps<SystemVariable<any>>>,
  23. dependsOn: () => {
  24. return false;
  25. },
  26. setValue: async (variable, option, emitChanges = false) => {
  27. return;
  28. },
  29. setValueFromUrl: async (variable, urlValue) => {
  30. return;
  31. },
  32. updateOptions: async (variable) => {
  33. return;
  34. },
  35. getSaveModel: (variable) => {
  36. return {};
  37. },
  38. getValueForUrl: (variable) => {
  39. return '';
  40. },
  41. };
  42. };