import * as React from 'react'; import I18n from 'i18n-js'; import Button from '../common/Button'; import Switch from '../common/Switch'; import ActionLink from '../common/ActionLink'; import { CancelIcon, DeleteIcon, MarkdownIcon } from '../common/Icons'; import Dropzone from '../common/Dropzone'; import ITenantSetting from '../../interfaces/ITenantSetting'; interface Props { id: number; initialBody: string; initialIsPostUpdate: boolean; attachmentUrls?: string[]; isPowerUser: boolean; tenantSetting: ITenantSetting; handleUpdateComment(body: string, isPostUpdate: boolean, attachmentsToDelete: number[], attachments: File[]): void; toggleEditMode(): void; } interface State { body: string; isPostUpdate: boolean; attachmentsToDelete: number[]; attachments: File[]; } class CommentEditForm extends React.Component { constructor(props) { super(props); this.state = { body: '', isPostUpdate: false, attachmentsToDelete: [], attachments: [], }; this.handleCommentBodyChange = this.handleCommentBodyChange.bind(this); this.handleCommentIsPostUpdateChange = this.handleCommentIsPostUpdateChange.bind(this); this.handleAttachmentsToDeleteChange = this.handleAttachmentsToDeleteChange.bind(this); this.handleAttachmentsChange = this.handleAttachmentsChange.bind(this); } componentDidMount() { this.setState({ body: this.props.initialBody, isPostUpdate: this.props.initialIsPostUpdate, }); } handleCommentBodyChange(newCommentBody: string) { this.setState({ body: newCommentBody }); } handleCommentIsPostUpdateChange(newIsPostUpdate: boolean) { this.setState({ isPostUpdate: newIsPostUpdate }); } handleAttachmentsToDeleteChange(newAttachmentsToDelete: number[]) { this.setState({ attachmentsToDelete: newAttachmentsToDelete }); } handleAttachmentsChange(newAttachments: File[]) { this.setState({ attachments: newAttachments }); } render() { const { id, attachmentUrls, isPowerUser, tenantSetting, handleUpdateComment, toggleEditMode } = this.props; const { body, isPostUpdate, attachmentsToDelete, attachments } = this.state; return (