mirror of
https://github.com/grafana/grafana.git
synced 2025-02-16 18:34:52 -06:00
* Initial commit * Chore: fixes after merge * Chore: removes todos * Chore: uncomment test * Chore: adds missing externals to rollup config * Refactor: selectors is master for everything * Docs: updates Docs * Chore: adds e2e-selectors to publish
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import React, { PureComponent } from 'react';
|
|
import { getTagColorsFromName, Icon } from '@grafana/ui';
|
|
import { selectors } from '@grafana/e2e-selectors';
|
|
|
|
import { VariableTag } from '../../../templating/types';
|
|
|
|
interface Props {
|
|
onClick: () => void;
|
|
text: string;
|
|
tags: VariableTag[];
|
|
}
|
|
export class VariableLink extends PureComponent<Props> {
|
|
onClick = (event: React.MouseEvent<HTMLAnchorElement>) => {
|
|
event.stopPropagation();
|
|
event.preventDefault();
|
|
this.props.onClick();
|
|
};
|
|
|
|
render() {
|
|
const { tags = [], text } = this.props;
|
|
|
|
return (
|
|
<a
|
|
onClick={this.onClick}
|
|
className="variable-value-link"
|
|
aria-label={selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${text}`)}
|
|
>
|
|
{text}
|
|
{tags.map(tag => {
|
|
const { color, borderColor } = getTagColorsFromName(tag.text.toString());
|
|
return (
|
|
<span bs-tooltip="tag.valuesText" data-placement="bottom" key={`${tag.text}`}>
|
|
<span className="label-tag" style={{ backgroundColor: color, borderColor }}>
|
|
|
|
<Icon name="tag-alt" />
|
|
{tag.text}
|
|
</span>
|
|
</span>
|
|
);
|
|
})}
|
|
<Icon name="angle-down" size="sm" />
|
|
</a>
|
|
);
|
|
}
|
|
}
|