mirror of
https://github.com/grafana/grafana.git
synced 2025-02-16 02:23:31 -06:00
* Use last used datasource or default datasource when starting a trail * Use tabs and move actions bar to same line when possible * Added overview tab with description, type and labels * Clickable labels in overview tab * Show label value counts next to the label name * Fix action bar zIndex * Address PR comments * Refactor * Refactor getLabelOptions to utils * Reuse language provider from state * betterer * testing some refactors * Remove unreachable code * Refactor GROUP_BY var to MetricScene * Fix url by excluding var-groupby * Fix conflicts * Use <Text/> instead of custom styles * Simplify setting overview as default tab --------- Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
25 lines
808 B
TypeScript
25 lines
808 B
TypeScript
import { SelectableValue } from '@grafana/data';
|
|
import { AdHocFiltersVariable, QueryVariable, sceneGraph, SceneObject } from '@grafana/scenes';
|
|
|
|
import { VAR_FILTERS } from '../shared';
|
|
|
|
export function getLabelOptions(scenObject: SceneObject, variable: QueryVariable) {
|
|
const labelFilters = sceneGraph.lookupVariable(VAR_FILTERS, scenObject);
|
|
const labelOptions: Array<SelectableValue<string>> = [];
|
|
|
|
if (!(labelFilters instanceof AdHocFiltersVariable)) {
|
|
return [];
|
|
}
|
|
|
|
const filters = labelFilters.state.set.state.filters;
|
|
|
|
for (const option of variable.getOptionsForSelect()) {
|
|
const filterExists = filters.find((f) => f.key === option.value);
|
|
if (!filterExists) {
|
|
labelOptions.push({ label: option.label, value: String(option.value) });
|
|
}
|
|
}
|
|
|
|
return labelOptions;
|
|
}
|