import React from 'react'; import PropTypes from 'prop-types'; import { withTranslation } from 'react-i18next'; import AppContainer from '~/client/services/AppContainer'; import PageContainer from '~/client/services/PageContainer'; import PaginationWrapper from './PaginationWrapper'; import { withUnstatedContainers } from './UnstatedUtils'; import RevisionLoader from './Page/RevisionLoader'; class PageTimeline extends React.Component { constructor(props) { super(props); this.state = { activePage: 1, totalPageItems: 0, limit: null, // TODO: remove after when timeline is implemented with React and inject data with props pages: this.props.pages, }; this.handlePage = this.handlePage.bind(this); } async handlePage(selectedPage) { const { appContainer, pageContainer } = this.props; const { path } = pageContainer.state; const page = selectedPage; const res = await appContainer.apiv3Get('/pages/list', { path, page }); const totalPageItems = res.data.totalCount; const pages = res.data.pages; const pagingLimit = res.data.limit; this.setState({ activePage: selectedPage, totalPageItems, pages, limit: pagingLimit, }); } componentWillMount() { const { appContainer } = this.props; // initialize GrowiRenderer this.growiRenderer = appContainer.getRenderer('timeline'); } async componentDidMount() { await this.handlePage(1); this.setState({ activePage: 1, }); } render() { const { t } = this.props; const { pages } = this.state; if (pages == null || pages.length === 0) { return (
{t('custom_navigation.no_page_list')}