RevisionUrl.js 781 B

12345678910111213141516171819202122232425262728293031
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import CopyButton from '../CopyButton';
  4. export default class RevisionUrl extends React.Component {
  5. render() {
  6. const buttonStyle = {
  7. fontSize: '1em'
  8. };
  9. const url = (this.props.pageId == null)
  10. ? decodeURIComponent(location.href)
  11. : `${location.origin}/${this.props.pageId}`;
  12. const copiedText = this.props.pagePath + '\n' + url;
  13. return (
  14. <span>
  15. {url}
  16. <CopyButton buttonId="btnCopyRevisionUrl" text={copiedText}
  17. buttonClassName="btn btn-default btn-copy-link" buttonStyle={buttonStyle} iconClassName="ti-clipboard" />
  18. </span>
  19. );
  20. }
  21. }
  22. RevisionUrl.propTypes = {
  23. pageId: PropTypes.string,
  24. pagePath: PropTypes.string.isRequired,
  25. };