index.tsx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import {useState} from 'react';
  2. import {Location} from 'history';
  3. import * as Layout from 'sentry/components/layouts/thirds';
  4. import PageFiltersContainer from 'sentry/components/organizations/pageFilters/container';
  5. import {t} from 'sentry/locale';
  6. import {
  7. PageErrorAlert,
  8. PageErrorProvider,
  9. } from 'sentry/utils/performance/contexts/pageError';
  10. import {EndpointDataRow} from 'sentry/views/starfish/views/endpointDetails';
  11. import {SpanSummaryPanel} from 'sentry/views/starfish/views/spans/spanSummaryPanel';
  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. <PageFiltersContainer>
  36. <APIModuleView {...props} onSelect={setSelectedRow} />
  37. <SpanSummaryPanel
  38. span={{
  39. ...selectedRow,
  40. span_operation: 'http.client',
  41. group_id: selectedRow?.group_id || '',
  42. }}
  43. onClose={unsetSelectedSpanGroup}
  44. />
  45. ;
  46. </PageFiltersContainer>
  47. </Layout.Main>
  48. </Layout.Body>
  49. </PageErrorProvider>
  50. </Layout.Page>
  51. );
  52. }