PageHistory.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import React from 'react';
  2. import { useCurrentPagePath, useCurrentPageId } from '~/stores/page';
  3. import loggerFactory from '~/utils/logger';
  4. import { PageRevisionTable } from '../PageHistory/PageRevisionTable';
  5. import { useAutoComparingRevisionsByQueryParam } from './hooks';
  6. const logger = loggerFactory('growi:PageHistory');
  7. type PageHistoryProps = {
  8. onClose: () => void
  9. }
  10. export const PageHistory: React.FC<PageHistoryProps> = (props: PageHistoryProps) => {
  11. const { onClose } = props;
  12. const { data: currentPageId } = useCurrentPageId();
  13. const { data: currentPagePath } = useCurrentPagePath();
  14. const comparingRevisions = useAutoComparingRevisionsByQueryParam();
  15. return (
  16. <div className="revision-history" data-testid="page-history">
  17. {currentPageId != null && currentPagePath != null && (
  18. <PageRevisionTable
  19. sourceRevisionId={comparingRevisions?.sourceRevisionId}
  20. targetRevisionId={comparingRevisions?.targetRevisionId}
  21. currentPageId={currentPageId}
  22. currentPagePath={currentPagePath}
  23. onClose={onClose}
  24. />
  25. )}
  26. </div>
  27. );
  28. };