itizawa 5 лет назад
Родитель
Сommit
362f7a2074

+ 5 - 1
src/client/js/components/Navbar/GrowiSubNavigation.jsx

@@ -153,6 +153,10 @@ const GrowiSubNavigation = (props) => {
     );
     );
   }
   }
 
 
+  function onThreeStrandedButtonClicked(viewType) {
+    navigationContainer.setEditorMode(viewType);
+  }
+
   return (
   return (
     <div className={`grw-subnav d-flex align-items-center justify-content-between ${isCompactMode ? 'grw-subnav-compact d-print-none' : ''}`}>
     <div className={`grw-subnav d-flex align-items-center justify-content-between ${isCompactMode ? 'grw-subnav-compact d-print-none' : ''}`}>
 
 
@@ -194,7 +198,7 @@ const GrowiSubNavigation = (props) => {
             { !isPageInTrash && <PageReactionButtons appContainer={appContainer} pageContainer={pageContainer} /> }
             { !isPageInTrash && <PageReactionButtons appContainer={appContainer} pageContainer={pageContainer} /> }
           </div>
           </div>
           <div className="mt-2">
           <div className="mt-2">
-            <ThreeStrandedButton />
+            <ThreeStrandedButton onThreeStrandedButtonClicked={onThreeStrandedButtonClicked} />
           </div>
           </div>
         </div>
         </div>
 
 

+ 5 - 12
src/client/js/components/Navbar/ThreeStrandedButton.jsx

@@ -1,15 +1,14 @@
 import React from 'react';
 import React from 'react';
 import PropTypes from 'prop-types';
 import PropTypes from 'prop-types';
 import { withTranslation } from 'react-i18next';
 import { withTranslation } from 'react-i18next';
-import { withUnstatedContainers } from '../UnstatedUtils';
-
-import NavigationContainer from '../../services/NavigationContainer';
 
 
 const ThreeStrandedButton = (props) => {
 const ThreeStrandedButton = (props) => {
-  const { t, navigationContainer } = props;
+  const { t } = props;
 
 
   function threeStrandedButtonClickedHandler(viewType) {
   function threeStrandedButtonClickedHandler(viewType) {
-    navigationContainer.setEditorMode(viewType);
+    if (props.onThreeStrandedButtonClicked != null) {
+      props.onThreeStrandedButtonClicked(viewType);
+    }
   }
   }
 
 
   return (
   return (
@@ -31,16 +30,10 @@ const ThreeStrandedButton = (props) => {
 
 
 };
 };
 
 
-/**
- * Wrapper component for using unstated
- */
-const ThreeStrandedButtonWrapper = withUnstatedContainers(ThreeStrandedButton, [NavigationContainer]);
-
 ThreeStrandedButton.propTypes = {
 ThreeStrandedButton.propTypes = {
   t: PropTypes.func.isRequired, //  i18next
   t: PropTypes.func.isRequired, //  i18next
 
 
-  navigationContainer: PropTypes.object.isRequired,
   onThreeStrandedButtonClicked: PropTypes.func,
   onThreeStrandedButtonClicked: PropTypes.func,
 };
 };
 
 
-export default withTranslation()(ThreeStrandedButtonWrapper);
+export default withTranslation()(ThreeStrandedButton);

+ 1 - 1
src/client/js/services/NavigationContainer.js

@@ -19,7 +19,7 @@ export default class NavigationContainer extends Container {
     const { localStorage } = window;
     const { localStorage } = window;
 
 
     this.state = {
     this.state = {
-      editorMode: null,
+      editorMode: 'view',
 
 
       isDeviceSmallerThanMd: null,
       isDeviceSmallerThanMd: null,
       preferDrawerModeByUser: localStorage.preferDrawerModeByUser === 'true',
       preferDrawerModeByUser: localStorage.preferDrawerModeByUser === 'true',