|
@@ -1,8 +1,9 @@
|
|
|
-import React, { useMemo } from 'react';
|
|
|
|
|
|
|
+import React, { useMemo, useState } from 'react';
|
|
|
import PropTypes from 'prop-types';
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
import loggerFactory from '@alias/logger';
|
|
import loggerFactory from '@alias/logger';
|
|
|
|
|
|
|
|
|
|
+import { TabContent, TabPane } from 'reactstrap';
|
|
|
import { withUnstatedContainers } from '../../UnstatedUtils';
|
|
import { withUnstatedContainers } from '../../UnstatedUtils';
|
|
|
import { toastError } from '../../../util/apiNotification';
|
|
import { toastError } from '../../../util/apiNotification';
|
|
|
import toArrayIfNot from '../../../../../lib/util/toArrayIfNot';
|
|
import toArrayIfNot from '../../../../../lib/util/toArrayIfNot';
|
|
@@ -10,7 +11,7 @@ import { withLoadingSppiner } from '../../SuspenseUtils';
|
|
|
|
|
|
|
|
import AdminNotificationContainer from '../../../services/AdminNotificationContainer';
|
|
import AdminNotificationContainer from '../../../services/AdminNotificationContainer';
|
|
|
|
|
|
|
|
-import CustomNavigation from '../../CustomNavigation';
|
|
|
|
|
|
|
+import { CustomNav } from '../../CustomNavigation';
|
|
|
|
|
|
|
|
import SlackAppConfiguration from './SlackAppConfiguration';
|
|
import SlackAppConfiguration from './SlackAppConfiguration';
|
|
|
import UserTriggerNotification from './UserTriggerNotification';
|
|
import UserTriggerNotification from './UserTriggerNotification';
|
|
@@ -21,6 +22,15 @@ const logger = loggerFactory('growi:NotificationSetting');
|
|
|
let retrieveErrors = null;
|
|
let retrieveErrors = null;
|
|
|
function NotificationSetting(props) {
|
|
function NotificationSetting(props) {
|
|
|
const { adminNotificationContainer } = props;
|
|
const { adminNotificationContainer } = props;
|
|
|
|
|
+
|
|
|
|
|
+ const [activeTab, setActiveTab] = useState('slack_configuration');
|
|
|
|
|
+ const [activeComponents, setActiveComponents] = useState(new Set(['slack_configuration']));
|
|
|
|
|
+
|
|
|
|
|
+ const switchActiveTab = (selectedTab) => {
|
|
|
|
|
+ setActiveTab(selectedTab);
|
|
|
|
|
+ setActiveComponents(activeComponents.add(selectedTab));
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
if (adminNotificationContainer.state.webhookUrl === adminNotificationContainer.dummyWebhookUrl) {
|
|
if (adminNotificationContainer.state.webhookUrl === adminNotificationContainer.dummyWebhookUrl) {
|
|
|
throw (async() => {
|
|
throw (async() => {
|
|
|
try {
|
|
try {
|
|
@@ -44,26 +54,39 @@ function NotificationSetting(props) {
|
|
|
return {
|
|
return {
|
|
|
slack_configuration: {
|
|
slack_configuration: {
|
|
|
Icon: () => <i className="icon-settings" />,
|
|
Icon: () => <i className="icon-settings" />,
|
|
|
- Content: SlackAppConfiguration,
|
|
|
|
|
i18n: 'Slack configuration',
|
|
i18n: 'Slack configuration',
|
|
|
index: 0,
|
|
index: 0,
|
|
|
},
|
|
},
|
|
|
user_trigger_notification: {
|
|
user_trigger_notification: {
|
|
|
Icon: () => <i className="icon-settings" />,
|
|
Icon: () => <i className="icon-settings" />,
|
|
|
- Content: UserTriggerNotification,
|
|
|
|
|
i18n: 'User trigger notification',
|
|
i18n: 'User trigger notification',
|
|
|
index: 1,
|
|
index: 1,
|
|
|
},
|
|
},
|
|
|
global_notification: {
|
|
global_notification: {
|
|
|
Icon: () => <i className="icon-settings" />,
|
|
Icon: () => <i className="icon-settings" />,
|
|
|
- Content: GlobalNotification,
|
|
|
|
|
i18n: 'Global notification',
|
|
i18n: 'Global notification',
|
|
|
index: 2,
|
|
index: 2,
|
|
|
},
|
|
},
|
|
|
};
|
|
};
|
|
|
}, []);
|
|
}, []);
|
|
|
|
|
|
|
|
- return <CustomNavigation navTabMapping={navTabMapping} />;
|
|
|
|
|
|
|
+ return (
|
|
|
|
|
+ <>
|
|
|
|
|
+ <CustomNav activeTab={activeTab} navTabMapping={navTabMapping} onNavSelected={switchActiveTab} hideBorderBottom />
|
|
|
|
|
+
|
|
|
|
|
+ <TabContent activeTab={activeTab} className="p-5">
|
|
|
|
|
+ <TabPane tabId="slack_configuration">
|
|
|
|
|
+ {activeComponents.has('slack_configuration') && <SlackAppConfiguration />}
|
|
|
|
|
+ </TabPane>
|
|
|
|
|
+ <TabPane tabId="user_trigger_notification">
|
|
|
|
|
+ {activeComponents.has('user_trigger_notification') && <UserTriggerNotification />}
|
|
|
|
|
+ </TabPane>
|
|
|
|
|
+ <TabPane tabId="global_notification">
|
|
|
|
|
+ {activeComponents.has('global_notification') && <GlobalNotification />}
|
|
|
|
|
+ </TabPane>
|
|
|
|
|
+ </TabContent>
|
|
|
|
|
+ </>
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const NotificationSettingWithUnstatedContainer = withUnstatedContainers(withLoadingSppiner(NotificationSetting), [AdminNotificationContainer]);
|
|
const NotificationSettingWithUnstatedContainer = withUnstatedContainers(withLoadingSppiner(NotificationSetting), [AdminNotificationContainer]);
|