DuplicatedPathsTable.jsx 1.4 KB

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