import React from 'react'; import classNames from 'classnames'; import {ItemUrgency, TypeIcon} from './index'; import {gettext} from 'core/utils'; import {IArticle} from 'superdesk-api'; import {querySelectorParent} from 'core/helpers/dom/querySelectorParent'; import ng from 'core/services/ng'; interface IProps { item?: any; selected?: boolean; canEdit?: boolean; customMonitoringWidget?: boolean; preview: (item: IArticle) => void; select: (item: IArticle) => void; edit: (item: IArticle) => void; } /** * @ngdoc React * @module superdesk.search * @name WidgetItemComponent * @description This component is a row in monitoring widget item list. */ export class WidgetItem extends React.Component { item: any; constructor(props) { super(props); this.item = props.item; this.preview = this.preview.bind(this); this.select = this.select.bind(this); this.edit = this.edit.bind(this); } preview() { this.props.preview(this.item); } select(e) { if (querySelectorParent(e.target, 'button', {self: true})) { return; } if (!this.item.gone) { this.props.select(this.item); } } edit() { if (!this.item.gone) { this.props.edit(this.item); } } render() { const {shortFormat} = ng.get('datetime'); const className = classNames( 'content-item', {'content-item--locked': this.item.lock_user}, {'custom-monitoring': this.props.customMonitoringWidget}, {shifted: this.props.canEdit}, {active: this.props.selected}, {gone: !!this.item.gone}, ); return (
  • {this.item.slugline} {this.item.headline}
    {this.props.canEdit && !this.item.gone ? (
    {this.item.type !== 'composite' ? ( ) : '' } { this.props.customMonitoringWidget ? '' : ( )}
    ) : '' }
  • ); } }