Explorar o código

persist slack notification setting

mizozobu %!s(int64=6) %!d(string=hai) anos
pai
achega
ed65592cd3

+ 7 - 7
src/server/routes/admin.js

@@ -335,10 +335,10 @@ module.exports = function(crowi, app) {
         setting = new GlobalNotificationMailSetting(crowi);
         setting.toEmail = form.toEmail;
         break;
-      // case 'slack':
-      //   setting = new GlobalNotificationSlackSetting(crowi);
-      //   setting.slackChannels = form.slackChannels;
-      //   break;
+      case 'slack':
+        setting = new GlobalNotificationSlackSetting(crowi);
+        setting.slackChannels = form.slackChannels;
+        break;
       default:
         logger.error('GlobalNotificationSetting Type Error: undefined type');
         req.flash('errorMessage', 'Error occurred in creating a new global notification setting: undefined notification type');
@@ -360,9 +360,9 @@ module.exports = function(crowi, app) {
       case 'mail':
         setting.toEmail = form.toEmail;
         break;
-      // case 'slack':
-      //   setting.slackChannels = form.slackChannels;
-      //   break;
+      case 'slack':
+        setting.slackChannels = form.slackChannels;
+        break;
       default:
         logger.error('GlobalNotificationSetting Type Error: undefined type');
         req.flash('errorMessage', 'Error occurred in updating the global notification setting: undefined notification type');

+ 7 - 7
src/server/service/global-notification.js

@@ -21,7 +21,7 @@ class GlobalNotificationService {
     // send slack notification here
   }
 
-  sendNotification(notifications, option) {
+  fire(notifications, option) {
     notifications.forEach((notification) => {
       if (notification.__t === 'mail') {
         this.notifyByMail(notification, option.mail);
@@ -55,7 +55,7 @@ class GlobalNotificationService {
 
     logger.debug('notifyPageCreate', option);
 
-    this.sendNotification(notifications, option);
+    this.fire(notifications, option);
   }
 
   /**
@@ -81,7 +81,7 @@ class GlobalNotificationService {
 
     logger.debug('notifyPageEdit', option);
 
-    this.sendNotification(notifications, option);
+    this.fire(notifications, option);
   }
 
   /**
@@ -105,7 +105,7 @@ class GlobalNotificationService {
       slack: {},
     };
 
-    this.sendNotification(notifications, option);
+    this.fire(notifications, option);
   }
 
   /**
@@ -130,7 +130,7 @@ class GlobalNotificationService {
       slack: {},
     };
 
-    this.sendNotification(notifications, option);
+    this.fire(notifications, option);
   }
 
   /**
@@ -154,7 +154,7 @@ class GlobalNotificationService {
       slack: {},
     };
 
-    this.sendNotification(notifications, option);
+    this.fire(notifications, option);
   }
 
   /**
@@ -181,7 +181,7 @@ class GlobalNotificationService {
       slack: {},
     };
 
-    this.sendNotification(notifications, option);
+    this.fire(notifications, option);
   }
 
 }

+ 4 - 5
src/server/views/admin/global-notification-detail.html

@@ -57,21 +57,20 @@
               <div class="form-group form-inline">
                 <h3>{{ t('notification_setting.notify_to') }}</h3>
                 <div class="radio radio-primary">
-                  <input type="radio" id="mail" name="notificationGlobal[notifyToType]" value="mail" {% if setting.__t == 'mail' %}checked{% endif %} checked>
+                  <input type="radio" id="mail" name="notificationGlobal[notifyToType]" value="mail" {% if setting.__t == 'mail' %}checked{% endif %}>
                   <label for="mail">
                     <p class="font-weight-bold">Email</p>
                   </label>
                 </div>
                 <div class="radio radio-primary">
-                  <input type="radio" id="slack" name="notificationGlobal[notifyToType]" value="slack" {% if setting.__t == 'slack' %}checked{% endif %} disabled>
+                  <input type="radio" id="slack" name="notificationGlobal[notifyToType]" value="slack" {% if setting.__t == 'slack' %}checked{% endif %}>
                   <label for="slack">
                     <p class="font-weight-bold">Slack</p>
                   </label>
                 </div>
               </div>
 
-              <!-- <div class="form-group notify-to-option {% if setting.__t != 'mail' %}d-none{% endif %}" id="mail-input"> -->
-              <div class="form-group notify-to-option" id="mail-input">
+              <div class="form-group notify-to-option {% if setting.__t != 'mail' %}d-none{% endif %}" id="mail-input">
                 <input class="form-control" type="text" name="notificationGlobal[toEmail]" value="{{ setting.toEmail || '' }}">
                 <p class="help">
                   <b>Hint: </b>
@@ -80,7 +79,7 @@
               </div>
 
               <div class="form-group notify-to-option {% if setting.__t != 'slack' %}d-none{% endif %}" id="slack-input">
-                <input class="form-control" type="text" name="notificationGlobal[slackChannels]" value="{{ setting.slackChannels || '' }}" disabled>
+                <input class="form-control" type="text" name="notificationGlobal[slackChannels]" value="{{ setting.slackChannels || '' }}">
               </div>
             </fieldset>