فهرست منبع

add empty button

itizawa 5 سال پیش
والد
کامیت
0b26ccb573

+ 10 - 6
src/client/js/components/Page/TrashPageAlert.jsx

@@ -14,10 +14,11 @@ import UserPicture from '../User/UserPicture';
 const TrashPageAlert = (props) => {
   const { t, appContainer, pageContainer } = props;
   const {
-    path, isDeleted, revisionAuthor, updatedAt,
+    path, isDeleted, revisionAuthor, updatedAt, childrenPages,
   } = 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');
@@ -28,11 +29,14 @@ const TrashPageAlert = (props) => {
       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>
-    {% endif %}
+      {currentUser.admin && path === '/trash' && childrenPages.length > 0 && (
+      <div>
+        <button href="#" type="button" className="btn btn-danger rounded-pill btn-sm" data-target="#emptyTrash" data-toggle="modal">
+          <i className="icon-trash" aria-hidden="true"></i>{ t('modal_empty.empty_the_trash') }
+        </button>
+      </div>
+      )}
+      {/*
     {% if page.isDeleted() and user %}
     <div>
       <button href="#" class="btn btn-outline-secondary rounded-pill btn-sm mr-2" data-target="#putBackPage" data-toggle="modal"><i class="icon-action-undo" aria-hidden="true"></i> {{ t('Put Back') }}</button>

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

@@ -32,7 +32,6 @@ export default class PageContainer extends Container {
 
     const revisionId = mainContent.getAttribute('data-page-revision-id');
     const path = decodeURI(mainContent.getAttribute('data-path'));
-
     this.state = {
       // local page data
       markdown: null, // will be initialized after initStateMarkdown()
@@ -50,6 +49,7 @@ export default class PageContainer extends Container {
       updatedAt: mainContent.getAttribute('data-page-updated-at'),
       isDeleted:  JSON.parse(mainContent.getAttribute('data-page-is-deleted')),
       tags: [],
+      childrenPages: JSON.parse(mainContent.getAttribute('data-children-pages')),
       templateTagData: mainContent.getAttribute('data-template-tags') || null,
 
       // latest(on remote) information

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

@@ -16,12 +16,15 @@
   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 %}"
   data-page-updated-at="{% if page %}{{ page.updatedAt|datetz('Y/m/d H:i:s') }}{% endif %}"
+  data-children-pages="{{ pages|json }}"
   >
 {% else %}
 <div id="content-main" class="content-main"
   data-path="{{ encodeURI(path) }}"
   data-current-user="{% if user %}{{ user._id.toString() }}{% endif %}"
   data-slack-channels="{{ slack|default('') }}"
+  data-page-is-deleted="{% if page.isDeleted() %}true{% else %}false{% endif %}"
+  data-children-pages="{{ pages|json }}"
   >
 {% endif %}