mirror of
https://github.com/grafana/grafana.git
synced 2025-07-30 02:02:33 +08:00

* Variables: Removes experimental Tags feature * Refactor: adds dashboard migration * Tests: fixes snapshots * Docs: removes docs for experimental feature * Refactor: dummy change * Docs: removes reference
24 lines
619 B
TypeScript
24 lines
619 B
TypeScript
import { VariableModel } from '@grafana/data';
|
|
import { VariableWithOptions } from '../types';
|
|
|
|
export const formatVariableLabel = (variable: VariableModel) => {
|
|
if (!isVariableWithOptions(variable)) {
|
|
return variable.name;
|
|
}
|
|
|
|
const { current } = variable;
|
|
|
|
if (Array.isArray(current.text)) {
|
|
return current.text.join(' + ');
|
|
}
|
|
|
|
return current.text;
|
|
};
|
|
|
|
const isVariableWithOptions = (variable: VariableModel): variable is VariableWithOptions => {
|
|
return (
|
|
Array.isArray((variable as VariableWithOptions)?.options) ||
|
|
typeof (variable as VariableWithOptions)?.current === 'object'
|
|
);
|
|
};
|