|
|
@@ -4,6 +4,7 @@ import loggerFactory from '@alias/logger';
|
|
|
|
|
|
import StickyEvents from 'sticky-events';
|
|
|
|
|
|
+import AppContainer from '../services/AppContainer';
|
|
|
import NavigationContainer from '../services/NavigationContainer';
|
|
|
import { withUnstatedContainers } from './UnstatedUtils';
|
|
|
import CreatePageIcon from './Icons/CreatePageIcon';
|
|
|
@@ -12,7 +13,8 @@ import ReturnTopIcon from './Icons/ReturnTopIcon';
|
|
|
const logger = loggerFactory('growi:cli:Fab');
|
|
|
|
|
|
const Fab = (props) => {
|
|
|
- const { navigationContainer } = props;
|
|
|
+ const { navigationContainer, appContainer } = props;
|
|
|
+ const { currentUser } = appContainer;
|
|
|
|
|
|
const [animateClasses, setAnimateClasses] = useState('invisible');
|
|
|
|
|
|
@@ -39,18 +41,25 @@ const Fab = (props) => {
|
|
|
};
|
|
|
}, [stickyChangeHandler]);
|
|
|
|
|
|
+ function renderPageCreateButton() {
|
|
|
+ return (
|
|
|
+ <>
|
|
|
+ <div className={`rounded-circle position-absolute ${animateClasses}`} style={{ bottom: '2.3rem', right: '4rem' }}>
|
|
|
+ <button
|
|
|
+ type="button"
|
|
|
+ className="btn btn-lg btn-create-page btn-primary rounded-circle p-0 waves-effect waves-light"
|
|
|
+ onClick={navigationContainer.openPageCreateModal}
|
|
|
+ >
|
|
|
+ <CreatePageIcon />
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ </>
|
|
|
+ );
|
|
|
+ }
|
|
|
|
|
|
return (
|
|
|
<div className="grw-fab d-none d-md-block">
|
|
|
- <div className={`rounded-circle position-absolute ${animateClasses}`} style={{ bottom: '2.3rem', right: '4rem' }}>
|
|
|
- <button
|
|
|
- type="button"
|
|
|
- className="btn btn-lg btn-create-page btn-primary rounded-circle p-0 waves-effect waves-light"
|
|
|
- onClick={navigationContainer.openPageCreateModal}
|
|
|
- >
|
|
|
- <CreatePageIcon />
|
|
|
- </button>
|
|
|
- </div>
|
|
|
+ {currentUser != null && renderPageCreateButton()}
|
|
|
<div className={`rounded-circle position-absolute ${animateClasses}`} style={{ bottom: 0, right: 0 }}>
|
|
|
<button type="button" className="btn btn-light btn-scroll-to-top rounded-circle p-0" onClick={() => navigationContainer.smoothScrollIntoView()}>
|
|
|
<ReturnTopIcon />
|
|
|
@@ -62,7 +71,8 @@ const Fab = (props) => {
|
|
|
};
|
|
|
|
|
|
Fab.propTypes = {
|
|
|
+ appContainer: PropTypes.instanceOf(AppContainer).isRequired,
|
|
|
navigationContainer: PropTypes.instanceOf(NavigationContainer).isRequired,
|
|
|
};
|
|
|
|
|
|
-export default withUnstatedContainers(Fab, [NavigationContainer]);
|
|
|
+export default withUnstatedContainers(Fab, [AppContainer, NavigationContainer]);
|