PageHistory.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import React from 'react';
  2. import Icon from './Common/Icon';
  3. import PageRevisionList from './PageHistory/PageRevisionList';
  4. export default class PageHistory extends React.Component {
  5. constructor(props) {
  6. super(props);
  7. this.crowi = window.crowi; // FIXME
  8. this.state = {
  9. revisions: [],
  10. };
  11. }
  12. componentDidMount() {
  13. const pageId = this.props.pageId;
  14. if (!pageId) {
  15. return ;
  16. }
  17. this.crowi.apiGet('/revisions.ids', {page_id: pageId})
  18. .then(res => {
  19. const rev = res.revisions;
  20. res.revisions.map((revision, i) => {
  21. const user = this.crowi.findUserById(revision.author);
  22. if (user) {
  23. rev[i].author = user;
  24. }
  25. });
  26. this.setState({revisions: rev});
  27. }).catch(err => {
  28. // do nothing
  29. });
  30. }
  31. fetchPageRevisionBody()
  32. {
  33. }
  34. render() {
  35. return (
  36. <div>
  37. <h1><Icon name="history" /> History</h1>
  38. <PageRevisionList revisions={this.state.revisions} />
  39. </div>
  40. );
  41. }
  42. }
  43. PageHistory.propTypes = {
  44. pageId: React.PropTypes.string,
  45. };
  46. /*
  47. <div class="tab-pane revision-history" id="revision-history">
  48. <div class="revision-history-list">
  49. {% for tt in tree %}
  50. <div class="revision-hisory-outer">
  51. <img src="{{ tt.author|picture }}" class="picture picture-rounded">
  52. <div class="revision-history-main">
  53. <div class="revision-history-author">
  54. <strong>{% if tt.author %}{{ tt.author.username }}{% else %}-{% endif %}</strong>
  55. </div>
  56. <div class="revision-history-comment">
  57. </div>
  58. <div class="revision-history-meta">
  59. {{ tt.createdAt|datetz('Y-m-d H:i:s') }}
  60. <br>
  61. <a href="?revision={{ tt._id.toString() }}"><i class="fa fa-history"></i> {{ t('View this version') }}</a>
  62. <a class="diff-view" data-revision-id="{{ tt._id.toString() }}">
  63. <i id="diff-icon-{{ tt._id.toString() }}" class="fa fa-arrow-circle-right"></i> {{ t('View diff') }}
  64. </a>
  65. <div class="" id="diff-display-{{ tt._id.toString()}}" style="display: none"></div>
  66. </div>
  67. </div>
  68. </div>
  69. {% endfor %}
  70. </div>
  71. */