RevisionUrl.js 896 B

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