|
|
@@ -78,7 +78,26 @@ const SlackIntegration = (props) => {
|
|
|
fetchSlackIntegrationData();
|
|
|
}, [fetchSlackIntegrationData]);
|
|
|
|
|
|
- const handleBotTypeSelect = async(clickedBotType) => {
|
|
|
+ const changeCurrentBotSettings = async() => {
|
|
|
+ try {
|
|
|
+ const res = await appContainer.apiv3.put('/slack-integration-settings/bot-type', {
|
|
|
+ currentBotType: selectedBotType,
|
|
|
+ });
|
|
|
+ setCurrentBotType(res.data.slackBotTypeParam.slackBotType);
|
|
|
+ setSelectedBotType(null);
|
|
|
+ setIsRegisterSlackCredentials(false);
|
|
|
+ setSlackSigningSecret(null);
|
|
|
+ setSlackBotToken(null);
|
|
|
+ setIsSendTestMessage(false);
|
|
|
+ setSlackWSNameInWithoutProxy(null);
|
|
|
+ toastSuccess(t('admin:slack_integration.bot_reset_successful'));
|
|
|
+ }
|
|
|
+ catch (err) {
|
|
|
+ toastError(err);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ const botTypeSelectHandler = async(clickedBotType) => {
|
|
|
if (clickedBotType === currentBotType) {
|
|
|
return;
|
|
|
}
|
|
|
@@ -93,31 +112,15 @@ const SlackIntegration = (props) => {
|
|
|
}
|
|
|
return setCurrentBotType(clickedBotType);
|
|
|
}
|
|
|
-
|
|
|
setSelectedBotType(clickedBotType);
|
|
|
};
|
|
|
|
|
|
- const cancelBotChangeHandler = () => {
|
|
|
- setSelectedBotType(null);
|
|
|
+ const changeCurrentBotSettingsHandler = async(clickedBotType) => {
|
|
|
+ changeCurrentBotSettings(clickedBotType);
|
|
|
};
|
|
|
|
|
|
- const changeCurrentBotSettingsHandler = async() => {
|
|
|
- try {
|
|
|
- const res = await appContainer.apiv3.put('/slack-integration-settings/bot-type', {
|
|
|
- currentBotType: selectedBotType,
|
|
|
- });
|
|
|
- setCurrentBotType(res.data.slackBotTypeParam.slackBotType);
|
|
|
- setSelectedBotType(null);
|
|
|
- setIsRegisterSlackCredentials(false);
|
|
|
- setSlackSigningSecret(null);
|
|
|
- setSlackBotToken(null);
|
|
|
- setIsSendTestMessage(false);
|
|
|
- setSlackWSNameInWithoutProxy(null);
|
|
|
- toastSuccess(t('admin:slack_integration.bot_reset_successful'));
|
|
|
- }
|
|
|
- catch (err) {
|
|
|
- toastError(err);
|
|
|
- }
|
|
|
+ const cancelBotChangeHandler = () => {
|
|
|
+ setSelectedBotType(null);
|
|
|
};
|
|
|
|
|
|
let settingsComponent = null;
|
|
|
@@ -196,7 +199,7 @@ const SlackIntegration = (props) => {
|
|
|
<BotTypeCard
|
|
|
botType={botType}
|
|
|
isActive={currentBotType === botType}
|
|
|
- handleBotTypeSelect={handleBotTypeSelect}
|
|
|
+ botTypeSelectHandler={botTypeSelectHandler}
|
|
|
/>
|
|
|
</div>
|
|
|
);
|