itizawa 6 лет назад
Родитель
Сommit
243b808a8a

+ 0 - 2
src/server/form/index.js

@@ -20,8 +20,6 @@ module.exports = {
     securityPassportGitHub: require('./admin/securityPassportGitHub'),
     securityPassportTwitter: require('./admin/securityPassportTwitter'),
     securityPassportOidc: require('./admin/securityPassportOidc'),
-    slackIwhSetting: require('./admin/slackIwhSetting'),
-    slackSetting: require('./admin/slackSetting'),
     userGroupCreate: require('./admin/userGroupCreate'),
     notificationGlobal: require('./admin/notificationGlobal'),
   },

+ 1 - 61
src/server/routes/admin.js

@@ -162,49 +162,8 @@ module.exports = function(crowi, app) {
   // app.get('/admin/notification'               , admin.notification.index);
   actions.notification = {};
   actions.notification.index = async(req, res) => {
-    const UpdatePost = crowi.model('UpdatePost');
-    let slackSetting = configManager.getConfigByPrefix('notification', 'slack:');
-    const hasSlackIwhUrl = !!configManager.getConfig('notification', 'slack:incomingWebhookUrl');
-    const hasSlackToken = !!configManager.getConfig('notification', 'slack:token');
-
-    if (!hasSlackIwhUrl) {
-      slackSetting['slack:incomingWebhookUrl'] = '';
-    }
-
-    if (req.session.slackSetting) {
-      slackSetting = req.session.slackSetting;
-      req.session.slackSetting = null;
-    }
-
-    const globalNotifications = await GlobalNotificationSetting.findAll();
-    const userNotifications = await UpdatePost.findAll();
 
-    return res.render('admin/notification', {
-      userNotifications,
-      slackSetting,
-      hasSlackIwhUrl,
-      hasSlackToken,
-      globalNotifications,
-    });
-  };
-
-  // app.post('/admin/notification/slackSetting' , admin.notification.slackauth);
-  actions.notification.slackSetting = async function(req, res) {
-    const slackSetting = req.form.slackSetting;
-
-    if (req.form.isValid) {
-      await configManager.updateConfigsInTheSameNamespace('notification', slackSetting);
-      req.flash('successMessage', ['Successfully Updated!']);
-
-      // Re-setup
-      crowi.setupSlack().then(() => {
-      });
-    }
-    else {
-      req.flash('errorMessage', req.form.errors);
-    }
-
-    return res.redirect('/admin/notification');
+    return res.render('admin/notification');
   };
 
   // app.get('/admin/notification/slackAuth'     , admin.notification.slackauth);
@@ -237,25 +196,6 @@ module.exports = function(crowi, app) {
       });
   };
 
