import React from 'react'; import PropTypes from 'prop-types'; import { withTranslation } from 'react-i18next'; import { TabContent, TabPane, Nav, NavItem, NavLink, } from 'reactstrap'; import { withUnstatedContainers } from '../../UnstatedUtils'; import AppContainer from '../../../services/AppContainer'; import AdminNotificationContainer from '../../../services/AdminNotificationContainer'; import SlackAppConfiguration from './SlackAppConfiguration'; import UserTriggerNotification from './UserTriggerNotification'; import GlobalNotification from './GlobalNotification'; class NotificationSettingContents extends React.Component { constructor(props) { super(props); this.state = { activeTab: 'slack-configuration', // Prevent unnecessary rendering activeComponents: new Set(['slack-configuration']), }; this.toggleActiveTab = this.toggleActiveTab.bind(this); } toggleActiveTab(activeTab) { this.setState({ activeTab, activeComponents: this.state.activeComponents.add(activeTab), }); } render() { const { activeTab, activeComponents } = this.state; return ( {activeComponents.has('slack-configuration') && } {activeComponents.has('user-trigger-notification') && } {activeComponents.has('global-notification') && } ); } } const NotificationSettingContentsWrapper = withUnstatedContainers(NotificationSettingContents, [AppContainer, AdminNotificationContainer]); NotificationSettingContents.propTypes = { t: PropTypes.func.isRequired, // i18next appContainer: PropTypes.instanceOf(AppContainer).isRequired, adminNotificationContainer: PropTypes.instanceOf(AdminNotificationContainer).isRequired, }; export default withTranslation()(NotificationSettingContentsWrapper);