فهرست منبع

Merge pull request #3949 from weseek/feat/GW-6496-toast-error

Feat/gw 6496 toast error
Shun Miyazawa 4 سال پیش
والد
کامیت
36902377e3
2فایلهای تغییر یافته به همراه22 افزوده شده و 6 حذف شده
  1. 19 3
      src/client/js/components/Admin/Users/UserInviteModal.jsx
  2. 3 3
      src/server/routes/apiv3/users.js

+ 19 - 3
src/client/js/components/Admin/Users/UserInviteModal.jsx

@@ -9,6 +9,7 @@ import {
   Modal, ModalHeader, ModalBody, ModalFooter,
   Modal, ModalHeader, ModalBody, ModalFooter,
 } from 'reactstrap';
 } from 'reactstrap';
 
 
+import * as toastr from 'toastr';
 import { toastSuccess, toastError, toastWarning } from '../../../util/apiNotification';
 import { toastSuccess, toastError, toastWarning } from '../../../util/apiNotification';
 
 
 import { withUnstatedContainers } from '../../UnstatedUtils';
 import { withUnstatedContainers } from '../../UnstatedUtils';
@@ -55,9 +56,15 @@ class UserInviteModal extends React.Component {
         msg = `Existing email<br>${msg}`;
         msg = `Existing email<br>${msg}`;
         toastWarning(msg);
         toastWarning(msg);
         break;
         break;
-      // TODO: GW-6496
       case 'error':
       case 'error':
-        toastError(msg);
+        toastr.error(msg, 'Error', {
+          closeButton: true,
+          progressBar: true,
+          newestOnTop: false,
+          showDuration: '100',
+          hideDuration: '100',
+          timeOut: '0',
+        });
         break;
         break;
     }
     }
   }
   }
@@ -224,7 +231,16 @@ class UserInviteModal extends React.Component {
       if (emailList.existingEmailList.length > 0) {
       if (emailList.existingEmailList.length > 0) {
         this.showToasterByEmailList(emailList.existingEmailList, 'warning');
         this.showToasterByEmailList(emailList.existingEmailList, 'warning');
       }
       }
-      // TODO: GW-6496
+      if (emailList.failedEmailList.length > 0) {
+        const failedEmailList = emailList.failedEmailList.map((failed, index) => {
+          let response = `email: ${failed.email}<br>・reason: ${failed.reason}`;
+          if (index !== emailList.failedEmailList.length - 1) {
+            response += '<br>';
+          }
+          return response;
+        });
+        this.showToasterByEmailList(failedEmailList, 'error');
+      }
     }
     }
     catch (err) {
     catch (err) {
       toastError(err);
       toastError(err);

+ 3 - 3
src/server/routes/apiv3/users.js

@@ -397,19 +397,19 @@ module.exports = (crowi) => {
 
 
     // Delete duplicate email addresses
     // Delete duplicate email addresses
     const emailList = Array.from(new Set(req.body.shapedEmailList));
     const emailList = Array.from(new Set(req.body.shapedEmailList));
-    const failedEmailList = [];
+    let failedEmailList = [];
 
 
     // Create users
     // Create users
     const createUser = await User.createUsersByEmailList(emailList);
     const createUser = await User.createUsersByEmailList(emailList);
     if (createUser.failedToCreateUserEmailList.length > 0) {
     if (createUser.failedToCreateUserEmailList.length > 0) {
-      failedEmailList.push(createUser.failedToCreateUserEmailList);
+      failedEmailList = failedEmailList.concat(createUser.failedToCreateUserEmailList);
     }
     }
 
 
     // Send email
     // Send email
     if (req.body.sendEmail) {
     if (req.body.sendEmail) {
       const sendEmail = await sendEmailByUserList(createUser.createdUserList);
       const sendEmail = await sendEmailByUserList(createUser.createdUserList);
       if (sendEmail.failedToSendEmailList.length > 0) {
       if (sendEmail.failedToSendEmailList.length > 0) {
-        failedEmailList.push(sendEmail.failedToSendEmailList);
+        failedEmailList = failedEmailList.concat(sendEmail.failedToSendEmailList);
       }
       }
     }
     }