import * as React from 'react'; import {AnnotationSelectList} from './AnnotationSelectList'; import {AnnotationSelectSingleItem} from './AnnotationSelectSingleItem'; import {ISuperdesk, ICrudManager} from 'superdesk-api'; import {IKnowledgeBaseItem} from './interfaces'; interface IProps { annotationText: string; conceptItems: ICrudManager; annotationTypeSelect: JSX.Element; onCancel(): void; onApplyAnnotation(html: string): void; superdesk: ISuperdesk; } interface IState { selected: IKnowledgeBaseItem | null; } export class AnnotationsSelect extends React.Component { constructor(props: IProps) { super(props); this.state = { selected: null, }; } render() { const {gettext} = this.props.superdesk.localization; const backButton = (
); if (this.props.conceptItems._items == null) { return null; // loading } if (this.props.conceptItems._meta.total < 1) { return (

{gettext('No matches found in the library.')}

{backButton}
); } if (this.state.selected != null) { return ( { this.setState({selected: null}); }} annotationTypeSelect={this.props.annotationTypeSelect} onApplyAnnotation={this.props.onApplyAnnotation} superdesk={this.props.superdesk} /> ); } else { return ( { this.setState({selected: item}); }} backButton={backButton} onCancel={this.props.onCancel} superdesk={this.props.superdesk} /> ); } } }