Yuki Takei 4 лет назад
Родитель
Сommit
e9cf5eb0aa

+ 6 - 0
packages/app/src/client/services/AdminNotificationContainer.js

@@ -13,6 +13,11 @@ export default class AdminNotificationContainer extends Container {
 
     this.state = {
       retrieveError: null,
+
+      isSlackbotConfigured: null,
+      isSlackLegacyConfigured: null,
+      currentBotType: null,
+
       userNotifications: [],
       isNotificationForOwnerPageEnabled: false,
       isNotificationForGroupPageEnabled: false,
@@ -38,6 +43,7 @@ export default class AdminNotificationContainer extends Container {
     this.setState({
       isSlackbotConfigured: notificationParams.isSlackbotConfigured,
       isSlackLegacyConfigured: notificationParams.isSlackLegacyConfigured,
+      currentBotType: notificationParams.currentBotType,
 
       userNotifications: notificationParams.userNotifications,
       isNotificationForOwnerPageEnabled: notificationParams.isNotificationForOwnerPageEnabled,

+ 10 - 8
packages/app/src/components/Admin/Notification/NotificationSetting.jsx

@@ -45,17 +45,19 @@ const SkeltonListItem = () => (
 );
 
 // eslint-disable-next-line react/prop-types
-const SlackIntegrationListItem = ({ isEnabled }) => {
+const SlackIntegrationListItem = ({ isEnabled, currentBotType }) => {
   const { t } = useTranslation();
 
+  const isCautionVisible = currentBotType === 'officialBot' || currentBotType === 'customBotWithProxy';
+
   return (
     <li className="list-group-item">
-      <h4 className="mb-2">
+      <h4>
         <Badge isEnabled={isEnabled} />
         <a href="/admin/slack-integration" className="ml-2">{t('slack_integration')}</a>
       </h4>
-      { isEnabled && (
-        <ul className="pl-4">
+      { isCautionVisible && (
+        <ul className="mt-2 pl-4">
           {/* eslint-disable-next-line react/no-danger */}
           <li dangerouslySetInnerHTML={{ __html: t('admin:external_notification.caution_enabled') }} />
         </ul>
@@ -70,12 +72,12 @@ const LegacySlackIntegrationListItem = ({ isEnabled }) => {
 
   return (
     <li className="list-group-item">
-      <h4 className="mb-1">
+      <h4>
         <Badge isEnabled={isEnabled} />
         <a href="/admin/slack-integration-legacy" className="ml-2">{t('legacy_slack_integration')}</a>
       </h4>
       { isEnabled && (
-        <ul className="pl-4">
+        <ul className="mt-2 pl-4">
           <li>
             {/* eslint-disable-next-line react/no-danger */}
             <span className="text-danger" dangerouslySetInnerHTML={{ __html: t('admin:slack_integration_legacy.alert_deplicated') }}></span>
@@ -134,7 +136,7 @@ function NotificationSetting(props) {
     };
   }, []);
 
-  const { isSlackbotConfigured, isSlackLegacyConfigured } = adminNotificationContainer.state;
+  const { isSlackbotConfigured, isSlackLegacyConfigured, currentBotType } = adminNotificationContainer.state;
   const isSlackEnabled = isSlackbotConfigured;
   const isSlackLegacyEnabled = !isSlackbotConfigured && isSlackLegacyConfigured;
 
@@ -145,7 +147,7 @@ function NotificationSetting(props) {
         { !isMounted && <SkeltonListItem />}
         { isMounted && (
           <>
-            <SlackIntegrationListItem isEnabled={isSlackEnabled} />
+            <SlackIntegrationListItem isEnabled={isSlackEnabled} currentBotType={currentBotType} />
             {/* Legacy Slack Integration become visible only when new Slack Integration is disabled */}
             { !isSlackEnabled && <LegacySlackIntegrationListItem isEnabled={isSlackLegacyEnabled} /> }
           </>

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

@@ -121,6 +121,7 @@ module.exports = (crowi) => {
       // status of slack intagration
       isSlackbotConfigured: crowi.slackIntegrationService.isSlackbotConfigured,
       isSlackLegacyConfigured: crowi.slackIntegrationService.isSlackLegacyConfigured,
+      currentBotType: await crowi.configManager.getConfig('crowi', 'slackbot:currentBotType'),
 
       userNotifications: await UpdatePost.findAll(),
       isNotificationForOwnerPageEnabled: await crowi.configManager.getConfig('notification', 'notification:owner-page:isEnabled'),