DuplicatedPathsTable.tsx 1.4 KB

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