mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* Adhoc variable: Correctly preselect datasource when provisioning * Fix test * Remove data sources from ad hoc variable state in favor of DataSourcePicker
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import {
|
|
AdHocVariableEditorState,
|
|
DataSourceVariableEditorState,
|
|
QueryVariableEditorState,
|
|
VariableEditorState,
|
|
} from './reducer';
|
|
|
|
/**
|
|
* Narrows generic variable editor state down to specific Adhoc variable extended editor state
|
|
*/
|
|
export function getAdhocVariableEditorState(editorState: VariableEditorState): AdHocVariableEditorState | null {
|
|
if (editorState.extended && 'infoText' in editorState.extended) {
|
|
return editorState.extended;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* Narrows generic variable editor state down to specific Datasource variable extended editor state
|
|
*/
|
|
export function getDatasourceVariableEditorState(
|
|
editorState: VariableEditorState
|
|
): DataSourceVariableEditorState | null {
|
|
if (editorState.extended && 'dataSourceTypes' in editorState.extended) {
|
|
return editorState.extended;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* Narrows generic variable editor state down to specific Query variable extended editor state
|
|
*/
|
|
export function getQueryVariableEditorState(editorState: VariableEditorState): QueryVariableEditorState | null {
|
|
if (editorState.extended && 'dataSource' in editorState.extended) {
|
|
return editorState.extended;
|
|
}
|
|
|
|
return null;
|
|
}
|