problems panel: handle tag click
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
import { ZBXTag } from '../types';
|
import { ZBXTag } from '../types';
|
||||||
|
|
||||||
const TAG_COLORS = [
|
const TAG_COLORS = [
|
||||||
@@ -87,20 +87,31 @@ function djb2(str) {
|
|||||||
interface EventTagProps {
|
interface EventTagProps {
|
||||||
tag: ZBXTag;
|
tag: ZBXTag;
|
||||||
highlight?: boolean;
|
highlight?: boolean;
|
||||||
|
onClick?: (tag: ZBXTag) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
function EventTag(props: EventTagProps) {
|
class EventTag extends PureComponent<EventTagProps> {
|
||||||
const { tag, highlight } = props;
|
handleClick = () => {
|
||||||
const tagColor = getTagColorsFromName(tag.tag);
|
if (this.props.onClick) {
|
||||||
const style: React.CSSProperties = {
|
this.props.onClick(this.props.tag);
|
||||||
background: tagColor.color,
|
}
|
||||||
borderColor: tagColor.borderColor,
|
}
|
||||||
};
|
|
||||||
return (
|
render() {
|
||||||
<span className={`label label-tag zbx-tag ${highlight ? 'highlighted' : ''}`} style={style}>
|
const { tag, highlight } = this.props;
|
||||||
{tag.tag}: {tag.value}
|
const tagColor = getTagColorsFromName(tag.tag);
|
||||||
</span>
|
const style: React.CSSProperties = {
|
||||||
);
|
background: tagColor.color,
|
||||||
|
borderColor: tagColor.borderColor,
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<span className={`label label-tag zbx-tag ${highlight ? 'highlighted' : ''}`}
|
||||||
|
style={style}
|
||||||
|
onClick={this.handleClick}>
|
||||||
|
{tag.tag}: {tag.value}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default EventTag;
|
export default EventTag;
|
||||||
|
|||||||
@@ -144,6 +144,7 @@
|
|||||||
padding-left: 0.6rem;
|
padding-left: 0.6rem;
|
||||||
}
|
}
|
||||||
.label-tag, .zbx-tag {
|
.label-tag, .zbx-tag {
|
||||||
|
cursor: pointer;
|
||||||
margin-right: 0.6rem;
|
margin-right: 0.6rem;
|
||||||
|
|
||||||
&.highlighted {
|
&.highlighted {
|
||||||
|
|||||||
Reference in New Issue
Block a user