The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/features/variables/editor/selectors.ts

41 lines
1.2 KiB

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;
}