|
|
@@ -1,9 +1,13 @@
|
|
|
import React, { useState } from 'react';
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
-import { Collapse } from 'reactstrap';
|
|
|
+import { Collapse, Button } from 'reactstrap';
|
|
|
|
|
|
import NavigationContainer from '../../services/NavigationContainer';
|
|
|
+import EditorContainer from '../../services/EditorContainer';
|
|
|
+import AppContainer from '../../services/AppContainer';
|
|
|
+import SlackNotification from '../SlackNotification';
|
|
|
+import SlackLogo from '../SlackLogo';
|
|
|
import { withUnstatedContainers } from '../UnstatedUtils';
|
|
|
|
|
|
import SavePageControls from '../SavePageControls';
|
|
|
@@ -14,6 +18,9 @@ const EditorNavbarBottom = (props) => {
|
|
|
|
|
|
const [isExpanded, setExpanded] = useState(false);
|
|
|
|
|
|
+ const [isSlackExpanded, setSlackExpanded] = useState(false);
|
|
|
+ const hasSlackConfig = props.appContainer.getConfig().hasSlackConfig;
|
|
|
+
|
|
|
const {
|
|
|
navigationContainer,
|
|
|
} = props;
|
|
|
@@ -27,6 +34,14 @@ const EditorNavbarBottom = (props) => {
|
|
|
</button>
|
|
|
);
|
|
|
|
|
|
+ const slackEnabledFlagChangedHandler = (isSlackEnabled) => {
|
|
|
+ props.editorContainer.setState({ isSlackEnabled });
|
|
|
+ };
|
|
|
+
|
|
|
+ const slackChannelsChangedHandler = (slackChannels) => {
|
|
|
+ props.editorContainer.setState({ slackChannels });
|
|
|
+ };
|
|
|
+
|
|
|
// eslint-disable-next-line react/prop-types
|
|
|
const renderExpandButton = () => (
|
|
|
<div className="d-md-none ml-2">
|
|
|
@@ -45,12 +60,51 @@ const EditorNavbarBottom = (props) => {
|
|
|
|
|
|
return (
|
|
|
<div className={`${isCollapsedOptionsSelectorEnabled ? 'fixed-bottom' : ''} `}>
|
|
|
+ {/* Collapsed SlackNotification */}
|
|
|
+ {hasSlackConfig && (
|
|
|
+ <Collapse isOpen={isSlackExpanded && isDeviceSmallerThanMd}>
|
|
|
+ <nav className={`navbar navbar-expand-lg border-top ${additionalClasses.join(' ')}`}>
|
|
|
+ <SlackNotification
|
|
|
+ isSlackEnabled={props.editorContainer.state.isSlackEnabled}
|
|
|
+ slackChannels={props.editorContainer.state.slackChannels}
|
|
|
+ onEnabledFlagChange={slackEnabledFlagChangedHandler}
|
|
|
+ onChannelChange={slackChannelsChangedHandler}
|
|
|
+ id="idForEditorNavbarBottomForMobile"
|
|
|
+ popUp
|
|
|
+ />
|
|
|
+ </nav>
|
|
|
+ </Collapse>
|
|
|
+ )
|
|
|
+ }
|
|
|
<div className={`navbar navbar-expand border-top px-2 ${additionalClasses.join(' ')}`}>
|
|
|
<form className="form-inline">
|
|
|
{ isDrawerMode && renderDrawerButton() }
|
|
|
{ isOptionsSelectorEnabled && !isDeviceSmallerThanMd && <OptionsSelector /> }
|
|
|
</form>
|
|
|
<form className="form-inline ml-auto">
|
|
|
+ {/* Responsive Design for the SlackNotification */}
|
|
|
+ {/* Button or the normal Slack banner */}
|
|
|
+ {hasSlackConfig && (isDeviceSmallerThanMd ? (
|
|
|
+ <Button
|
|
|
+ color="white"
|
|
|
+ className="border mr-2"
|
|
|
+ onClick={() => (setSlackExpanded(!isSlackExpanded))}
|
|
|
+ >
|
|
|
+ <SlackLogo />
|
|
|
+ <span className="fa fa-caret-up ml-2"></span>
|
|
|
+ </Button>
|
|
|
+ ) : (
|
|
|
+ <div className="mr-2">
|
|
|
+ <SlackNotification
|
|
|
+ isSlackEnabled={props.editorContainer.state.isSlackEnabled}
|
|
|
+ slackChannels={props.editorContainer.state.slackChannels}
|
|
|
+ onEnabledFlagChange={slackEnabledFlagChangedHandler}
|
|
|
+ onChannelChange={slackChannelsChangedHandler}
|
|
|
+ id="idForEditorNavbarBottom"
|
|
|
+ popUp={false}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ ))}
|
|
|
<SavePageControls />
|
|
|
{ isCollapsedOptionsSelectorEnabled && renderExpandButton() }
|
|
|
</form>
|
|
|
@@ -73,6 +127,8 @@ const EditorNavbarBottom = (props) => {
|
|
|
|
|
|
EditorNavbarBottom.propTypes = {
|
|
|
navigationContainer: PropTypes.instanceOf(NavigationContainer).isRequired,
|
|
|
+ appContainer: PropTypes.instanceOf(AppContainer).isRequired,
|
|
|
+ editorContainer: PropTypes.instanceOf(EditorContainer).isRequired,
|
|
|
};
|
|
|
|
|
|
-export default withUnstatedContainers(EditorNavbarBottom, [NavigationContainer]);
|
|
|
+export default withUnstatedContainers(EditorNavbarBottom, [NavigationContainer, EditorContainer, AppContainer]);
|