|
@@ -10,21 +10,21 @@ import {
|
|
|
} from '~/client/util/apiv3-client';
|
|
} from '~/client/util/apiv3-client';
|
|
|
import { toastSuccess, toastError } from '~/client/util/toastr';
|
|
import { toastSuccess, toastError } from '~/client/util/toastr';
|
|
|
|
|
|
|
|
-import BotTypeCard from './BotTypeCard';
|
|
|
|
|
|
|
+import { BotTypeCard } from './BotTypeCard';
|
|
|
import ConfirmBotChangeModal from './ConfirmBotChangeModal';
|
|
import ConfirmBotChangeModal from './ConfirmBotChangeModal';
|
|
|
import CustomBotWithProxySettings from './CustomBotWithProxySettings';
|
|
import CustomBotWithProxySettings from './CustomBotWithProxySettings';
|
|
|
import CustomBotWithoutProxySettings from './CustomBotWithoutProxySettings';
|
|
import CustomBotWithoutProxySettings from './CustomBotWithoutProxySettings';
|
|
|
-import DeleteSlackBotSettingsModal from './DeleteSlackBotSettingsModal';
|
|
|
|
|
|
|
+import { DeleteSlackBotSettingsModal } from './DeleteSlackBotSettingsModal';
|
|
|
import OfficialBotSettings from './OfficialBotSettings';
|
|
import OfficialBotSettings from './OfficialBotSettings';
|
|
|
|
|
|
|
|
|
|
|
|
|
const botTypes = Object.values(SlackbotType);
|
|
const botTypes = Object.values(SlackbotType);
|
|
|
|
|
|
|
|
-const SlackIntegration = () => {
|
|
|
|
|
|
|
+export const SlackIntegration = (): JSX.Element => {
|
|
|
|
|
|
|
|
const { t } = useTranslation();
|
|
const { t } = useTranslation();
|
|
|
- const [currentBotType, setCurrentBotType] = useState(null);
|
|
|
|
|
- const [selectedBotType, setSelectedBotType] = useState(null);
|
|
|
|
|
|
|
+ const [currentBotType, setCurrentBotType] = useState<SlackbotType | undefined>();
|
|
|
|
|
+ const [selectedBotType, setSelectedBotType] = useState<SlackbotType | undefined>();
|
|
|
const [slackSigningSecret, setSlackSigningSecret] = useState(null);
|
|
const [slackSigningSecret, setSlackSigningSecret] = useState(null);
|
|
|
const [slackBotToken, setSlackBotToken] = useState(null);
|
|
const [slackBotToken, setSlackBotToken] = useState(null);
|
|
|
const [slackSigningSecretEnv, setSlackSigningSecretEnv] = useState('');
|
|
const [slackSigningSecretEnv, setSlackSigningSecretEnv] = useState('');
|
|
@@ -106,12 +106,12 @@ const SlackIntegration = () => {
|
|
|
fetchSlackIntegrationData();
|
|
fetchSlackIntegrationData();
|
|
|
}, [fetchSlackIntegrationData]);
|
|
}, [fetchSlackIntegrationData]);
|
|
|
|
|
|
|
|
- const changeCurrentBotSettings = async(botType) => {
|
|
|
|
|
|
|
+ const changeCurrentBotSettings = async(botType?: SlackbotType) => {
|
|
|
try {
|
|
try {
|
|
|
await apiv3Put('/slack-integration-settings/bot-type', {
|
|
await apiv3Put('/slack-integration-settings/bot-type', {
|
|
|
currentBotType: botType,
|
|
currentBotType: botType,
|
|
|
});
|
|
});
|
|
|
- setSelectedBotType(null);
|
|
|
|
|
|
|
+ setSelectedBotType(undefined);
|
|
|
fetchSlackIntegrationData();
|
|
fetchSlackIntegrationData();
|
|
|
}
|
|
}
|
|
|
catch (err) {
|
|
catch (err) {
|
|
@@ -119,7 +119,7 @@ const SlackIntegration = () => {
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- const botTypeSelectHandler = async(botType) => {
|
|
|
|
|
|
|
+ const botTypeSelectHandler = async(botType: SlackbotType) => {
|
|
|
if (botType === currentBotType) {
|
|
if (botType === currentBotType) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -135,10 +135,10 @@ const SlackIntegration = () => {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const cancelBotChangeHandler = () => {
|
|
const cancelBotChangeHandler = () => {
|
|
|
- setSelectedBotType(null);
|
|
|
|
|
|
|
+ setSelectedBotType(undefined);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- let settingsComponent = null;
|
|
|
|
|
|
|
+ let settingsComponent = <></>;
|
|
|
|
|
|
|
|
switch (currentBotType) {
|
|
switch (currentBotType) {
|
|
|
case SlackbotType.OFFICIAL:
|
|
case SlackbotType.OFFICIAL:
|
|
@@ -231,7 +231,7 @@ const SlackIntegration = () => {
|
|
|
</button>
|
|
</button>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
- <div className="row my-5 flex-wrap-reverse justify-content-center">
|
|
|
|
|
|
|
+ <div className="my-5 d-flex flex-wrap-reverse justify-content-center">
|
|
|
{botTypes.map((botType) => {
|
|
{botTypes.map((botType) => {
|
|
|
return (
|
|
return (
|
|
|
<div key={botType} className="m-3">
|
|
<div key={botType} className="m-3">
|
|
@@ -251,4 +251,4 @@ const SlackIntegration = () => {
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-export default SlackIntegration;
|
|
|
|
|
|
|
+SlackIntegration.displayName = 'SlackIntegration';
|