Explorar o código

Refine MyDraftList

Yuki Takei %!s(int64=6) %!d(string=hai) anos
pai
achega
c472d82c5d

+ 1 - 0
resource/locales/en-US/translation.json

@@ -2,6 +2,7 @@
   "Help": "Help",
   "Help": "Help",
   "Edit": "Edit",
   "Edit": "Edit",
   "Delete": "Delete",
   "Delete": "Delete",
+  "Delete All": "Delete All",
   "Duplicate": "Duplicate",
   "Duplicate": "Duplicate",
   "Copy": "Copy",
   "Copy": "Copy",
   "Click to copy": "Click to copy",
   "Click to copy": "Click to copy",

+ 1 - 0
resource/locales/ja/translation.json

@@ -2,6 +2,7 @@
   "Help": "ヘルプ",
   "Help": "ヘルプ",
   "Edit": "編集",
   "Edit": "編集",
   "Delete": "削除",
   "Delete": "削除",
+  "Delete All": "全て削除",
   "Duplicate": "複製",
   "Duplicate": "複製",
   "Copy": "コピー",
   "Copy": "コピー",
   "Click to copy": "クリックでコピー",
   "Click to copy": "クリックでコピー",

+ 27 - 12
src/client/js/components/MyDraftList/MyDraftList.jsx

@@ -1,6 +1,8 @@
 import React from 'react';
 import React from 'react';
 import PropTypes from 'prop-types';
 import PropTypes from 'prop-types';
 
 
+import { withTranslation } from 'react-i18next';
+
 import Pagination from 'react-bootstrap/lib/Pagination';
 import Pagination from 'react-bootstrap/lib/Pagination';
 
 
 import { createSubscribedElement } from '../UnstatedUtils';
 import { createSubscribedElement } from '../UnstatedUtils';
@@ -211,10 +213,14 @@ class MyDraftList extends React.Component {
   }
   }
 
 
   render() {
   render() {
+    const { t } = this.props;
+
     const draftList = this.generateDraftList(this.state.currentDrafts);
     const draftList = this.generateDraftList(this.state.currentDrafts);
 
 
     const paginationItems = [];
     const paginationItems = [];
 
 
+    const totalCount = this.state.drafts.length;
+
     const activePage = this.state.activePage;
     const activePage = this.state.activePage;
     const totalPage = this.state.paginationNumbers.totalPage;
     const totalPage = this.state.paginationNumbers.totalPage;
     const paginationStart = this.state.paginationNumbers.paginationStart;
     const paginationStart = this.state.paginationNumbers.paginationStart;
@@ -229,21 +235,28 @@ class MyDraftList extends React.Component {
     return (
     return (
       <div className="page-list-container-create">
       <div className="page-list-container-create">
 
 
-        { draftList.length === 0
+        { totalCount === 0
           && <span>No drafts yet.</span>
           && <span>No drafts yet.</span>
         }
         }
 
 
-        { draftList.length > 0
-          && (
-            <React.Fragment>
-              <button type="button" className="btn-danger mb-3" onClick={this.clearAllDrafts}>Delete All</button>
-              <div className="tab-pane m-t-30 accordion" id="draft-list">
-                {draftList}
+        { totalCount > 0 && (
+          <React.Fragment>
+            <div className="d-flex justify-content-between">
+              <h4>Total: {totalCount} drafts</h4>
+              <div className="align-self-center">
+                <button type="button" className="btn btn-sm btn-default" onClick={this.clearAllDrafts}>
+                  <i className="icon-fw icon-fire text-danger"></i>
+                  {t('Delete All')}
+                </button>
               </div>
               </div>
-              <Pagination bsSize="small">{paginationItems}</Pagination>
-            </React.Fragment>
-          )
-        }
+            </div>
+
+            <div className="tab-pane m-t-30 accordion" id="draft-list">
+              {draftList}
+            </div>
+            <Pagination bsSize="small">{paginationItems}</Pagination>
+          </React.Fragment>
+        ) }
 
 
       </div>
       </div>
     );
     );
@@ -260,9 +273,11 @@ const MyDraftListWrapper = (props) => {
 
 
 
 
 MyDraftList.propTypes = {
 MyDraftList.propTypes = {
+  t: PropTypes.func.isRequired, // react-i18next
+
   appContainer: PropTypes.instanceOf(AppContainer).isRequired,
   appContainer: PropTypes.instanceOf(AppContainer).isRequired,
   pageContainer: PropTypes.instanceOf(PageContainer).isRequired,
   pageContainer: PropTypes.instanceOf(PageContainer).isRequired,
   editorContainer: PropTypes.instanceOf(EditorContainer).isRequired,
   editorContainer: PropTypes.instanceOf(EditorContainer).isRequired,
 };
 };
 
 
-export default MyDraftListWrapper;
+export default withTranslation()(MyDraftListWrapper);