|
@@ -26,42 +26,28 @@ const SlackIntegration = (props) => {
|
|
|
const [isSendTestMessage, setIsSendTestMessage] = useState(false);
|
|
const [isSendTestMessage, setIsSendTestMessage] = useState(false);
|
|
|
const [slackWSNameInWithoutProxy, setSlackWSNameInWithoutProxy] = useState(null);
|
|
const [slackWSNameInWithoutProxy, setSlackWSNameInWithoutProxy] = useState(null);
|
|
|
|
|
|
|
|
- const fetchSlackWorkSpaceNameInWithoutProxy = useCallback(async() => {
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- const res = await appContainer.apiv3.get('/slack-integration-settings/custom-bot-without-proxy/slack-workspace-name');
|
|
|
|
|
- setSlackWSNameInWithoutProxy(res.data.slackWorkSpaceName);
|
|
|
|
|
- }
|
|
|
|
|
- catch (err) {
|
|
|
|
|
- if (err[0].message === 'missing_scope') {
|
|
|
|
|
- setSlackWSNameInWithoutProxy(null);
|
|
|
|
|
- toastError(err, t('admin:slack_integration.set_scope'));
|
|
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- toastError(err);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }, [appContainer.apiv3, t]);
|
|
|
|
|
-
|
|
|
|
|
const fetchSlackIntegrationData = useCallback(async() => {
|
|
const fetchSlackIntegrationData = useCallback(async() => {
|
|
|
try {
|
|
try {
|
|
|
- const response = await appContainer.apiv3.get('/slack-integration-settings');
|
|
|
|
|
- const { currentBotType, customBotWithoutProxySettings } = response.data.slackBotSettingParams;
|
|
|
|
|
|
|
+ const { data } = await appContainer.apiv3.get('/slack-integration-settings');
|
|
|
const {
|
|
const {
|
|
|
slackSigningSecret, slackBotToken, slackSigningSecretEnvVars, slackBotTokenEnvVars,
|
|
slackSigningSecret, slackBotToken, slackSigningSecretEnvVars, slackBotTokenEnvVars,
|
|
|
- } = customBotWithoutProxySettings;
|
|
|
|
|
|
|
+ } = data.settings;
|
|
|
|
|
+
|
|
|
|
|
+ if (data.connectionStatuses != null) {
|
|
|
|
|
+ const { workspaceName } = data.connectionStatuses[slackBotToken];
|
|
|
|
|
+ setSlackWSNameInWithoutProxy(workspaceName);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
setCurrentBotType(currentBotType);
|
|
setCurrentBotType(currentBotType);
|
|
|
setSlackSigningSecret(slackSigningSecret);
|
|
setSlackSigningSecret(slackSigningSecret);
|
|
|
setSlackBotToken(slackBotToken);
|
|
setSlackBotToken(slackBotToken);
|
|
|
setSlackSigningSecretEnv(slackSigningSecretEnvVars);
|
|
setSlackSigningSecretEnv(slackSigningSecretEnvVars);
|
|
|
setSlackBotTokenEnv(slackBotTokenEnvVars);
|
|
setSlackBotTokenEnv(slackBotTokenEnvVars);
|
|
|
- fetchSlackWorkSpaceNameInWithoutProxy();
|
|
|
|
|
}
|
|
}
|
|
|
catch (err) {
|
|
catch (err) {
|
|
|
toastError(err);
|
|
toastError(err);
|
|
|
}
|
|
}
|
|
|
- }, [appContainer.apiv3, fetchSlackWorkSpaceNameInWithoutProxy]);
|
|
|
|
|
|
|
+ }, [appContainer.apiv3, currentBotType]);
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|