zahmis 4 лет назад
Родитель
Сommit
74efa86222

+ 2 - 2
src/client/js/components/Admin/SlackIntegration/CustomBotWithoutProxyIntegrationCard.jsx

@@ -23,7 +23,7 @@ const CustomBotWithoutProxyIntegrationCard = (props) => {
       </div>
 
       <div className="text-center w-25">
-        {props.slackSettingsErrors.includes(false) ? (
+        {!props.isSlackScopeSet ? (
           <div className="mt-4">
             <small
               className="text-secondary m-0"
@@ -56,7 +56,7 @@ const CustomBotWithoutProxyIntegrationCard = (props) => {
 CustomBotWithoutProxyIntegrationCard.propTypes = {
   siteName: PropTypes.string.isRequired,
   slackWSNameInWithoutProxy: PropTypes.string,
-  slackSettingsErrors: PropTypes.array,
+  isSlackScopeSet: PropTypes.bool,
 };
 
 export default CustomBotWithoutProxyIntegrationCard;

+ 4 - 21
src/client/js/components/Admin/SlackIntegration/CustomBotWithoutProxySettings.jsx

@@ -10,25 +10,12 @@ import CustomBotWithoutProxyIntegrationCard from './CustomBotWithoutProxyIntegra
 import DeleteSlackBotSettingsModal from './DeleteSlackBotSettingsModal';
 
 const CustomBotWithoutProxySettings = (props) => {
-  const { appContainer, slackSettingsErrors } = props;
+  const { appContainer, isSlackScopeSet } = props;
   const { t } = useTranslation();
 
   const [siteName, setSiteName] = useState('');
   const [isDeleteConfirmModalShown, setIsDeleteConfirmModalShown] = useState(false);
 
-
-  const onSetIsSetupSlackBot = () => {
-    if (props.onSetIsSetupSlackBot != null) {
-      props.onSetIsSetupSlackBot();
-    }
-  };
-
-  const onSetIsSlackScopeSet = () => {
-    if (props.onSetIsSlackScopeSet != null) {
-      props.onSetIsSlackScopeSet();
-    }
-  };
-
   const deleteSlackSettingsHandler = async() => {
     try {
       await appContainer.apiv3.put('/slack-integration-settings/custom-bot-without-proxy', {
@@ -36,8 +23,6 @@ const CustomBotWithoutProxySettings = (props) => {
         slackBotToken: '',
         currentBotType: '',
       });
-      onSetIsSetupSlackBot(false);
-      onSetIsSlackScopeSet(false);
       toastSuccess('success');
     }
     catch (err) {
@@ -57,12 +42,12 @@ const CustomBotWithoutProxySettings = (props) => {
       <CustomBotWithoutProxyIntegrationCard
         siteName={siteName}
         slackWSNameInWithoutProxy={props.slackWSNameInWithoutProxy}
-        slackSettingsErrors={slackSettingsErrors}
+        isSlackScopeSet={isSlackScopeSet}
       />
 
       <h2 className="admin-setting-header">{t('admin:slack_integration.custom_bot_without_proxy_settings')}</h2>
 
-      {!slackSettingsErrors.includes(false) && (
+      {props.isSlackScopeSet && (
       <button
         className="mx-3 pull-right btn text-danger border-danger"
         type="button"
@@ -96,10 +81,8 @@ CustomBotWithoutProxySettings.propTypes = {
   slackBotToken: PropTypes.string,
   slackBotTokenEnv: PropTypes.string,
   isRgisterSlackCredentials: PropTypes.bool,
-  slackSettingsErrors: PropTypes.array,
+  isSlackScopeSet: PropTypes.bool,
   slackWSNameInWithoutProxy: PropTypes.string,
-  onSetIsSetupSlackBot: PropTypes.func,
-  onSetIsSlackScopeSet: PropTypes.func,
 };
 
 export default CustomBotWithoutProxySettingsWrapper;

+ 1 - 3
src/client/js/components/Admin/SlackIntegration/SlackIntegration.jsx

@@ -28,8 +28,6 @@ const SlackIntegration = (props) => {
   const [isSendTestMessage, setIsSendTestMessage] = useState(false);
   const [slackWSNameInWithoutProxy, setSlackWSNameInWithoutProxy] = useState(null);
   const [isSlackScopeSet, setIsSlackScopeSet] = useState(false);
-  const slackSettingsErrors = [isSetupSlackBot, isConnectedToSlack, isSlackScopeSet];
-
 
   const fetchSlackWorkSpaceNameInWithoutProxy = useCallback(async() => {
     if (!isSetupSlackBot || !isConnectedToSlack) {
@@ -139,7 +137,7 @@ const SlackIntegration = (props) => {
         <CustomBotWithoutProxySettings
           isSendTestMessage={isSendTestMessage}
           isRegisterSlackCredentials={isRegisterSlackCredentials}
-          slackSettingsErrors={slackSettingsErrors}
+          isSlackScopeSet={isSlackScopeSet}
           slackBotTokenEnv={slackBotTokenEnv}
           slackBotToken={slackBotToken}
           slackSigningSecretEnv={slackSigningSecretEnv}