mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* Chore: reduces a lot of variable errors * Chore: reduces variable Editor errors * Chore: reduces variable Picker errors * Chore: reduce error count * Chore: reduces errors for ChangeEvent instead of FormEvent * Chore: reduces errors with CombinedState * Chore: reduces ComponentType errors * Chore: reduce errors in reducers * Chore: reduces misc errors * Chore: reduce AdhocPicker errors * Chore: reduce error limit * Update public/app/features/variables/adhoc/picker/AdHocFilterValue.tsx Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com> * Chore: updates after PR comments * Chore: small refactor Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
47 lines
2.0 KiB
TypeScript
47 lines
2.0 KiB
TypeScript
import { ComponentType } from 'react';
|
|
import { Reducer } from 'redux';
|
|
import { Registry, UrlQueryValue, VariableType } from '@grafana/data';
|
|
|
|
import { VariableModel, VariableOption } from './types';
|
|
import { VariableEditorProps } from './editor/types';
|
|
import { VariablesState } from './state/variablesReducer';
|
|
import { VariablePickerProps } from './pickers/types';
|
|
import { createQueryVariableAdapter } from './query/adapter';
|
|
import { createCustomVariableAdapter } from './custom/adapter';
|
|
import { createTextBoxVariableAdapter } from './textbox/adapter';
|
|
import { createConstantVariableAdapter } from './constant/adapter';
|
|
import { createDataSourceVariableAdapter } from './datasource/adapter';
|
|
import { createIntervalVariableAdapter } from './interval/adapter';
|
|
import { createAdHocVariableAdapter } from './adhoc/adapter';
|
|
import { createSystemVariableAdapter } from './system/adapter';
|
|
|
|
export interface VariableAdapter<Model extends VariableModel> {
|
|
id: VariableType;
|
|
description: string;
|
|
name: string;
|
|
initialState: Model;
|
|
dependsOn: (variable: Model, variableToTest: Model) => boolean;
|
|
setValue: (variable: Model, option: VariableOption, emitChanges?: boolean) => Promise<void>;
|
|
setValueFromUrl: (variable: Model, urlValue: UrlQueryValue) => Promise<void>;
|
|
updateOptions: (variable: Model, searchFilter?: string) => Promise<void>;
|
|
getSaveModel: (variable: Model, saveCurrentAsDefault?: boolean) => Partial<Model>;
|
|
getValueForUrl: (variable: Model) => string | string[];
|
|
picker: ComponentType<VariablePickerProps<Model>>;
|
|
editor: ComponentType<VariableEditorProps<Model>>;
|
|
reducer: Reducer<VariablesState>;
|
|
beforeAdding?: (model: any) => any;
|
|
}
|
|
|
|
export const getDefaultVariableAdapters = () => [
|
|
createQueryVariableAdapter(),
|
|
createCustomVariableAdapter(),
|
|
createTextBoxVariableAdapter(),
|
|
createConstantVariableAdapter(),
|
|
createDataSourceVariableAdapter(),
|
|
createIntervalVariableAdapter(),
|
|
createAdHocVariableAdapter(),
|
|
createSystemVariableAdapter(),
|
|
];
|
|
|
|
export const variableAdapters = new Registry<VariableAdapter<any>>();
|