import React from 'react'; import PropTypes from 'prop-types'; import { withTranslation } from 'react-i18next'; import loggerFactory from '@alias/logger'; import DevidedPagePath from '@commons/models/devided-page-path'; import LinkedPagePath from '@commons/models/linked-page-path'; import PagePathHierarchicalLink from '@commons/components/PagePathHierarchicalLink'; import FootstampIcon from '../FootstampIcon'; import { withUnstatedContainers } from '../UnstatedUtils'; import AppContainer from '../../services/AppContainer'; import { toastError } from '../../util/apiNotification'; import FormattedDistanceDate from '../FormattedDistanceDate'; import UserPicture from '../User/UserPicture'; const logger = loggerFactory('growi:History'); class RecentChanges extends React.Component { static propTypes = { t: PropTypes.func.isRequired, // i18next appContainer: PropTypes.instanceOf(AppContainer).isRequired, }; constructor(props) { super(props); this.reloadData = this.reloadData.bind(this); } async componentDidMount() { this.reloadData(); } async reloadData() { const { appContainer } = this.props; try { await appContainer.retrieveRecentlyUpdated(); } catch (error) { logger.error('failed to save', error); toastError(error, 'Error occurred in updating History'); } } PageItem = ({ page }) => { const dPagePath = new DevidedPagePath(page.path, false, true); const linkedPagePathFormer = new LinkedPagePath(dPagePath.former); const linkedPagePathLatter = new LinkedPagePath(dPagePath.latter); const FormerLink = () => (
); let locked; if (page.grant !== 1) { locked = ; } const tags = page.tags; const tagElements = tags.map((tag) => { return ( {tag.name} ); }); return (
  • { !dPagePath.isRoot && }
    {locked}
    {page.seenUsers.length} {page.commentCount} { tagElements }
  • ); } render() { const { PageItem } = this; const { t } = this.props; const { recentlyUpdatedPages } = this.props.appContainer.state; return ( <>

    {t('Recent Changes')}

    {/*

    {t('Recent Created')}

    */} {/* TODO: impl switching */}
    ); } } /** * Wrapper component for using unstated */ const RecentChangesWrapper = withUnstatedContainers(RecentChanges, [AppContainer]); export default withTranslation()(RecentChangesWrapper);