RevisionPathControls.jsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import { withTranslation } from 'react-i18next';
  4. import { isTrashPage } from '@commons/util/path-utils';
  5. import CopyDropdown from './CopyDropdown';
  6. const RevisionPathControls = (props) => {
  7. // define styles
  8. const buttonStyle = {
  9. marginLeft: '0.5em',
  10. padding: '0 2px',
  11. };
  12. const {
  13. pagePath, pageId, isPageForbidden,
  14. } = props;
  15. const isPageInTrash = isTrashPage(pagePath);
  16. return (
  17. <>
  18. <CopyDropdown pagePath={pagePath} pageId={pageId} buttonStyle={buttonStyle} />
  19. { !isPageInTrash && !isPageForbidden && (
  20. <a href="#edit" className="d-edit-none text-muted btn btn-secondary bg-transparent btn-edit border-0" style={buttonStyle}>
  21. <i className="icon-note" />
  22. </a>
  23. ) }
  24. </>
  25. );
  26. };
  27. RevisionPathControls.propTypes = {
  28. t: PropTypes.func.isRequired, // i18next
  29. pagePath: PropTypes.string.isRequired,
  30. pageId: PropTypes.string,
  31. isPageForbidden: PropTypes.bool,
  32. };
  33. RevisionPathControls.defaultProps = {
  34. isPageForbidden: false,
  35. };
  36. export default withTranslation()(RevisionPathControls);