useIssueActivityDrawer.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import {useCallback} from 'react';
  2. import useDrawer from 'sentry/components/globalDrawer';
  3. import {t} from 'sentry/locale';
  4. import type {Group} from 'sentry/types/group';
  5. import type {Project} from 'sentry/types/project';
  6. import {useLocation} from 'sentry/utils/useLocation';
  7. import {useNavigate} from 'sentry/utils/useNavigate';
  8. import {ActivityDrawer} from 'sentry/views/issueDetails/streamline/activityDrawer';
  9. import {useGroupDetailsRoute} from 'sentry/views/issueDetails/useGroupDetailsRoute';
  10. interface UseIssueActivityDrawerProps {
  11. group: Group;
  12. project: Project;
  13. }
  14. export function useIssueActivityDrawer({group, project}: UseIssueActivityDrawerProps) {
  15. const {openDrawer} = useDrawer();
  16. const {baseUrl} = useGroupDetailsRoute();
  17. const navigate = useNavigate();
  18. const location = useLocation();
  19. const openIssueActivityDrawer = useCallback(() => {
  20. openDrawer(() => <ActivityDrawer group={group} project={project} />, {
  21. ariaLabel: t('Issue Activity'),
  22. shouldCloseOnInteractOutside: () => false,
  23. onClose: () => {
  24. navigate(
  25. {
  26. pathname: baseUrl,
  27. query: location.query,
  28. },
  29. {replace: true}
  30. );
  31. },
  32. transitionProps: {stiffness: 1000},
  33. });
  34. }, [openDrawer, baseUrl, navigate, location.query, group, project]);
  35. return {openIssueActivityDrawer};
  36. }