OldRevisionAlert.tsx 890 B

123456789101112131415161718192021222324252627282930
  1. import React from 'react';
  2. import { pathUtils } from '@growi/core';
  3. import Link from 'next/link';
  4. import { useTranslation } from 'react-i18next';
  5. import { useIsLatestRevision } from '~/stores/context';
  6. import { useSWRxCurrentPage } from '~/stores/page';
  7. export const OldRevisionAlert = (): JSX.Element => {
  8. const { t } = useTranslation();
  9. const { data: isLatestRevision } = useIsLatestRevision();
  10. const { data: page } = useSWRxCurrentPage();
  11. const { returnPathForURL } = pathUtils;
  12. if (page == null || isLatestRevision == null || isLatestRevision) {
  13. return <></>;
  14. }
  15. return (
  16. <div className="alert alert-warning">
  17. <strong>{t('Warning')}: </strong> {t('page_page.notice.version')}
  18. <Link href={returnPathForURL(page.path, page._id)}>
  19. <a><i className="icon-fw icon-arrow-right-circle"></i>{t('Show latest')}</a>
  20. </Link>
  21. </div>
  22. );
  23. };