Parcourir la source

user array errors

zahmis il y a 5 ans
Parent
commit
792a097a2f

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

@@ -23,7 +23,7 @@ const CustomBotWithoutProxyIntegrationCard = (props) => {
       </div>
       </div>
 
 
       <div className="text-center w-25">
       <div className="text-center w-25">
-        {props.isSlackScopeSet && (
+        {!props.errors.includes(false) && (
         <div className="mt-5">
         <div className="mt-5">
           <p className="text-success small">
           <p className="text-success small">
             <i className="fa fa-check mr-1" />
             <i className="fa fa-check mr-1" />
@@ -32,7 +32,7 @@ const CustomBotWithoutProxyIntegrationCard = (props) => {
           <hr className="align-self-center admin-border-success border-success"></hr>
           <hr className="align-self-center admin-border-success border-success"></hr>
         </div>
         </div>
           )}
           )}
-        {!props.isSlackScopeSet && (
+        {props.errors.includes(false) && (
         <div className="mt-4">
         <div className="mt-4">
           <small
           <small
             className="text-secondary m-0"
             className="text-secondary m-0"
@@ -57,7 +57,8 @@ const CustomBotWithoutProxyIntegrationCard = (props) => {
 CustomBotWithoutProxyIntegrationCard.propTypes = {
 CustomBotWithoutProxyIntegrationCard.propTypes = {
   siteName: PropTypes.string.isRequired,
   siteName: PropTypes.string.isRequired,
   slackWSNameInWithoutProxy: PropTypes.string,
   slackWSNameInWithoutProxy: PropTypes.string,
-  isSlackScopeSet: PropTypes.bool.isRequired,
+  // isSlackScopeSet: PropTypes.bool.isRequired,
+  errors: PropTypes.array,
 };
 };
 
 
 export default CustomBotWithoutProxyIntegrationCard;
 export default CustomBotWithoutProxyIntegrationCard;

+ 14 - 12
src/client/js/components/Admin/SlackIntegration/CustomBotWithoutProxySettings.jsx

@@ -10,7 +10,7 @@ import CustomBotWithoutProxyIntegrationCard from './CustomBotWithoutProxyIntegra
 import DeleteSlackBotSettingsModal from './DeleteSlackBotSettingsModal';
 import DeleteSlackBotSettingsModal from './DeleteSlackBotSettingsModal';
 
 
 const CustomBotWithoutProxySettings = (props) => {
 const CustomBotWithoutProxySettings = (props) => {
-  const { appContainer, isSlackScopeSet, isSetupSlackBot } = props;
+  const { appContainer, errors } = props;
   const { t } = useTranslation();
   const { t } = useTranslation();
 
 
   const [siteName, setSiteName] = useState('');
   const [siteName, setSiteName] = useState('');
@@ -23,11 +23,11 @@ const CustomBotWithoutProxySettings = (props) => {
     }
     }
   };
   };
 
 
-  const onSetIsSlackScopeSet = () => {
-    if (props.onSetIsSlackScopeSet != null) {
-      props.onSetIsSlackScopeSet();
-    }
-  };
+  // const onSetIsSlackScopeSet = () => {
+  //   if (props.onSetIsSlackScopeSet != null) {
+  //     props.onSetIsSlackScopeSet();
+  //   }
+  // };
 
 
   const deleteSlackCredentialsHandler = async() => {
   const deleteSlackCredentialsHandler = async() => {
     try {
     try {
@@ -37,7 +37,7 @@ const CustomBotWithoutProxySettings = (props) => {
         currentBotType: '',
         currentBotType: '',
       });
       });
       onSetIsSetupSlackBot(false);
       onSetIsSetupSlackBot(false);
-      onSetIsSlackScopeSet(false);
+      // onSetIsSlackScopeSet(false);
       toastSuccess('success');
       toastSuccess('success');
     }
     }
     catch (err) {
     catch (err) {
@@ -57,13 +57,14 @@ const CustomBotWithoutProxySettings = (props) => {
       <CustomBotWithoutProxyIntegrationCard
       <CustomBotWithoutProxyIntegrationCard
         siteName={siteName}
         siteName={siteName}
         slackWSNameInWithoutProxy={props.slackWSNameInWithoutProxy}
         slackWSNameInWithoutProxy={props.slackWSNameInWithoutProxy}
-        isSlackScopeSet={props.isSlackScopeSet}
-        isSetupSlackBot={props.isSetupSlackBot}
+        errors={errors}
+        // isSlackScopeSet={errors.isSlackScopeSet}
+        // isSetupSlackBot={errors.isSetupSlackBot}
       />
       />
 
 
       <h2 className="admin-setting-header">{t('admin:slack_integration.custom_bot_without_proxy_settings')}</h2>
       <h2 className="admin-setting-header">{t('admin:slack_integration.custom_bot_without_proxy_settings')}</h2>
 
 
-      {isSetupSlackBot && isSlackScopeSet && (
+      {!errors.includes(false) && (
       <button
       <button
         className="pull-right btn text-danger border-danger"
         className="pull-right btn text-danger border-danger"
         type="button"
         type="button"
@@ -98,8 +99,9 @@ CustomBotWithoutProxySettings.propTypes = {
   slackBotTokenEnv: PropTypes.string,
   slackBotTokenEnv: PropTypes.string,
   isRgisterSlackCredentials: PropTypes.bool,
   isRgisterSlackCredentials: PropTypes.bool,
   isConnectedToSlack: PropTypes.bool,
   isConnectedToSlack: PropTypes.bool,
-  isSlackScopeSet: PropTypes.bool,
-  isSetupSlackBot: PropTypes.bool,
+  // isSlackScopeSet: PropTypes.bool,
+  // isSetupSlackBot: PropTypes.bool,
+  errors: PropTypes.array,
   slackWSNameInWithoutProxy: PropTypes.string,
   slackWSNameInWithoutProxy: PropTypes.string,
   onSetIsSetupSlackBot: PropTypes.func,
   onSetIsSetupSlackBot: PropTypes.func,
   onSetIsSlackScopeSet: PropTypes.func,
   onSetIsSlackScopeSet: PropTypes.func,

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

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