Просмотр исходного кода

Merge pull request #3726 from weseek/feat/GW-5937-reset-modal

reset modal
itizawa 4 лет назад
Родитель
Сommit
b96a575faf

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

@@ -97,6 +97,7 @@ const CustomBotWithProxySettings = (props) => {
         </div>
       </div>
       <DeleteSlackBotSettingsModal
+        isResetAll={false}
         isOpen={isDeleteConfirmModalShown}
         onClose={() => setIsDeleteConfirmModalShown(false)}
         onClickDeleteButton={deleteSlackSettingsHandler}

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

@@ -60,6 +60,7 @@ const CustomBotWithoutProxySettings = (props) => {
         />
       </div>
       <DeleteSlackBotSettingsModal
+        isResetAll={false}
         isOpen={isDeleteConfirmModalShown}
         onClose={() => setIsDeleteConfirmModalShown(false)}
         onClickDeleteButton={deleteSlackSettingsHandler}

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

@@ -36,7 +36,16 @@ const DeleteSlackBotSettingsModal = React.memo((props) => {
       <ModalHeader tag="h4" toggle={closeButtonHandler} className="bg-danger text-light">
         <span>
           <i className="icon-fw icon-fire"></i>
-          {t('admin:slack_integration.delete_slackbot_settings')}
+          {props.isResetAll && (
+            <>
+              {t('admin:slack_integration.reset_all_settings')}
+            </>
+          )}
+          {!props.isResetAll && (
+            <>
+              {t('admin:slack_integration.delete_slackbot_settings')}
+            </>
+          )}
         </span>
       </ModalHeader>
       <ModalBody>
@@ -56,7 +65,7 @@ const DeleteSlackBotSettingsModal = React.memo((props) => {
 
 DeleteSlackBotSettingsModal.propTypes = {
   t: PropTypes.func.isRequired, // i18next
-
+  isResetAll: PropTypes.bool.isRequired,
   isOpen: PropTypes.bool.isRequired,
   onClose: PropTypes.func,
   onClickDeleteButton: PropTypes.func,

+ 10 - 0
src/client/js/components/Admin/SlackIntegration/SlackIntegration.jsx

@@ -10,6 +10,7 @@ import CustomBotWithoutProxySettings from './CustomBotWithoutProxySettings';
 import CustomBotWithProxySettings from './CustomBotWithProxySettings';
 import ConfirmBotChangeModal from './ConfirmBotChangeModal';
 import BotTypeCard from './BotTypeCard';
+import DeleteSlackBotSettingsModal from './DeleteSlackBotSettingsModal';
 
 const botTypes = ['officialBot', 'customBotWithoutProxy', 'customBotWithProxy'];
 
@@ -25,6 +26,7 @@ const SlackIntegration = (props) => {
   const [isRegisterSlackCredentials, setIsRegisterSlackCredentials] = useState(false);
   const [isSendTestMessage, setIsSendTestMessage] = useState(false);
   const [slackWSNameInWithoutProxy, setSlackWSNameInWithoutProxy] = useState(null);
+  const [isDeleteConfirmModalShown, setIsDeleteConfirmModalShown] = useState(false);
 
   const fetchSlackIntegrationData = useCallback(async() => {
     try {
@@ -124,6 +126,13 @@ const SlackIntegration = (props) => {
         onCancelClick={cancelBotChangeHandler}
       />
 
+      {/* TODO add onClickDeleteButton */}
+      <DeleteSlackBotSettingsModal
+        isResetAll
+        isOpen={isDeleteConfirmModalShown}
+        onClose={() => setIsDeleteConfirmModalShown(false)}
+      />
+
       <div className="selecting-bot-type mb-5">
         <h2 className="admin-setting-header mb-4">
           {t('admin:slack_integration.selecting_bot_types.slack_bot')}
@@ -143,6 +152,7 @@ const SlackIntegration = (props) => {
             <button
               className="mx-3 btn btn-outline-danger flex-end"
               type="button"
+              onClick={() => setIsDeleteConfirmModalShown(true)}
             >{t('admin:slack_integration.reset_all_settings')}
             </button>
           )}