SimpleItemContent.tsx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import nodePath from 'path';
  2. import { useTranslation } from 'next-i18next';
  3. import { UncontrolledTooltip } from 'reactstrap';
  4. import type { IPageForItem } from '~/interfaces/page';
  5. import { shouldRecoverPagePaths } from '~/utils/page-operation';
  6. import styles from './SimpleItemContent.module.scss';
  7. const moduleClass = styles['simple-item-content'] ?? '';
  8. export const SimpleItemContent = ({ page }: { page: IPageForItem }): JSX.Element => {
  9. const { t } = useTranslation();
  10. const pageName = nodePath.basename(page.path ?? '') || '/';
  11. const shouldShowAttentionIcon = page.processData != null ? shouldRecoverPagePaths(page.processData) : false;
  12. return (
  13. <div
  14. className={`${moduleClass} flex-grow-1 d-flex align-items-center pe-none`}
  15. style={{ minWidth: 0 }}
  16. >
  17. {shouldShowAttentionIcon && (
  18. <>
  19. <span id="path-recovery" className="material-symbols-outlined mr-2 text-warning">warning</span>
  20. <UncontrolledTooltip placement="top" target="path-recovery" fade={false}>
  21. {t('tooltip.operation.attention.rename')}
  22. </UncontrolledTooltip>
  23. </>
  24. )}
  25. {page != null && page.path != null && page._id != null && (
  26. <div className="grw-page-title-anchor flex-grow-1">
  27. <div className="d-flex align-items-center">
  28. <span className={`text-truncate me-1 ${page.isEmpty && 'opacity-75'}`}>{pageName}</span>
  29. { page.wip && (
  30. <span className="wip-page-badge badge rounded-pill me-1 text-bg-secondary">WIP</span>
  31. )}
  32. </div>
  33. </div>
  34. )}
  35. </div>
  36. );
  37. };