index.tsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 {space} from 'sentry/styles/space';
  10. import type {Activity} from 'sentry/types';
  11. import {useApiQuery} from 'sentry/utils/queryClient';
  12. import routeTitle from 'sentry/utils/routeTitle';
  13. import useOrganization from 'sentry/utils/useOrganization';
  14. import ActivityFeedItem from './activityFeedItem';
  15. function OrganizationActivity() {
  16. const organization = useOrganization();
  17. const {
  18. data: activity,
  19. isLoading,
  20. isError,
  21. getResponseHeader,
  22. } = useApiQuery<Activity[]>([`/organizations/${organization.slug}/activity/`], {
  23. staleTime: 0,
  24. });
  25. if (isLoading) {
  26. return <LoadingIndicator />;
  27. }
  28. if (isError || (!isLoading && !activity.length)) {
  29. return (
  30. <EmptyStateWarning>
  31. <p>{t('Nothing to show here, move along.')}</p>
  32. </EmptyStateWarning>
  33. );
  34. }
  35. const activityPageLinks = getResponseHeader?.('Link');
  36. return (
  37. <SentryDocumentTitle title={routeTitle(t('Activity'), organization.slug, false)}>
  38. <Layout.Page>
  39. <Layout.Header>
  40. <Layout.HeaderContent>
  41. <Layout.Title>{t('Activity')}</Layout.Title>
  42. </Layout.HeaderContent>
  43. </Layout.Header>
  44. <Layout.Body>
  45. <Layout.Main fullWidth>
  46. <Panel>
  47. {!isLoading && (
  48. <div data-test-id="activity-feed-list">
  49. {activity.map(item => (
  50. <ErrorBoundary
  51. mini
  52. css={{marginBottom: space(1), borderRadius: 0}}
  53. key={item.id}
  54. >
  55. <ActivityFeedItem organization={organization} item={item} />
  56. </ErrorBoundary>
  57. ))}
  58. </div>
  59. )}
  60. </Panel>
  61. {activityPageLinks && <Pagination pageLinks={activityPageLinks} />}
  62. </Layout.Main>
  63. </Layout.Body>
  64. </Layout.Page>
  65. </SentryDocumentTitle>
  66. );
  67. }
  68. export default OrganizationActivity;