index.tsx 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import EmptyStateWarning from 'sentry/components/emptyStateWarning';
  2. import ErrorBoundary from 'sentry/components/errorBoundary';
  3. import * as Layout from 'sentry/components/layouts/thirds';
  4. import LoadingIndicator from 'sentry/components/loadingIndicator';
  5. import Pagination from 'sentry/components/pagination';
  6. import Panel from 'sentry/components/panels/panel';
  7. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  8. import {t} from 'sentry/locale';
  9. import AlertStore from 'sentry/stores/alertStore';
  10. import {space} from 'sentry/styles/space';
  11. import type {Activity} from 'sentry/types';
  12. import {useApiQuery} from 'sentry/utils/queryClient';
  13. import routeTitle from 'sentry/utils/routeTitle';
  14. import useOrganization from 'sentry/utils/useOrganization';
  15. import ActivityFeedItem from './activityFeedItem';
  16. function OrganizationActivity() {
  17. const organization = useOrganization();
  18. const {
  19. data: activity,
  20. isLoading,
  21. isError,
  22. getResponseHeader,
  23. } = useApiQuery<Activity[]>([`/organizations/${organization.slug}/activity/`], {
  24. staleTime: 0,
  25. });
  26. AlertStore.addAlert({
  27. id: 'organization-activity-deprecation-notice',
  28. message: t('This page is deprecated and will be removed in a future release.'),
  29. type: 'warning',
  30. opaque: true,
  31. neverExpire: true,
  32. noDuplicates: true,
  33. });
  34. if (isLoading) {
  35. return <LoadingIndicator />;
  36. }
  37. if (isError || (!isLoading && !activity.length)) {
  38. return (
  39. <EmptyStateWarning>
  40. <p>{t('Nothing to show here, move along.')}</p>
  41. </EmptyStateWarning>
  42. );
  43. }
  44. const activityPageLinks = getResponseHeader?.('Link');
  45. return (
  46. <SentryDocumentTitle title={routeTitle(t('Activity'), organization.slug, false)}>
  47. <Layout.Page>
  48. <Layout.Header>
  49. <Layout.HeaderContent>
  50. <Layout.Title>{t('Activity')}</Layout.Title>
  51. </Layout.HeaderContent>
  52. </Layout.Header>
  53. <Layout.Body>
  54. <Layout.Main fullWidth>
  55. <Panel>
  56. {!isLoading && (
  57. <div data-test-id="activity-feed-list">
  58. {activity.map(item => (
  59. <ErrorBoundary
  60. mini
  61. css={{marginBottom: space(1), borderRadius: 0}}
  62. key={item.id}
  63. >
  64. <ActivityFeedItem organization={organization} item={item} />
  65. </ErrorBoundary>
  66. ))}
  67. </div>
  68. )}
  69. </Panel>
  70. {activityPageLinks && <Pagination pageLinks={activityPageLinks} />}
  71. </Layout.Main>
  72. </Layout.Body>
  73. </Layout.Page>
  74. </SentryDocumentTitle>
  75. );
  76. }
  77. export default OrganizationActivity;