problems: handle tag click in table view

This commit is contained in:
Alexander Zobnin
2018-12-27 19:19:17 +03:00
parent be3f91b862
commit da8bc416c2

View File

@@ -71,7 +71,9 @@ export class ProblemList extends PureComponent<ProblemListProps, ProblemListStat
},
{ Header: 'Status', accessor: 'value', show: options.statusField, width: 100, Cell: statusCell },
{ Header: 'Problem', accessor: 'description', minWidth: 200, Cell: ProblemCell},
{ Header: 'Tags', accessor: 'tags', show: options.showTags, className: 'problem-tags', Cell: TagCell },
{ Header: 'Tags', accessor: 'tags', show: options.showTags, className: 'problem-tags',
Cell: props => <TagCell {...props} onTagClick={this.handleTagClick} />
},
{ Header: 'Time', className: 'last-change', width: timeColWidth,
accessor: 'lastchangeUnix',
id: 'lastchange',
@@ -192,11 +194,23 @@ function ProblemCell(props: RTCell<Trigger>) {
);
}
function TagCell(props: RTCell<Trigger>) {
const tags = props.value || [];
return [
tags.map(tag => <EventTag key={tag.tag + tag.value} tag={tag} />)
];
interface TagCellProps extends RTCell<Trigger> {
onTagClick: (tag: ZBXTag, datasource: string) => void;
}
class TagCell extends PureComponent<TagCellProps> {
handleTagClick = (tag: ZBXTag) => {
if (this.props.onTagClick) {
this.props.onTagClick(tag, this.props.original.datasource);
}
}
render() {
const tags = this.props.value || [];
return [
tags.map(tag => <EventTag key={tag.tag + tag.value} tag={tag} onClick={this.handleTagClick} /> )
];
}
}
function CustomExpander(props: RTCell<any>) {