mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Monaco: add suggestions for template variables (#25921)
* now with suggestions * using suggestions API * using variable suggestions * using variable suggestions * show variables * minor cleanup * add @alpha warning * Do not produce data variables if panel does not support queries Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
This commit is contained in:
@@ -19,6 +19,7 @@ import {
|
||||
urlUtil,
|
||||
textUtil,
|
||||
DataLink,
|
||||
PanelPlugin,
|
||||
} from '@grafana/data';
|
||||
|
||||
const timeRangeVars = [
|
||||
@@ -231,6 +232,18 @@ export const getCalculationValueDataLinksVariableSuggestions = (dataFrames: Data
|
||||
return [...seriesVars, ...fieldVars, ...valueVars, valueCalcVar, ...getPanelLinksVariableSuggestions()];
|
||||
};
|
||||
|
||||
export const getPanelOptionsVariableSuggestions = (plugin: PanelPlugin, data?: DataFrame[]): VariableSuggestion[] => {
|
||||
const dataVariables = plugin.meta.skipDataQuery ? [] : getDataFrameVars(data || []);
|
||||
return [
|
||||
...dataVariables, // field values
|
||||
...templateSrv.getVariables().map(variable => ({
|
||||
value: variable.name as string,
|
||||
label: variable.name,
|
||||
origin: VariableOrigin.Template,
|
||||
})),
|
||||
];
|
||||
};
|
||||
|
||||
export interface LinkService {
|
||||
getDataLinkUIModel: <T>(link: DataLink, scopedVars: ScopedVars, origin: T) => LinkModel<T>;
|
||||
getAnchorInfo: (link: any) => any;
|
||||
|
||||
Reference in New Issue
Block a user