Browse Source

FB by Takeisan

白石誠 5 years ago
parent
commit
fa9ecffed3

+ 1 - 2
src/client/js/components/PageAccessoriesModal.jsx

@@ -84,8 +84,7 @@ const PageAccessoriesModal = (props) => {
             </TabPane>
             </TabPane>
             <TabPane tabId="timeline" className="p-4">
             <TabPane tabId="timeline" className="p-4">
               {
               {
-                pageAccessoriesContainer.state.activeComponents.has('timeline')
-                && <PageTimeline pages={JSON.parse(document.getElementById('page-timeline-data').text)} />
+                pageAccessoriesContainer.state.activeComponents.has('timeline') && <PageTimeline fromModal />
               }
               }
             </TabPane>
             </TabPane>
             <TabPane tabId="page-history">
             <TabPane tabId="page-history">

+ 17 - 5
src/client/js/components/PageTimeline.jsx

@@ -4,6 +4,7 @@ import PropTypes from 'prop-types';
 import { withTranslation } from 'react-i18next';
 import { withTranslation } from 'react-i18next';
 
 
 import AppContainer from '../services/AppContainer';
 import AppContainer from '../services/AppContainer';
+import PageContainer from '../services/PageContainer';
 import { withUnstatedContainers } from './UnstatedUtils';
 import { withUnstatedContainers } from './UnstatedUtils';
 
 
 import RevisionLoader from './Page/RevisionLoader';
 import RevisionLoader from './Page/RevisionLoader';
@@ -30,13 +31,22 @@ class PageTimeline extends React.Component {
     if (!this.state.isEnabled) {
     if (!this.state.isEnabled) {
       return;
       return;
     }
     }
-
-    const { appContainer } = this.props;
+    const { appContainer, pageContainer } = this.props;
 
 
     // initialize GrowiRenderer
     // initialize GrowiRenderer
     this.growiRenderer = appContainer.getRenderer('timeline');
     this.growiRenderer = appContainer.getRenderer('timeline');
-
-    this.initBsTab();
+    if (this.props.fromModal) {
+      const { path } = pageContainer.state;
+      appContainer.apiv3Get('/pages/list', { path })
+        .then((res) => {
+          this.setState({
+            pages: res.data.pages,
+          });
+        });
+    }
+    else {
+      this.initBsTab();
+    }
   }
   }
 
 
   /**
   /**
@@ -114,12 +124,14 @@ class PageTimeline extends React.Component {
 PageTimeline.propTypes = {
 PageTimeline.propTypes = {
   t: PropTypes.func.isRequired, // i18next
   t: PropTypes.func.isRequired, // i18next
   appContainer: PropTypes.instanceOf(AppContainer).isRequired,
   appContainer: PropTypes.instanceOf(AppContainer).isRequired,
+  pageContainer: PropTypes.instanceOf(PageContainer).isRequired,
   pages: PropTypes.arrayOf(PropTypes.object),
   pages: PropTypes.arrayOf(PropTypes.object),
+  fromModal: PropTypes.bool,
 };
 };
 
 
 /**
 /**
  * Wrapper component for using unstated
  * Wrapper component for using unstated
  */
  */
-const PageTimelineWrapper = withUnstatedContainers(PageTimeline, [AppContainer]);
+const PageTimelineWrapper = withUnstatedContainers(PageTimeline, [AppContainer, PageContainer]);
 
 
 export default withTranslation()(PageTimelineWrapper);
 export default withTranslation()(PageTimelineWrapper);