-  // app.post('/admin/notification/slackIwhSetting' , admin.notification.slackIwhSetting);
-  actions.notification.slackIwhSetting = async function(req, res) {
-    const slackIwhSetting = req.form.slackIwhSetting;
-
-    if (req.form.isValid) {
-      await configManager.updateConfigsInTheSameNamespace('notification', slackIwhSetting);
-      req.flash('successMessage', ['Successfully Updated!']);
-
-      // Re-setup
-      crowi.setupSlack().then(() => {
-        return res.redirect('/admin/notification#slack-incoming-webhooks');
-      });
-    }
-    else {
-      req.flash('errorMessage', req.form.errors);
-      return res.redirect('/admin/notification#slack-incoming-webhooks');
-    }
-  };
-
   // app.post('/admin/notification/slackSetting/disconnect' , admin.notification.disconnectFromSlack);
   actions.notification.disconnectFromSlack = async function(req, res) {
     await configManager.updateConfigsInTheSameNamespace('notification', { 'slack:token': '' });

+ 0 - 2
src/server/routes/index.js

@@ -97,8 +97,6 @@ module.exports = function(crowi, app) {
 
   // notification admin
   app.get('/admin/notification'              , loginRequiredStrictly , adminRequired , admin.notification.index);
-  app.post('/admin/notification/slackIwhSetting', loginRequiredStrictly , adminRequired , csrf, form.admin.slackIwhSetting, admin.notification.slackIwhSetting);
-  app.post('/admin/notification/slackSetting', loginRequiredStrictly , adminRequired , csrf, form.admin.slackSetting, admin.notification.slackSetting);
   app.get('/admin/notification/slackAuth'    , loginRequiredStrictly , adminRequired , admin.notification.slackAuth);
   app.get('/admin/notification/slackSetting/disconnect', loginRequiredStrictly , adminRequired , admin.notification.disconnectFromSlack);
   app.post('/_api/admin/notification.remove' , loginRequiredStrictly , adminRequired , csrf, admin.api.notificationRemove);

+ 0 - 178
src/server/views/admin/notification.html

@@ -18,28 +18,7 @@
     </div>
     <div class="col-md-9" id="admin-notification-setting">
 
-      {% set smessage = req.flash('successMessage') %}
-      {% if smessage.length %}
-      <div class="alert alert-success">
-        {% for e in smessage %}
-          {{ e }}<br>
-        {% endfor %}
-      </div>
-      {% endif %}
-
-      {% set emessage = req.flash('errorMessage') %}
-      {% if emessage.length %}
-      <div class="alert alert-danger">
-        {% for e in emessage %}
-        {{ e }}<br>
-        {% endfor %}
-      </div>
-      {% endif %}
-
       <ul class="nav nav-tabs" role="tablist">
-        <li role="tab" class="active">
-          <a href="#slack-configuration" data-toggle="tab" role="tab"><i class="icon-settings"></i> Slack Configuration</a>
-        </li>
         <li role="tab">
           <a href="#user-trigger-notification" data-toggle="tab" role="tab"><i class="icon-settings"></i> User Trigger Notification</a>
         </li>
@@ -48,163 +27,6 @@
         </li>
       </ul>
 
-      <div class="tab-content m-t-15">
-        <div id="slack-configuration" class="tab-pane active" role="tabpanel">
-
-          <select class="selectpicker" id="selectSlackOption" data-width="auto">
-            <option value="1">Slack Incoming Webhooks</option>
-            <option value="2">Slack App</option>
-          </select><!-- /.select-tab -->
-
-          <div class="tab-content m-t-15">
-
-            <div id="slack-incoming-webhooks" class="tab-pane active" role="tabpanel">
-
-              <form action="/admin/notification/slackIwhSetting" method="post" class="form-horizontal" id="appSettingForm" role="form">
-                <fieldset>
-                  <legend>Slack Incoming Webhooks Configuration</legend>
-
-                  <div class="form-group">
-                    <label for="slackIwhSetting[slack:incomingWebhookUrl]" class="col-xs-3 control-label">Webhook URL</label>
-                    <div class="col-xs-9">
-                      <input class="form-control" type="text" name="slackIwhSetting[slack:incomingWebhookUrl]" value="{{ slackSetting['slack:incomingWebhookUrl'] }}">
-                    </div>
-                  </div>
-
-                  <div class="form-group">
-                    <label for="slackIwhSetting[slack:isIncomingWebhookPrioritized]" class="col-xs-3 control-label"></label>
-                    <div class="col-xs-9">
-                      <div class="checkbox checkbox-info">
-                        <input type="checkbox" id ="cbPrioritizeIWH" name="slackIwhSetting[slack:isIncomingWebhookPrioritized]" value="1"
-                         {% if slackSetting['slack:isIncomingWebhookPrioritized'] %}checked{% endif %}>
-                        <label for="cbPrioritizeIWH">
-                         Prioritize Incoming Webhook than Slack App
-                        </label>
-                      </div>
-                      <p class="help-block">Check this option and GROWI use Incoming Webhooks even if Slack App settings are enabled.</p>
-                    </div>
-                  </div>
-
-                  <div class="form-group">
-                    <div class="col-xs-offset-3 col-xs-6">
-                      <button type="submit" class="btn btn-primary">Save</button>
-                    </div>
-                  </div>
-                </fieldset>
-                <input type="hidden" name="_csrf" value="{{ csrf() }}">
-              </form>
-
-              <hr>
-              <h3>
-                <i class="icon-question" aria-hidden="true"></i>
-                <a href="#collapseHelpForIwh" data-toggle="collapse">How to configure Incoming Webhooks?</a>
-              </h3>
-
-              <ol id="collapseHelpForIwh" class="collapse">
-                <li>
-                 (At Workspace) Add a hook
-                  <ol>
-                    <li>Go to <a href="https://slack.com/services/new/incoming-webhook">Incoming Webhooks Configuration page</a>.</li>
-                    <li>Choose the default channel to post.</li>
-                    <li>Add.</li>
-                  </ol>
-                </li>
-                <li>
-                (At GROWI admin page) Set Webhook URL
-                  <ol>
-                    <li>Input "Webhook URL" and submit on this page.</li>
-                  </ol>
-                </li>
-              </ol>
-
-            </div><!-- /#slack-incoming-webhooks -->
-
-            <div id="slack-app" class="tab-pane" role="tabpanel" >
-
-              <form action="/admin/notification/slackSetting" method="post" class="form-horizontal" id="appSettingForm" role="form">
-                <fieldset>
-                  <legend>Slack App Configuration</legend>
-
-                  <p class="well">
-                    <i class="icon-fw icon-exclamation text-danger"></i><span class="text-danger">NOT RECOMMENDED</span>
-                    <br><br>
-                    This is the way that compatible with Crowi,<br>
-                    but not recommended in GROWI because it is <strong>too complex</strong>.
-                    <br><br>
-                    Please use <a href="#slack-incoming-webhooks" data-toggle="tab" onclick="activateSlackIwh()">Slack incomming webhooks Configuration</a> instead.
-                  </p>
-
-                  <div class="form-group">
-                    <label for="slackSetting[slack:token]" class="col-xs-3 control-label">OAuth Access Token</label>
-                    <div class="col-xs-6">
-                      <input class="form-control" type="text" name="slackSetting[slack:token]" value="{{ slackSetting['slack:token'] || '' }}">
-                    </div>
-                  </div>
-
-                  <div class="form-group">
-                    <div class="col-xs-offset-3 col-xs-6">
-                      <button type="submit" class="btn btn-primary">Save</button>
-                    </div>
-                  </div>
-                </fieldset>
-                <input type="hidden" name="_csrf" value="{{ csrf() }}">
-              </form>
-
-              <hr>
-              <h3>
-                <i class="icon-question" aria-hidden="true"></i>
-                <a href="#collapseHelpForApp" data-toggle="collapse">How to configure Slack App?</a>
-              </h3>
-
-              <ol id="collapseHelpForApp" class="collapse">
-                <li>
-                  Register Slack App
-                  <ol>
-                    <li>
-                     Create App from <a href="https://api.slack.com/applications/new">this link</a>, and fill the form out as below:
-                      <dl class="dl-horizontal">
-                        <dt>App Name</dt> <dd><code>growi</code> </dd>
-                        <dt>Development Slack Workspace</dt> <dd>Select the workspace you want to notify to.</dd>
-                      </dl>
-                    </li>
-                    <li><strong>Save</strong> it.</li>
-                  </ol>
-                </li>
-                <li>
-                  Set Permission Scopes to the App
-                  <ol>
-                    <li>Go to "OAuth &amp; Permissions" page.</li>
-                    <li>Add "Send messages as GROWI"(<code>chat:write:bot</code>).</li>
-                    <li>Don't forget to <strong>save</strong>.</li>
-                  </ol>
-                </li>
-                <li>
-                  Create a bot user
-                  <ol>
-                    <li>Go to "Bot Users" page and add.</li>
-                  </ol>
-                </li>
-                <li>
-                  Install the app
-                  <ol>
-                    <li>Go to "Install App to Your Workspace" page and install.</li>
-                    <li>Go to "OAuth &amp; Permissions" page and copy <code>OAuth Access Token</code>.</li>
-                  </ol>
-                </li>
-                <li>
-                  (At this page) Set OAuth Access Token
-                  <ol>
-                    <li>Input "OAuth Access Token".</li>
-                    <li>Don't forget to <strong>save</strong>.</li>
-                  </ol>
-                </li>
-              </ol>
-
-            </div><!-- /#slack-app -->
-
-          </div><!-- /.tab-content -->
-        </div>
-
         <div id="user-trigger-notification" class="tab-pane" role="tabpanel">
           <h4>Default Notification Settings for Patterns</h4>