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, MarkdownIcon } from '../common/Icons'; interface Props { id: number; initialBody: string; initialIsPostUpdate: boolean; isPowerUser: boolean; handleUpdateComment(body: string, isPostUpdate: boolean): void; toggleEditMode(): void; } interface State { body: string; isPostUpdate: boolean; } class CommentEditForm extends React.Component { constructor(props) { super(props); this.state = { body: '', isPostUpdate: false, }; this.handleCommentBodyChange = this.handleCommentBodyChange.bind(this); this.handleCommentIsPostUpdateChange = this.handleCommentIsPostUpdateChange.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 }); } render() { const { id, isPowerUser, handleUpdateComment, toggleEditMode } = this.props; const { body, isPostUpdate } = this.state; return (