RevisionUrl.js 931 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. showToolTip() {
  6. $('#btnCopy').tooltip('show');
  7. setTimeout(() => {
  8. $('#btnCopy').tooltip('hide');
  9. }, 1000);
  10. }
  11. render() {
  12. const buttonStyle = {
  13. fontSize: "1em"
  14. }
  15. const url = (this.props.pageId === '')
  16. ? decodeURIComponent(location.href)
  17. : `${location.origin}/${this.props.pageId}`;
  18. const copiedText = this.props.pagePath + '\n' + url;
  19. return (
  20. <span>
  21. {url}
  22. <CopyButton buttonId="btnCopyRevisionUrl" text={copiedText}
  23. buttonClassName="btn btn-default btn-muted" buttonStyle={buttonStyle} iconClassName="fa fa-link text-muted" />
  24. </span>
  25. );
  26. }
  27. }
  28. RevisionUrl.propTypes = {
  29. pageId: PropTypes.string.isRequired,
  30. pagePath: PropTypes.string.isRequired,
  31. };