Browse Source

Improved toastr

Taichi Masuyama 4 years ago
parent
commit
e8b1b87fb6

+ 4 - 3
packages/app/resource/locales/en_US/admin/admin.json

@@ -20,12 +20,13 @@
     "submit_bug_report": "<a href='https://github.com/weseek/growi/issues/new?assignees=&labels=bug&template=bug-report.md&title=Bug%3A' target='_blank' rel='noreferrer'>then submit your issue to GitHub.</a>"
     "submit_bug_report": "<a href='https://github.com/weseek/growi/issues/new?assignees=&labels=bug&template=bug-report.md&title=Bug%3A' target='_blank' rel='noreferrer'>then submit your issue to GitHub.</a>"
   },
   },
   "v5_page_migration": {
   "v5_page_migration": {
-    "migration_desc": "Some of the public pages have the old schema.<br/>To take advantage of new features such as page trees and easy renaming, please upgrade the schema of all your pages.<br/><br/>",
+    "migration_desc": "Some of the public pages have the old schema. To take advantage of new features such as page trees and easy renaming, please upgrade the schema of all your pages.",
     "migration_note": "Note: You will lose unique constraints from the page paths.",
     "migration_note": "Note: You will lose unique constraints from the page paths.",
     "upgrade_to_v5": "Upgrade to V5",
     "upgrade_to_v5": "Upgrade to V5",
-    "modal_migration_warning": "This process may take long.<br/>It is highly recommended that administrators tell users not to create, modify, or delete pages during migration.<br/><br/>Note: You will lose unique constraints from the page paths.",
+    "modal_migration_warning": "This process may take long. It is highly recommended that administrators tell users not to create, modify, or delete pages during migration.",
     "start_upgrading": "Start upgrading",
     "start_upgrading": "Start upgrading",
-    "successfully_started": "Succeeded to start migration"
+    "successfully_started": "Succeeded to start migration",
+    "already_upgraded": "You have already completed upgrading"
   },
   },
   "app_setting": {
   "app_setting": {
     "site_name": "Site name",
     "site_name": "Site name",

+ 4 - 3
packages/app/resource/locales/ja_JP/admin/admin.json

@@ -20,12 +20,13 @@
     "submit_bug_report": "<a href='https://github.com/weseek/growi/issues/new?assignees=&labels=bug&template=bug-report.md&title=Bug%3A' target='_blank' rel='noreferrer'>次に GitHub で Issue を投稿してください。</a>"
     "submit_bug_report": "<a href='https://github.com/weseek/growi/issues/new?assignees=&labels=bug&template=bug-report.md&title=Bug%3A' target='_blank' rel='noreferrer'>次に GitHub で Issue を投稿してください。</a>"
   },
   },
   "v5_page_migration": {
   "v5_page_migration": {
-    "migration_desc": "公開されているページに古いスキーマのものが存在します。<br/>ページツリーや簡単なリネームなどの新機能を利用するには、全てのページのスキーマをアップグレードしてください。<br/><br />",
+    "migration_desc": "公開されているページに古いスキーマのものが存在します。ページツリーや簡単なリネームなどの新機能を利用するには、全てのページのスキーマをアップグレードしてください。",
     "migration_note": "注意: ページパスからユニーク制約が失われます。",
     "migration_note": "注意: ページパスからユニーク制約が失われます。",
     "upgrade_to_v5": "V5 にアップグレード",
     "upgrade_to_v5": "V5 にアップグレード",
-    "modal_migration_warning": "管理者はユーザーに、マイグレーション中はページを作成・変更・削除しないように伝えることを強くお勧めします。<br/><br/>注意: アップグレードが終了するとページパスからユニーク制約が失われます。",
+    "modal_migration_warning": "管理者はユーザーに、マイグレーション中はページを作成・変更・削除しないように伝えることを強くお勧めします。",
     "start_upgrading": "アップグレードを開始",
     "start_upgrading": "アップグレードを開始",
-    "successfully_started": "正常にマイグレーションが開始されました"
+    "successfully_started": "正常にマイグレーションが開始されました",
+    "already_upgraded": "アップグレードは既に完了しています"
   },
   },
   "app_setting": {
   "app_setting": {
     "site_name": "サイト名",
     "site_name": "サイト名",

+ 4 - 3
packages/app/resource/locales/zh_CN/admin/admin.json

@@ -20,12 +20,13 @@
     "submit_bug_report": "<a href='https://github.com/weseek/growi/issues/new?assignees=&labels=bug&template=bug-report.md&title=Bug%3A' target='_blank' rel='noreferrer'>然后提交你的问题到GitHub。</a>"
     "submit_bug_report": "<a href='https://github.com/weseek/growi/issues/new?assignees=&labels=bug&template=bug-report.md&title=Bug%3A' target='_blank' rel='noreferrer'>然后提交你的问题到GitHub。</a>"
   },
   },
   "v5_page_migration": {
   "v5_page_migration": {
-    "migration_desc": "Some of the public pages have the old schema.<br/>To take advantage of new features such as page trees and easy renaming, please upgrade the schema of all your pages.<br/><br/>",
+    "migration_desc": "Some of the public pages have the old schema. To take advantage of new features such as page trees and easy renaming, please upgrade the schema of all your pages. ",
     "migration_note": "Note: You will lose unique constraints from the page paths.",
     "migration_note": "Note: You will lose unique constraints from the page paths.",
     "upgrade_to_v5": "Upgrade to V5",
     "upgrade_to_v5": "Upgrade to V5",
-    "modal_migration_warning": "This process may take long.<br/>It is highly recommended that administrators tell users not to create, modify, or delete pages during migration.<br/><br/>Note: You will lose unique constraints from the page paths.",
+    "modal_migration_warning": "This process may take long. It is highly recommended that administrators tell users not to create, modify, or delete pages during migration.",
     "start_upgrading": "Start upgrading",
     "start_upgrading": "Start upgrading",
-    "successfully_started": "Succeeded to start migration"
+    "successfully_started": "Succeeded to start migration",
+    "already_upgraded": "You have already completed upgrading"
   },
   },
   "app_setting": {
   "app_setting": {
     "site_name": "网站名称 ",
     "site_name": "网站名称 ",

+ 2 - 2
packages/app/src/components/Admin/AdminHome/AdminHome.jsx

@@ -46,10 +46,10 @@ class AdminHome extends React.Component {
           !isV5Compatible
           !isV5Compatible
           && (
           && (
             <div className={`alert ${alertStyle}`}>
             <div className={`alert ${alertStyle}`}>
-              {t('v5_page_migration.migration_desc')}
+              {t('admin:v5_page_migration.migration_desc')}
               <a className="btn-link" href="/admin/app" rel="noopener noreferrer">
               <a className="btn-link" href="/admin/app" rel="noopener noreferrer">
                 <i className="fa fa-link ml-1" aria-hidden="true"></i>
                 <i className="fa fa-link ml-1" aria-hidden="true"></i>
-                <strong>{t('v5_page_migration.upgrade_to_v5')}</strong>
+                <strong>{t('admin:v5_page_migration.upgrade_to_v5')}</strong>
               </a>
               </a>
             </div>
             </div>
           )
           )

+ 12 - 5
packages/app/src/components/Admin/App/V5PageMigration.tsx

@@ -6,7 +6,7 @@ import { withUnstatedContainers } from '../../UnstatedUtils';
 import { toastSuccess, toastError } from '../../../client/util/apiNotification';
 import { toastSuccess, toastError } from '../../../client/util/apiNotification';
 
 
 type Props = {
 type Props = {
-  adminAppContainer: typeof AdminAppContainer & { v5PageMigrationHandler: (action: string) => Promise<void> },
+  adminAppContainer: typeof AdminAppContainer & { v5PageMigrationHandler: (action: string) => Promise<{ isV5Compatible: boolean }> },
 }
 }
 
 
 const V5PageMigration: FC<Props> = (props: Props) => {
 const V5PageMigration: FC<Props> = (props: Props) => {
@@ -17,8 +17,13 @@ const V5PageMigration: FC<Props> = (props: Props) => {
   const onConfirm = async() => {
   const onConfirm = async() => {
     setIsV5PageMigrationModalShown(false);
     setIsV5PageMigrationModalShown(false);
     try {
     try {
-      await adminAppContainer.v5PageMigrationHandler('upgrade');
-      toastSuccess(t('v5_page_migration.successfully_started'));
+      // もう完了してたらその旨のトースター
+      const { isV5Compatible } = await adminAppContainer.v5PageMigrationHandler('upgrade');
+      if (isV5Compatible) {
+
+        return toastSuccess(t('admin:v5_page_migration.already_upgraded'));
+      }
+      toastSuccess(t('admin:v5_page_migration.successfully_started'));
     }
     }
     catch (err) {
     catch (err) {
       toastError(err);
       toastError(err);
@@ -33,10 +38,12 @@ const V5PageMigration: FC<Props> = (props: Props) => {
         onCancel={() => setIsV5PageMigrationModalShown(false)}
         onCancel={() => setIsV5PageMigrationModalShown(false)}
       />
       />
       <p className="card well">
       <p className="card well">
-        {t('v5_page_migration.migration_desc')}
+        {t('admin:v5_page_migration.migration_desc')}
+        <br />
+        <br />
         <span className="text-danger">
         <span className="text-danger">
           <i className="icon-exclamation icon-fw"></i>
           <i className="icon-exclamation icon-fw"></i>
-          {t('v5_page_migration.migration_note')}
+          {t('admin:v5_page_migration.migration_note')}
         </span>
         </span>
       </p>
       </p>
       <div className="row my-3">
       <div className="row my-3">

+ 8 - 2
packages/app/src/components/Admin/App/V5PageMigrationModal.tsx

@@ -32,7 +32,13 @@ export const V5PageMigrationModal: FC<V5PageMigrationModalProps> = (props: V5Pag
         Warning
         Warning
       </ModalHeader>
       </ModalHeader>
       <ModalBody>
       <ModalBody>
-        {t('v5_page_migration.modal_migration_warning')}
+        {t('admin:v5_page_migration.modal_migration_warning')}
+        <br />
+        <br />
+        <span className="text-danger">
+          <i className="icon-exclamation icon-fw"></i>
+          {t('admin:v5_page_migration.migration_note')}
+        </span>
       </ModalBody>
       </ModalBody>
       <ModalFooter>
       <ModalFooter>
         <button
         <button
@@ -47,7 +53,7 @@ export const V5PageMigrationModal: FC<V5PageMigrationModalProps> = (props: V5Pag
           className="btn btn-outline-primary ml-3"
           className="btn btn-outline-primary ml-3"
           onClick={onConfirm}
           onClick={onConfirm}
         >
         >
-          {t('v5_page_migration.start_upgrading')}
+          {t('admin:v5_page_migration.start_upgrading')}
         </button>
         </button>
       </ModalFooter>
       </ModalFooter>
     </Modal>
     </Modal>

+ 1 - 0
packages/app/src/server/routes/apiv3/pages.js

@@ -690,6 +690,7 @@ module.exports = (crowi) => {
 
 
     switch (action) {
     switch (action) {
       case 'upgrade':
       case 'upgrade':
+
         try {
         try {
           const Page = crowi.model('Page');
           const Page = crowi.model('Page');
           // not await
           // not await