itizawa 5 лет назад
Родитель
Сommit
294c38c6bb

+ 13 - 9
src/client/js/components/Page/TrashPageAlert.jsx

@@ -1,30 +1,34 @@
 import React from 'react';
 import PropTypes from 'prop-types';
+
 import { withTranslation } from 'react-i18next';
+import { format } from 'date-fns';
 
 import { isTopPage, isUserPage } from '@commons/util/path-utils';
 import { createSubscribedElement } from '../UnstatedUtils';
 import AppContainer from '../../services/AppContainer';
 import PageContainer from '../../services/PageContainer';
+import UserPicture from '../User/UserPicture';
 
 
 const TrashPageAlert = (props) => {
   const { t, appContainer, pageContainer } = props;
-  const { path } = pageContainer.state;
+  const {
+    path, isDeleted, revisionAuthor, updatedAt,
+  } = pageContainer.state;
+  console.log(pageContainer.state);
   const { currentUser } = appContainer;
   const isTopPagePath = isTopPage(path);
   const isUserPagePath = isUserPage(path);
+  // const now = format(updatedAt, 'Y-m-d H:i:s');
 
   return (
     <div className="alert alert-warning py-3 px-4 d-flex align-items-center justify-content-between">
-      hoge
-      {/* <div>
-      This page is in the trash <i class="icon-trash" aria-hidden="true"></i>.
-      {% if page.isDeleted() %}
-      <br>Deleted by <img src="{{ page.lastUpdateUser|picture }}" class="picture picture-sm rounded-circle"> {{ page.lastUpdateUser.name }} at {{ page.updatedAt|datetz('Y-m-d H:i:s') }}
-      {% endif %}
-    </div>
-    {% if user and user.admin and req.path == '/trash' and pages.length > 0 %}
+      <div>
+      This page is in the trash <i className="icon-trash" aria-hidden="true"></i>.
+        {isDeleted && <span><br /><UserPicture user={revisionAuthor} /> Deleted by {revisionAuthor.name} at {updatedAt}</span>}
+      </div>
+      {/* {% if user and user.admin and req.path == '/trash' and pages.length > 0 %}
     <div>
       <button href="#" class="btn btn-danger rounded-pill btn-sm" data-target="#emptyTrash" data-toggle="modal"><i class="icon-trash" aria-hidden="true"></i>{{ t('modal_empty.empty_the_trash') }}</button>
     </div>

+ 1 - 1
src/client/js/services/PageContainer.js

@@ -48,7 +48,7 @@ export default class PageContainer extends Container {
       createdAt: mainContent.getAttribute('data-page-created-at'),
       creator: JSON.parse(mainContent.getAttribute('data-page-creator')),
       updatedAt: mainContent.getAttribute('data-page-updated-at'),
-
+      isDeleted:  JSON.parse(mainContent.getAttribute('data-page-is-deleted')),
       tags: [],
       templateTagData: mainContent.getAttribute('data-template-tags') || null,
 

+ 1 - 0
src/server/views/widget/page_content.html

@@ -11,6 +11,7 @@
   data-page-has-draft-on-hackmd="{% if hasDraftOnHackmd %}{{ hasDraftOnHackmd.toString() }}{% endif %}"
   data-page-is-liked="{% if page.isLiked(user) %}true{% else %}false{% endif %}"
   data-page-is-seen="{% if page and page.isSeenUser(user) %}1{% else %}0{% endif %}"
+  data-page-is-deleted="{% if page.isDeleted() %}true{% else %}false{% endif %}"
   data-slack-channels="{{ slack|default('') }}"
   data-page-created-at="{% if page %}{{ page.createdAt|datetz('Y/m/d H:i:s') }}{% endif %}"
   data-page-creator="{% if page %}{{ page.creator|json }}{% endif %}"