import React from 'react'; import { Row, Col, Modal, Button, Select, } from 'antd'; import Text from 'antd/lib/typography/Text'; import Title from 'antd/lib/typography/Title'; import moment from 'moment'; import LabelsEditorComponent from '../labels-editor/labels-editor'; import getCore from '../../core'; import patterns from '../../utils/validation-patterns'; const core = getCore(); interface Props { previewImage: string; taskInstance: any; installedGit: boolean; // change to git repos url registeredUsers: any[]; onTaskUpdate: (taskInstance: any) => void; } interface State { name: string; bugTracker: string; assignee: any; } export default class DetailsComponent extends React.PureComponent { constructor(props: Props) { super(props); const { taskInstance } = props; this.state = { name: taskInstance.name, bugTracker: taskInstance.bugTracker, assignee: taskInstance.assignee, }; } private renderTaskName() { const { taskInstance } = this.props; const { name } = this.state; return ( { this.setState({ name: value, }); taskInstance.name = value; this.props.onTaskUpdate(taskInstance); }, }} className='cvat-black-color' >{name} ); } private renderPreview() { return (
Preview
); } private renderParameters() { const { taskInstance } = this.props; const { overlap } = taskInstance; const { segmentSize } = taskInstance; const { imageQuality } = taskInstance; const zOrder = taskInstance.zOrder.toString(); return ( <> Overlap size
{overlap} Segment size
{segmentSize}
Image quality
{imageQuality} Z-order
{zOrder}
); } private renderUsers() { const { taskInstance } = this.props; const owner = taskInstance.owner ? taskInstance.owner.username : null; const assignee = this.state.assignee ? this.state.assignee.username : null; const created = moment(taskInstance.createdDate).format('MMMM Do YYYY'); const assigneeSelect = ( ); return ( { owner ? Created by {owner} on {created} : null } {'Assigned to'} { assigneeSelect } ); } private renderBugTracker() { const { taskInstance } = this.props; const { bugTracker } = this.state; const onChangeValue = (value: string) => { if (value && !patterns.validateURL.pattern.test(value)) { Modal.error({ title: `Could not update the task ${taskInstance.id}`, content: 'Issue tracker is expected to be URL', }); } else { this.setState({ bugTracker: value, }); taskInstance.bugTracker = value; this.props.onTaskUpdate(taskInstance); } } if (bugTracker) { return ( Issue Tracker
{bugTracker}
); } else { return ( Issue Tracker
{'Not specified'}
); } } private renderLabelsEditor() { const { taskInstance } = this.props; return ( label.toJSON() )} onSubmit={(labels: any[]) => { taskInstance.labels = labels.map((labelData) => { return new core.classes.Label(labelData); }); this.props.onTaskUpdate(taskInstance); }} /> ); } public componentDidUpdate(prevProps: Props) { if (prevProps !== this.props) { this.setState({ name: this.props.taskInstance.name, bugTracker: this.props.taskInstance.bugTracker, assignee: this.props.taskInstance.assignee, }); } } public render() { return (
{ this.renderTaskName() } { this.renderPreview() } { this.renderParameters() } { this.renderUsers() } { this.renderBugTracker() } { this.renderLabelsEditor() }
); } }