|
|
@@ -5,22 +5,30 @@ import { Collapse } from 'reactstrap';
|
|
|
import AppContainer from '../../../services/AppContainer';
|
|
|
import { withUnstatedContainers } from '../../UnstatedUtils';
|
|
|
|
|
|
-const CustomBotWithoutProxySettingsAccordion = (props) => {
|
|
|
- const {
|
|
|
- appContainer, isRgisterSlackCredentials, isSendTestMessage,
|
|
|
- } = props;
|
|
|
+
|
|
|
+export const botInstallationStep = {
|
|
|
+ CREATE_BOT: 'create-bot',
|
|
|
+ INSTALL_BOT: 'install-bot',
|
|
|
+ REGISTER_SLACK_CONFIGURATION: 'register-slack-configuration',
|
|
|
+ CONNECTION_TEST: 'connection-test',
|
|
|
+};
|
|
|
+
|
|
|
+const CustomBotWithoutProxySettingsAccordion = ({
|
|
|
+ appContainer, activeStep, isRgisterSlackCredentials, isSendTestMessage, setIsSendTestMessage,
|
|
|
+}) => {
|
|
|
const { t } = useTranslation('admin');
|
|
|
- const [openAccordionIndexes, setOpenAccordionIndexes] = useState(new Set());
|
|
|
+ const [openAccordionIndexes, setOpenAccordionIndexes] = useState(new Set([activeStep]));
|
|
|
const [connectionErrorCode, setConnectionErrorCode] = useState(null);
|
|
|
const [connectionErrorMessage, setConnectionErrorMessage] = useState(null);
|
|
|
|
|
|
- const onToggleAccordionHandler = (i) => {
|
|
|
+
|
|
|
+ const onToggleAccordionHandler = (installationStep) => {
|
|
|
const accordionIndexes = new Set(openAccordionIndexes);
|
|
|
- if (accordionIndexes.has(i)) {
|
|
|
- accordionIndexes.delete(i);
|
|
|
+ if (accordionIndexes.has(installationStep)) {
|
|
|
+ accordionIndexes.delete(installationStep);
|
|
|
}
|
|
|
else {
|
|
|
- accordionIndexes.add(i);
|
|
|
+ accordionIndexes.add(installationStep);
|
|
|
}
|
|
|
setOpenAccordionIndexes(accordionIndexes);
|
|
|
};
|
|
|
@@ -33,10 +41,10 @@ const CustomBotWithoutProxySettingsAccordion = (props) => {
|
|
|
// TODO put proper request
|
|
|
channel: 'testchannel',
|
|
|
});
|
|
|
- props.setIsSendTestMessage(true);
|
|
|
+ setIsSendTestMessage(true);
|
|
|
}
|
|
|
catch (err) {
|
|
|
- props.setIsSendTestMessage(false);
|
|
|
+ setIsSendTestMessage(false);
|
|
|
setConnectionErrorCode(err[0].code);
|
|
|
setConnectionErrorMessage(err[0].message);
|
|
|
}
|
|
|
@@ -49,15 +57,15 @@ const CustomBotWithoutProxySettingsAccordion = (props) => {
|
|
|
<div
|
|
|
className="card-header font-weight-normal py-3 d-flex justify-content-between"
|
|
|
role="button"
|
|
|
- onClick={() => onToggleAccordionHandler(0)}
|
|
|
+ onClick={() => onToggleAccordionHandler(botInstallationStep.CREATE_BOT)}
|
|
|
>
|
|
|
<p className="mb-0 text-primary"><span className="mr-2">①</span>{t('slack_integration.without_proxy.create_bot')}</p>
|
|
|
- {openAccordionIndexes.has(0)
|
|
|
+ {openAccordionIndexes.has(botInstallationStep.CREATE_BOT)
|
|
|
? <i className="fa fa-chevron-up" />
|
|
|
: <i className="fa fa-chevron-down" />
|
|
|
}
|
|
|
</div>
|
|
|
- <Collapse isOpen={openAccordionIndexes.has(0)}>
|
|
|
+ <Collapse isOpen={openAccordionIndexes.has(botInstallationStep.CREATE_BOT)}>
|
|
|
<div className="card-body">
|
|
|
|
|
|
<div className="row my-5">
|
|
|
@@ -87,15 +95,15 @@ const CustomBotWithoutProxySettingsAccordion = (props) => {
|
|
|
<div
|
|
|
className="card-header font-weight-normal py-3 d-flex justify-content-between"
|
|
|
role="button"
|
|
|
- onClick={() => onToggleAccordionHandler(1)}
|
|
|
+ onClick={() => onToggleAccordionHandler(botInstallationStep.INSTALL_BOT)}
|
|
|
>
|
|
|
<p className="mb-0 text-primary"><span className="mr-2">②</span>{t('slack_integration.without_proxy.install_bot_to_slack')}</p>
|
|
|
- {openAccordionIndexes.has(1)
|
|
|
+ {openAccordionIndexes.has(botInstallationStep.INSTALL_BOT)
|
|
|
? <i className="fa fa-chevron-up" />
|
|
|
: <i className="fa fa-chevron-down" />
|
|
|
}
|
|
|
</div>
|
|
|
- <Collapse isOpen={openAccordionIndexes.has(1)}>
|
|
|
+ <Collapse isOpen={openAccordionIndexes.has(botInstallationStep.INSTALL_BOT)}>
|
|
|
<div className="card-body py-5">
|
|
|
<div className="container w-75">
|
|
|
<p>1. Install your app をクリックします。</p>
|
|
|
@@ -118,19 +126,20 @@ const CustomBotWithoutProxySettingsAccordion = (props) => {
|
|
|
<div
|
|
|
className="card-header font-weight-normal py-3 d-flex justify-content-between"
|
|
|
role="button"
|
|
|
- onClick={() => onToggleAccordionHandler(2)}
|
|
|
+ onClick={() => onToggleAccordionHandler(botInstallationStep.REGISTER_SLACK_CONFIGURATION)}
|
|
|
>
|
|
|
<p className="mb-0 text-primary">
|
|
|
<span className="mr-2">③</span>
|
|
|
{t('slack_integration.without_proxy.register_secret_and_token')}
|
|
|
{isRgisterSlackCredentials && <i className="ml-3 text-success fa fa-check"></i>}
|
|
|
</p>
|
|
|
- {openAccordionIndexes.has(2)
|
|
|
+
|
|
|
+ {openAccordionIndexes.has(botInstallationStep.REGISTER_SLACK_CONFIGURATION)
|
|
|
? <i className="fa fa-chevron-up" />
|
|
|
: <i className="fa fa-chevron-down" />
|
|
|
}
|
|
|
</div>
|
|
|
- <Collapse isOpen={openAccordionIndexes.has(2)}>
|
|
|
+ <Collapse isOpen={openAccordionIndexes.has(botInstallationStep.REGISTER_SLACK_CONFIGURATION)}>
|
|
|
<div className="card-body">
|
|
|
BODY 3
|
|
|
</div>
|
|
|
@@ -141,19 +150,18 @@ const CustomBotWithoutProxySettingsAccordion = (props) => {
|
|
|
<div
|
|
|
className="card-header font-weight-normal py-3 d-flex justify-content-between"
|
|
|
role="button"
|
|
|
- onClick={() => onToggleAccordionHandler(3)}
|
|
|
+ onClick={() => onToggleAccordionHandler(botInstallationStep.CONNECTION_TEST)}
|
|
|
>
|
|
|
- <p className="mb-0 text-primary">
|
|
|
- <span className="mr-2">④</span>
|
|
|
+ <p className="mb-0 text-primary"><span className="mr-2">④</span>
|
|
|
{t('slack_integration.without_proxy.test_connection')}
|
|
|
{isSendTestMessage && <i className="ml-3 text-success fa fa-check"></i>}
|
|
|
</p>
|
|
|
- {openAccordionIndexes.has(3)
|
|
|
+ {openAccordionIndexes.has(botInstallationStep.CONNECTION_TEST)
|
|
|
? <i className="fa fa-chevron-up" />
|
|
|
: <i className="fa fa-chevron-down" />
|
|
|
}
|
|
|
</div>
|
|
|
- <Collapse isOpen={openAccordionIndexes.has(3)}>
|
|
|
+ <Collapse isOpen={openAccordionIndexes.has(botInstallationStep.CONNECTION_TEST)}>
|
|
|
<div className="card-body">
|
|
|
<p className="text-center m-4">以下のテストボタンを押して、Slack連携が完了しているかの確認をしましょう</p>
|
|
|
<div className="d-flex justify-content-center">
|
|
|
@@ -185,6 +193,8 @@ CustomBotWithoutProxySettingsAccordion.propTypes = {
|
|
|
isRgisterSlackCredentials: PropTypes.bool,
|
|
|
isSendTestMessage: PropTypes.bool,
|
|
|
setIsSendTestMessage: PropTypes.func,
|
|
|
+
|
|
|
+ activeStep: PropTypes.oneOf(Object.values(botInstallationStep)).isRequired,
|
|
|
};
|
|
|
|
|
|
export default CustomBotWithoutProxySettingsAccordionWrapper;
|