index.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import {useState} from 'react';
  2. import {Location} from 'history';
  3. import * as Layout from 'sentry/components/layouts/thirds';
  4. import {t} from 'sentry/locale';
  5. import {
  6. PageErrorAlert,
  7. PageErrorProvider,
  8. } from 'sentry/utils/performance/contexts/pageError';
  9. import EndpointDetail, {
  10. EndpointDataRow,
  11. } from 'sentry/views/starfish/views/endpointDetails';
  12. import APIModuleView from './APIModuleView';
  13. type APIModuleState = {
  14. selectedRow?: EndpointDataRow;
  15. };
  16. type Props = {
  17. location: Location;
  18. };
  19. export default function APIModule(props: Props) {
  20. const [state, setState] = useState<APIModuleState>({selectedRow: undefined});
  21. const unsetSelectedSpanGroup = () => setState({selectedRow: undefined});
  22. const {selectedRow} = state;
  23. const setSelectedRow = (row: EndpointDataRow) => setState({selectedRow: row});
  24. return (
  25. <Layout.Page>
  26. <PageErrorProvider>
  27. <Layout.Header>
  28. <Layout.HeaderContent>
  29. <Layout.Title>{t('API')}</Layout.Title>
  30. </Layout.HeaderContent>
  31. </Layout.Header>
  32. <Layout.Body>
  33. <Layout.Main fullWidth>
  34. <PageErrorAlert />
  35. <APIModuleView {...props} onSelect={setSelectedRow} />
  36. <EndpointDetail row={selectedRow} onClose={unsetSelectedSpanGroup} />
  37. </Layout.Main>
  38. </Layout.Body>
  39. </PageErrorProvider>
  40. </Layout.Page>
  41. );
  42. }