             {PostSubmit && `<Col xs={12} sm={12} md={12} lg={12}><PostSubmit {...allProps}/></Col>`}
         </Grid>
 
+SubmitActions = (props) ->
+    admin = props.me?.admin
+    <div>
+        {props.currentSubmit && (not props.currentSubmit.similar) && (not props.result.findMistake) && <div>
+            <div>
+                {
+                if props.currentSubmit.outcome in ["OK", "AC"]
+                    starsClass = styles.stars
+                else
+                    starsClass = ""
+                <div className={starsClass}>
+                    <FontAwesome name="times" key={0} onClick={props.setQuality(0)}/>
+                    {(<FontAwesome
+                        name={"star" + (if x <= props.currentSubmit.quality then "" else "-o")}
+                        key={x}
+                        onClick={props.setQuality(x)}/> \
+                        for x in [1..5])}
+                </div>
+                }
+            </div>
+            {
+            if props.bestSubmits?.length
+                <span>
+                    <a href="#" onClick={props.toggleBestSubmits}>Хорошие решения</a>
+                    {" = " + props.bestSubmits.length}
+                    {" " + props.bestSubmits.map((submit) -> submit.language || "unknown").join(", ")}
+                </span>
+            }
+            <FieldGroup
+                    id="commentText"
+                    label="Комментарий"
+                    componentClass="textarea"
+                    setField={props.setField}
+                    style={{ height: 200 }}
+                    state={props}/>
+            <FormGroup>
+                {
+                bsSize = null
+                bsCommentSize = null
+                if not (props.currentSubmit.outcome in ["OK", "AC", "IG"])
+                    bsSize = "xsmall"
+                if not props.result?.activated
+                    bsSize = "xsmall"
+                    bsCommentSize = "xsmall"
+                <ButtonGroup>
+                    <Button onClick={props.accept} bsStyle="success" bsSize={bsSize}>Зачесть</Button>
+                    <Button onClick={props.ignore} bsStyle="info" bsSize={bsSize}>Проигнорировать</Button>
+                    <Button onClick={props.comment}  bsSize={bsCommentSize}>Прокомментировать</Button>
+                    <Button onClick={props.disqualify} bsStyle="danger" bsSize="xsmall">Дисквалифицировать</Button>
+                </ButtonGroup>
+                }
+            </FormGroup>
+            <Button onClick={props.downloadSubmits} bsSize="xsmall">re-download submits</Button>
+            {
+            admin and props.currentSubmit and not props.currentSubmit.similar and <Col xs={12} sm={12} md={12} lg={12}>
+                <ConnectedProblemCommentsLists problemId={props.result.fullTable._id} handleCommentClicked={props.setComment}/>
+            </Col>
+            }
+            {
+            admin && props.showBestSubmits && <BestSubmits submits={props.bestSubmits} close={props.toggleBestSubmits} stars/>
+            }
+        </div>}
+        {props.result.findMistake && <Link to="/findMistake/#{props.result.findMistake}">Исходный поиск ошибки</Link>}
+    </div>
+
 export class ReviewResult extends React.Component
+    constructor: (props) ->
+        super(props)
+        @state =
+            commentText: ""
+            showBestSubmits: false
+        @currentSubmit = null
+        @accept = @accept.bind this
+        @ignore = @ignore.bind this
+        @disqualify = @disqualify.bind this
+        @comment = @comment.bind this
+        @setField = @setField.bind this
+        @setQuality = @setQuality.bind this
+        @toggleBestSubmits = @toggleBestSubmits.bind this
+        @downloadSubmits = @downloadSubmits.bind this
+        @setComment = @setComment.bind this
+        @copyTest = @copyTest.bind this
+        @setCurrentSubmit = @setCurrentSubmit.bind this
+
+    componentDidUpdate: (prevProps, prevState) ->
+        if !submitListEquals(prevProps.submits, @props.submits)
+            @setState
+                showBestSubmits: false
+                commentText: ""
+
+    setCurrentSubmit: (submit) ->
+        @currentSubmit = submit
+
+    copyTest: (result) ->
+        (e) =>
+            e.stopPropagation()
+            newComment = @state.commentText
+            if newComment.length
+                newComment += "\n\n"
+            newComment += "Входные данные:\n#{result.input.trim()}\n\nВывод программы:\n#{result.output.trim()}\n\nПравильный ответ:\n#{result.corr.trim()}"
+            @setState
+                commentText: newComment 
+            return false
+
+    setComment: (comment) ->
+        () =>
+            newText = entities.decode(comment.text)
+            newText = newText.trim()
+            for tail in TAIL_TEXTS
+                if newText.endsWith(tail)
+                    newText = newText.substring(0, newText.length - tail.length);
+            newText = newText.trim()
+            if @state.commentText.length
+                newText = @state.commentText + "\n\n" + newText
+            @setState({commentText: newText})
+
+    setField: (field, value) ->
+        newState = {@state...}
+        newState[field] = value
+        @setState(newState)
+
     paidStyle: () ->
         user = @props.user
         if (!user?.paidTill)

            @setState
                currentSubmit: undefined
                currentDiff: newDiff

    render:  () ->
        SubmitComponent = @props.SubmitComponent


ConnectedProblemCommentsLists = ConnectedComponent(ProblemCommentsLists, listOptions)

# TODO: get rid of this wrapper?
class SubmitForReviewResults extends React.Component
    render: () ->
        admin = @props.me?.admin
        <div>
            <Submit submit={@props.currentSubmit} showHeader me={@props.me} copyTest={@props.copyTest}/>
        </div>

export class SubmitListWithDiff extends React.Component
