import React from 'react'; import PropTypes from 'prop-types'; import { translate } from 'react-i18next'; /** * * @author Yuki Takei * * @export * @class PageStatusAlert * @extends {React.Component} */ class PageStatusAlert extends React.Component { constructor(props) { super(props); this.state = { revisionId: this.props.revisionId, latestRevisionId: this.props.revisionId, lastUpdateUsername: undefined, }; } initRevisionId(revisionId) { this.setState({ revisionId, latestRevisionId: revisionId, }); } setLatestRevisionId(revisionId) { this.setState({latestRevisionId: revisionId}); } setLastUpdateUsername(lastUpdateUsername) { this.setState({lastUpdateUsername}); } render() { const { t } = this.props; const label1 = t('edited this page'); const label2 = t('Load latest'); const isShown = this.state.revisionId !== this.state.latestRevisionId; const style = { display: isShown ? 'block' : 'none' }; return (
{this.state.lastUpdateUsername} {label1}  {label2}
); } } PageStatusAlert.propTypes = { t: PropTypes.func.isRequired, // i18next crowi: PropTypes.object.isRequired, revisionId: PropTypes.string, latestRevisionId: PropTypes.string, }; PageStatusAlert.defaultProps = { }; export default translate()(PageStatusAlert);