All files / client/components/PageHistory Revision.tsx

0% Statements 0/7
100% Branches 0/0
0% Functions 0/4
0% Lines 0/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53                                                                                                         
import React from 'react'
import UserDate from 'components/Common/UserDate'
import Icon from 'components/Common/Icon'
import UserPicture from 'components/User/UserPicture'
import { Revision as RevisionType } from 'client/types/crowi'
 
interface Props {
  revision: RevisionType
  onDiffOpenClicked: Function
}
 
export default class Revision extends React.Component<Props> {
  constructor(props: Props) {
    super(props)
 
    this._onDiffOpenClicked = this._onDiffOpenClicked.bind(this)
  }
 
  componentDidMount() {}
 
  _onDiffOpenClicked() {
    this.props.onDiffOpenClicked(this.props.revision)
  }
 
  render() {
    const revision = this.props.revision
    const author = revision.author
    const pic = <UserPicture user={author} />
 
    return (
      <div className="revision-history-main">
        {pic}
        <div className="revision-history-author">
          <strong>{author.username}</strong>
        </div>
        <div className="revision-history-meta">
          <p>
            <UserDate dateTime={revision.createdAt} />
          </p>
          <p>
            <a href={'?revision=' + revision._id}>
              <Icon name="history" /> View this version
            </a>
            <a className="diff-view" onClick={this._onDiffOpenClicked}>
              <Icon name="unfoldMoreHorizontal" /> View diff
            </a>
          </p>
        </div>
      </div>
    )
  }
}