2020-06-25 00:38:55 -05:00
|
|
|
import { ComponentType } from 'react';
|
2020-10-02 00:02:06 -05:00
|
|
|
import { LoadingState } from '@grafana/data';
|
|
|
|
|
|
|
|
import { initialVariableModelState, SystemVariable, VariableHide } from '../types';
|
2020-06-25 00:38:55 -05:00
|
|
|
import { VariableAdapter } from '../adapters';
|
|
|
|
import { VariablePickerProps } from '../pickers/types';
|
|
|
|
import { VariableEditorProps } from '../editor/types';
|
|
|
|
|
|
|
|
export const createSystemVariableAdapter = (): VariableAdapter<SystemVariable<any>> => {
|
|
|
|
return {
|
|
|
|
id: 'system',
|
|
|
|
description: '',
|
|
|
|
name: 'system',
|
|
|
|
initialState: {
|
2020-10-02 00:02:06 -05:00
|
|
|
...initialVariableModelState,
|
2020-06-25 00:38:55 -05:00
|
|
|
type: 'system',
|
|
|
|
hide: VariableHide.hideVariable,
|
|
|
|
skipUrlSync: true,
|
|
|
|
current: { value: { toString: () => '' } },
|
2020-10-02 00:02:06 -05:00
|
|
|
state: LoadingState.Done,
|
2020-06-25 00:38:55 -05:00
|
|
|
},
|
|
|
|
reducer: (state: any, action: any) => state,
|
2021-02-17 23:21:35 -06:00
|
|
|
picker: (null as unknown) as ComponentType<VariablePickerProps<SystemVariable<any>>>,
|
|
|
|
editor: (null as unknown) as ComponentType<VariableEditorProps<SystemVariable<any>>>,
|
2020-06-25 00:38:55 -05:00
|
|
|
dependsOn: () => {
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
setValue: async (variable, option, emitChanges = false) => {
|
|
|
|
return;
|
|
|
|
},
|
|
|
|
setValueFromUrl: async (variable, urlValue) => {
|
|
|
|
return;
|
|
|
|
},
|
2021-01-20 00:59:48 -06:00
|
|
|
updateOptions: async (variable) => {
|
2020-06-25 00:38:55 -05:00
|
|
|
return;
|
|
|
|
},
|
2021-01-20 00:59:48 -06:00
|
|
|
getSaveModel: (variable) => {
|
2020-06-25 00:38:55 -05:00
|
|
|
return {};
|
|
|
|
},
|
2021-01-20 00:59:48 -06:00
|
|
|
getValueForUrl: (variable) => {
|
2020-06-25 00:38:55 -05:00
|
|
|
return '';
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|