Parcourir la source

80678 show toastr when delete button clicked

Yohei-Shiina il y a 4 ans
Parent
commit
20e34f0371

+ 2 - 1
packages/app/resource/locales/en_US/translation.json

@@ -576,7 +576,8 @@
     "deletion_modal_header": "Delete page",
     "delete_completely": "Delete completely",
     "include_certain_path" : "Include {{pathToInclude}} path ",
-    "delete_all_selected_page" : "Delete All"
+    "delete_all_selected_page" : "Delete All",
+    "currently_not_implemented":"This is not currently implemented"
   },
   "security_setting": {
     "Guest Users Access": "Guest users access",

+ 2 - 1
packages/app/resource/locales/ja_JP/translation.json

@@ -576,7 +576,8 @@
     "deletion_modal_header": "以下のページを削除",
     "delete_completely": "完全に削除する",
     "include_certain_path": "{{pathToInclude}}下を含む ",
-    "delete_all_selected_page" : "一括削除"
+    "delete_all_selected_page" : "一括削除",
+    "currently_not_implemented":"現在未実装の機能です"
   },
   "security_setting": {
     "Guest Users Access": "ゲストユーザーのアクセス",

+ 2 - 1
packages/app/resource/locales/zh_CN/translation.json

@@ -848,7 +848,8 @@
 		"deletion_modal_header": "删除页",
 		"delete_completely": "完全删除",
     "include_certain_path": "包含 {{pathToInclude}} 路径 ",
-    "delete_all_selected_page": "删除所有"
+    "delete_all_selected_page": "删除所有",
+    "currently_not_implemented": "这是当前未实现的功能"
 	},
 	"to_cloud_settings": "進入 GROWI.cloud 的管理界面",
 	"login": {

+ 23 - 14
packages/app/src/components/SearchPage.jsx

@@ -255,21 +255,30 @@ class SearchPage extends React.Component {
   }
 
   async deleteSelectedPages() {
-    const deleteCompletely = this.state.isDeleteCompletely || null;
+    const { t } = this.props;
+    toastr.warning(t('search_result.currently_not_implemented'));
+    // const deleteCompletely = this.state.isDeleteCompletely || null;
     try {
-      const selectedPages = this.getSelectedPages();
-      await Promise.all(selectedPages.map(async(page) => {
-        const removePageParams = { page_id: page._id, revision_id: page.revision, completely: deleteCompletely };
-        try {
-          const res = await this.props.appContainer.apiPost('/pages.remove', removePageParams);
-          if (res.ok) { this.state.selectedPagesIdList.delete(page) }
-        }
-        catch (err) {
-          this.setState({ errorMessageForDeleting: err.message });
-          throw new Error(err.message);
-        }
-      }));
-      window.location.reload();
+
+      // const selectedPages = this.getSelectedPages();
+
+      // ************** replace these code that remove pages with code that does bulk remove **************
+      // Todo: https://redmine.weseek.co.jp/issues/82220
+      // await Promise.all(selectedPages.map(async(page) => {
+      //   const removePageParams = { page_id: page._id, revision_id: page.revision, completely: deleteCompletely };
+      //   try {
+      //     const res = await this.props.appContainer.apiPost('/pages.remove', removePageParams);
+      //     if (res.ok) { this.state.selectedPagesIdList.delete(page) }
+      //   }
+      //   catch (err) {
+      //     this.setState({ errorMessageForDeleting: err.message });
+      //     throw new Error(err.message);
+      //   }
+      // }));
+      // **************************************************************************************************
+
+      this.search({ keyword: this.state.searchedKeyword });
+      this.onCloseDeleteConfirmModal();
     }
     catch (err) {
       toastr.error(err, 'Error occured', { toastrOption });

+ 0 - 3
packages/app/src/components/SearchPage/DeletePageListModal.jsx

@@ -15,9 +15,6 @@ class DeletePageListModal extends React.Component {
    */
   static get OMIT_BODY_THRES() { return 400 }
 
-  componentWillMount() {
-  }
-
   render() {
     const { t } = this.props;
     if (this.props.pages == null || this.props.pages.length === 0) {

+ 5 - 4
packages/app/src/components/SearchPage/SearchResultListItem.tsx

@@ -1,6 +1,7 @@
 import React, { FC } from 'react';
 
 import Clamp from 'react-multiline-clamp';
+import toastr from 'toastr';
 
 import { useTranslation } from 'react-i18next';
 import { UserPicture, PageListMeta, PagePathLabel } from '@growi/ui';
@@ -48,16 +49,16 @@ const PageItemControl: FC<PageItemControlProps> = (props: {page: ISearchedPage})
           TODO: add function to the following buttons like using modal or others
           ref: https://estoc.weseek.co.jp/redmine/issues/79026
         */}
-        <button className="dropdown-item text-danger" type="button" onClick={() => console.log('delete modal show')}>
+        <button className="dropdown-item text-danger" type="button" onClick={() => toastr.warning(t('search_result.currently_not_implemented'))}>
           <i className="icon-fw icon-fire"></i>{t('Delete')}
         </button>
-        <button className="dropdown-item" type="button" onClick={() => console.log('duplicate modal show')}>
+        <button className="dropdown-item" type="button" onClick={() => toastr.warning(t('search_result.currently_not_implemented'))}>
           <i className="icon-fw icon-star"></i>{t('Add to bookmark')}
         </button>
-        <button className="dropdown-item" type="button" onClick={() => console.log('duplicate modal show')}>
+        <button className="dropdown-item" type="button" onClick={() => toastr.warning(t('search_result.currently_not_implemented'))}>
           <i className="icon-fw icon-docs"></i>{t('Duplicate')}
         </button>
-        <button className="dropdown-item" type="button" onClick={() => console.log('rename function will be added')}>
+        <button className="dropdown-item" type="button" onClick={() => toastr.warning(t('search_result.currently_not_implemented'))}>
           <i className="icon-fw  icon-action-redo"></i>{t('Move/Rename')}
         </button>
       </div>