import React from 'react'; import ng from 'core/services/ng'; import {gettext, gettextPlural} from 'core/utils'; import {IArticle} from 'superdesk-api'; import {TranslationsList} from './translations-list'; import {ItemListPopup} from '../item-list-popup'; interface IProps { item: IArticle; } interface IState { popup?: { ids: Array; label: string; target: HTMLElement; }; } export class Translations extends React.PureComponent { constructor(props) { super(props); this.state = {popup: null}; this.closePopup = this.closePopup.bind(this); } render() { return ( {this.props.item.translated_from != null && ( )} {this.props.item.translations != null && this.props.item.translations.length > 0 && ( )} {this.state.popup != null && ( { ng.get('$rootScope').$broadcast('broadcast:preview', {item}); }} /> )} ); } renderOriginalArticle(elem: EventTarget) { this.setState({ popup: { label: gettext('Original Article'), ids: [this.props.item.translated_from], target: elem as HTMLElement, }, }); } renderTranslations(elem: EventTarget) { this.setState({ popup: { label: gettext('Translations'), ids: this.props.item.translations, target: elem as HTMLElement, }, }); } closePopup() { this.setState({popup: null}); } }