|
|
@@ -4,30 +4,22 @@ import PropTypes from 'prop-types';
|
|
|
import AppContainer from '../../../services/AppContainer';
|
|
|
import AdminAppContainer from '../../../services/AdminAppContainer';
|
|
|
import { withUnstatedContainers } from '../../UnstatedUtils';
|
|
|
-import { toastSuccess, toastError } from '../../../util/apiNotification';
|
|
|
import CustomBotWithoutProxySettingsAccordion, { botInstallationStep } from './CustomBotWithoutProxySettingsAccordion';
|
|
|
import CustomBotWithoutProxyIntegrationCard from './CustomBotWithoutProxyIntegrationCard';
|
|
|
import DeleteSlackBotSettingsModal from './DeleteSlackBotSettingsModal';
|
|
|
|
|
|
const CustomBotWithoutProxySettings = (props) => {
|
|
|
- const { appContainer } = props;
|
|
|
+ const { appContainer, onResetSettings } = props;
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
const [siteName, setSiteName] = useState('');
|
|
|
const [isDeleteConfirmModalShown, setIsDeleteConfirmModalShown] = useState(false);
|
|
|
|
|
|
- const deleteSlackSettingsHandler = async() => {
|
|
|
- try {
|
|
|
- await appContainer.apiv3.put('/slack-integration-settings/bot-type', {
|
|
|
- slackSigningSecret: null,
|
|
|
- slackBotToken: null,
|
|
|
- currentBotType: null,
|
|
|
- });
|
|
|
- toastSuccess('success');
|
|
|
- }
|
|
|
- catch (err) {
|
|
|
- toastError(err);
|
|
|
+ const resetSettings = async() => {
|
|
|
+ if (onResetSettings == null) {
|
|
|
+ return;
|
|
|
}
|
|
|
+ onResetSettings();
|
|
|
};
|
|
|
|
|
|
useEffect(() => {
|
|
|
@@ -46,12 +38,14 @@ const CustomBotWithoutProxySettings = (props) => {
|
|
|
|
|
|
<h2 className="admin-setting-header">{t('admin:slack_integration.custom_bot_without_proxy_settings')}</h2>
|
|
|
|
|
|
+ {(props.slackSigningSecret || props.slackBotToken) && (
|
|
|
<button
|
|
|
className="mx-3 pull-right btn text-danger border-danger"
|
|
|
type="button"
|
|
|
onClick={() => setIsDeleteConfirmModalShown(true)}
|
|
|
>{t('admin:slack_integration.reset')}
|
|
|
</button>
|
|
|
+ )}
|
|
|
|
|
|
<div className="my-5 mx-3">
|
|
|
<CustomBotWithoutProxySettingsAccordion
|
|
|
@@ -63,7 +57,7 @@ const CustomBotWithoutProxySettings = (props) => {
|
|
|
isResetAll={false}
|
|
|
isOpen={isDeleteConfirmModalShown}
|
|
|
onClose={() => setIsDeleteConfirmModalShown(false)}
|
|
|
- onClickDeleteButton={deleteSlackSettingsHandler}
|
|
|
+ onClickDeleteButton={resetSettings}
|
|
|
/>
|
|
|
</>
|
|
|
);
|
|
|
@@ -80,6 +74,7 @@ CustomBotWithoutProxySettings.propTypes = {
|
|
|
slackBotTokenEnv: PropTypes.string,
|
|
|
isRgisterSlackCredentials: PropTypes.bool,
|
|
|
slackWSNameInWithoutProxy: PropTypes.string,
|
|
|
+ onResetSettings: PropTypes.func,
|
|
|
};
|
|
|
|
|
|
export default CustomBotWithoutProxySettingsWrapper;
|