|
@@ -5,7 +5,6 @@ import AppContainer from '../../../services/AppContainer';
|
|
|
import { withUnstatedContainers } from '../../UnstatedUtils';
|
|
import { withUnstatedContainers } from '../../UnstatedUtils';
|
|
|
import { toastSuccess, toastError } from '../../../util/apiNotification';
|
|
import { toastSuccess, toastError } from '../../../util/apiNotification';
|
|
|
|
|
|
|
|
-import AccessTokenSettings from './AccessTokenSettings';
|
|
|
|
|
import OfficialBotSettings from './OfficialBotSettings';
|
|
import OfficialBotSettings from './OfficialBotSettings';
|
|
|
import CustomBotWithoutProxySettings from './CustomBotWithoutProxySettings';
|
|
import CustomBotWithoutProxySettings from './CustomBotWithoutProxySettings';
|
|
|
import CustomBotWithProxySettings from './CustomBotWithProxySettings';
|
|
import CustomBotWithProxySettings from './CustomBotWithProxySettings';
|
|
@@ -19,7 +18,6 @@ const SlackIntegration = (props) => {
|
|
|
const { t } = useTranslation();
|
|
const { t } = useTranslation();
|
|
|
const [currentBotType, setCurrentBotType] = useState(null);
|
|
const [currentBotType, setCurrentBotType] = useState(null);
|
|
|
const [selectedBotType, setSelectedBotType] = useState(null);
|
|
const [selectedBotType, setSelectedBotType] = useState(null);
|
|
|
- const [accessToken, setAccessToken] = useState('');
|
|
|
|
|
const [slackSigningSecret, setSlackSigningSecret] = useState('');
|
|
const [slackSigningSecret, setSlackSigningSecret] = useState('');
|
|
|
const [slackBotToken, setSlackBotToken] = useState('');
|
|
const [slackBotToken, setSlackBotToken] = useState('');
|
|
|
const [slackSigningSecretEnv, setSlackSigningSecretEnv] = useState('');
|
|
const [slackSigningSecretEnv, setSlackSigningSecretEnv] = useState('');
|
|
@@ -33,13 +31,12 @@ const SlackIntegration = (props) => {
|
|
|
const fetchData = useCallback(async() => {
|
|
const fetchData = useCallback(async() => {
|
|
|
try {
|
|
try {
|
|
|
const response = await appContainer.apiv3.get('slack-integration/');
|
|
const response = await appContainer.apiv3.get('slack-integration/');
|
|
|
- const { currentBotType, customBotWithoutProxySettings, accessToken } = response.data.slackBotSettingParams;
|
|
|
|
|
|
|
+ const { currentBotType, customBotWithoutProxySettings } = response.data.slackBotSettingParams;
|
|
|
const {
|
|
const {
|
|
|
slackSigningSecret, slackBotToken, slackSigningSecretEnvVars, slackBotTokenEnvVars, isSetupSlackBot,
|
|
slackSigningSecret, slackBotToken, slackSigningSecretEnvVars, slackBotTokenEnvVars, isSetupSlackBot,
|
|
|
} = customBotWithoutProxySettings;
|
|
} = customBotWithoutProxySettings;
|
|
|
|
|
|
|
|
setCurrentBotType(currentBotType);
|
|
setCurrentBotType(currentBotType);
|
|
|
- setAccessToken(accessToken);
|
|
|
|
|
setSlackSigningSecret(slackSigningSecret);
|
|
setSlackSigningSecret(slackSigningSecret);
|
|
|
setSlackBotToken(slackBotToken);
|
|
setSlackBotToken(slackBotToken);
|
|
|
setSlackSigningSecretEnv(slackSigningSecretEnvVars);
|
|
setSlackSigningSecretEnv(slackSigningSecretEnvVars);
|
|
@@ -95,27 +92,6 @@ const SlackIntegration = (props) => {
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- const generateTokenHandler = async() => {
|
|
|
|
|
- try {
|
|
|
|
|
- await appContainer.apiv3.put('slack-integration/access-token');
|
|
|
|
|
- fetchData();
|
|
|
|
|
- }
|
|
|
|
|
- catch (err) {
|
|
|
|
|
- toastError(err);
|
|
|
|
|
- }
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- const discardTokenHandler = async() => {
|
|
|
|
|
- try {
|
|
|
|
|
- await appContainer.apiv3.delete('slack-integration/access-token');
|
|
|
|
|
- fetchData();
|
|
|
|
|
- toastSuccess(t('admin:slack_integration.bot_reset_successful'));
|
|
|
|
|
- }
|
|
|
|
|
- catch (err) {
|
|
|
|
|
- toastError(err);
|
|
|
|
|
- }
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
let settingsComponent = null;
|
|
let settingsComponent = null;
|
|
|
|
|
|
|
|
switch (currentBotType) {
|
|
switch (currentBotType) {
|
|
@@ -125,7 +101,6 @@ const SlackIntegration = (props) => {
|
|
|
case 'customBotWithoutProxy':
|
|
case 'customBotWithoutProxy':
|
|
|
settingsComponent = (
|
|
settingsComponent = (
|
|
|
<CustomBotWithoutProxySettings
|
|
<CustomBotWithoutProxySettings
|
|
|
- accessToken={accessToken}
|
|
|
|
|
isSendTestMessage={isSendTestMessage}
|
|
isSendTestMessage={isSendTestMessage}
|
|
|
isRegisterSlackCredentials={isRegisterSlackCredentials}
|
|
isRegisterSlackCredentials={isRegisterSlackCredentials}
|
|
|
isConnectedToSlack={isConnectedToSlack}
|
|
isConnectedToSlack={isConnectedToSlack}
|
|
@@ -155,12 +130,6 @@ const SlackIntegration = (props) => {
|
|
|
onCancelClick={cancelBotChangeHandler}
|
|
onCancelClick={cancelBotChangeHandler}
|
|
|
/>
|
|
/>
|
|
|
|
|
|
|
|
- <AccessTokenSettings
|
|
|
|
|
- accessToken={accessToken}
|
|
|
|
|
- onClickDiscardButton={discardTokenHandler}
|
|
|
|
|
- onClickGenerateToken={generateTokenHandler}
|
|
|
|
|
- />
|
|
|
|
|
-
|
|
|
|
|
<div className="selecting-bot-type my-5">
|
|
<div className="selecting-bot-type my-5">
|
|
|
<h2 className="admin-setting-header mb-4">
|
|
<h2 className="admin-setting-header mb-4">
|
|
|
{t('admin:slack_integration.selecting_bot_types.slack_bot')}
|
|
{t('admin:slack_integration.selecting_bot_types.slack_bot')}
|