ComparePathsTable.jsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import { withTranslation } from 'react-i18next';
  4. import { pagePathUtils } from '@growi/core';
  5. const { convertToNewAffiliationPath } = pagePathUtils;
  6. function ComparePathsTable(props) {
  7. const {
  8. path, subordinatedPages, newPagePath, t,
  9. } = props;
  10. return (
  11. <table className="table table-bordered grw-compare-paths-table">
  12. <thead>
  13. <tr className="d-flex">
  14. <th className="w-50">{t('original_path')}</th>
  15. <th className="w-50">{t('new_path')}</th>
  16. </tr>
  17. </thead>
  18. <tbody className="overflow-auto d-block">
  19. {subordinatedPages.map((subordinatedPage) => {
  20. const convertedPath = convertToNewAffiliationPath(path, newPagePath, subordinatedPage.path);
  21. return (
  22. <tr key={subordinatedPage._id} className="d-flex">
  23. <td className="text-break w-50">
  24. <a href={subordinatedPage.path}>
  25. {subordinatedPage.path}
  26. </a>
  27. </td>
  28. <td className="text-break w-50">
  29. {convertedPath}
  30. </td>
  31. </tr>
  32. );
  33. })}
  34. </tbody>
  35. </table>
  36. );
  37. }
  38. ComparePathsTable.propTypes = {
  39. t: PropTypes.func.isRequired, // i18next
  40. path: PropTypes.string.isRequired,
  41. subordinatedPages: PropTypes.array.isRequired,
  42. newPagePath: PropTypes.string.isRequired,
  43. };
  44. export default withTranslation()(ComparePathsTable);