PageHistory.tsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. const logger = loggerFactory('growi:PageHistory');
  6. type PageHistoryProps = {
  7. sourceRevisionId?: string,
  8. targetRevisionId?: string
  9. onClose: () => void
  10. }
  11. // Get string from 'compare' query params
  12. export const getQueryParam = (): string | null => {
  13. const query: URLSearchParams = new URL(window.location.href).searchParams;
  14. return query.get('compare');
  15. };
  16. export const PageHistory: React.FC<PageHistoryProps> = (props: PageHistoryProps) => {
  17. const { sourceRevisionId, targetRevisionId, onClose } = props;
  18. const { data: currentPageId } = useCurrentPageId();
  19. const { data: currentPagePath } = useCurrentPagePath();
  20. return (
  21. <div className="revision-history" data-testid="page-history">
  22. {currentPageId != null && currentPagePath != null && (
  23. <PageRevisionTable
  24. sourceRevisionId={sourceRevisionId}
  25. targetRevisionId={targetRevisionId}
  26. currentPageId={currentPageId}
  27. currentPagePath={currentPagePath}
  28. onClose={onClose}
  29. />
  30. )}
  31. </div>
  32. );
  33. };