Browse Source

FB by Takeisan

白石誠 5 years ago
parent
commit
862619f266

+ 1 - 1
src/client/js/app.jsx

@@ -74,7 +74,7 @@ Object.assign(componentMappings, {
 
 
   'trash-page-alert': <TrashPageAlert />,
   'trash-page-alert': <TrashPageAlert />,
 
 
-  'not-found-alert': <NotFoundAlert />,
+  'not-found-alert': <NotFoundAlert onPageCreateClicked={navigationContainer.setEditorMode} />,
 
 
   'page-timeline': <PageTimeline />,
   'page-timeline': <PageTimeline />,
 
 

+ 25 - 50
src/client/js/components/Page/NotFoundAlert.jsx

@@ -1,68 +1,43 @@
 import React from 'react';
 import React from 'react';
 import PropTypes from 'prop-types';
 import PropTypes from 'prop-types';
-import NavigationContainer from '../../services/NavigationContainer';
-import { withUnstatedContainers } from '../UnstatedUtils';
-import Editor from '../PageEditor';
-import EditorNavbarBottom from '../PageEditor/EditorNavbarBottom';
 
 
 const NotFoundAlert = (props) => {
 const NotFoundAlert = (props) => {
-  const { navigationContainer } = props;
-  const { editorMode } = navigationContainer.state;
 
 
-  function clickHandler() {
-    navigationContainer.setEditorMode('edit');
-  }
-
-  function renderNotFound() {
-    if (editorMode === 'view') {
-      return (
-        <div className="grw-not-found-alert border m-4 p-4">
-          <div className="col-md-12">
-            <h2 className="text-muted not-found-text">
-              <i className="icon-info" aria-hidden="true"></i>
-              {/* Todo make the message supported by i18n GW4050 */ }
-              このページは存在しません。新たに作成する必要があります。
-            </h2>
-            <button
-              type="button"
-              className="m-2 p-2"
-              onClick={clickHandler}
-            >
-              <i className="icon-note icon-fw" />
-              {/* Todo make the message supported by i18n GW4050 */ }
-              ページを作成する
-            </button>
-          </div>
-        </div>
-      );
+  function clickHandler(viewType) {
+    if (props.onPageCreateClicked) {
+      props.onPageCreateClicked(viewType);
+    }
+    else {
+      return null;
     }
     }
-    return (
-      <div id="page-editor">
-        <Editor />
-        <EditorNavbarBottom />
-      </div>
-    );
-
   }
   }
 
 
-
   return (
   return (
-    <div>
-      { renderNotFound() }
+    <div className="grw-not-found-alert border m-4 p-4">
+      <div className="col-md-12">
+        <h2 className="text-muted not-found-text">
+          <i className="icon-info" aria-hidden="true"></i>
+          {/* Todo make the message supported by i18n GW4050 */ }
+          このページは存在しません。新たに作成する必要があります。
+        </h2>
+        <button
+          type="button"
+          className="m-2 p-2"
+          onClick={() => { clickHandler('edit') }}
+        >
+          <i className="icon-note icon-fw" />
+          {/* Todo make the message supported by i18n GW4050 */ }
+          ページを作成する
+        </button>
+      </div>
     </div>
     </div>
   );
   );
 };
 };
 
 
 
 
-/**
- * Wrapper component for using unstated
- */
-const NotFoundAlertWrapper = withUnstatedContainers(NotFoundAlert, [NavigationContainer]);
-
-
 NotFoundAlert.propTypes = {
 NotFoundAlert.propTypes = {
-  navigationContainer: PropTypes.instanceOf(NavigationContainer).isRequired,
+  onPageCreateClicked: PropTypes.func,
 };
 };
 
 
 
 
-export default NotFoundAlertWrapper;
+export default NotFoundAlert;

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

@@ -37,6 +37,7 @@ export default class NavigationContainer extends Container {
 
 
     this.openPageCreateModal = this.openPageCreateModal.bind(this);
     this.openPageCreateModal = this.openPageCreateModal.bind(this);
     this.closePageCreateModal = this.closePageCreateModal.bind(this);
     this.closePageCreateModal = this.closePageCreateModal.bind(this);
+    this.setEditorMode = this.setEditorMode.bind(this);
     this.initDeviceSize();
     this.initDeviceSize();
     this.initScrollEvent();
     this.initScrollEvent();
   }
   }

+ 3 - 0
src/server/views/widget/not_found_content.html

@@ -6,6 +6,9 @@
   {% endif %}
   {% endif %}
   >
   >
 
 
+  <div id="display-switcher">
+    <script type="text/template" id="raw-text-original">{{ revision.body.toString() | encodeHTML }}</script>
+  </div>
   <div id="not-found-alert"></div>
   <div id="not-found-alert"></div>
   {% include 'not_found_tabs.html' %}
   {% include 'not_found_tabs.html' %}