focusArea.tsx 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import Feature from 'sentry/components/acl/feature';
  2. import FeatureDisabled from 'sentry/components/acl/featureDisabled';
  3. import Placeholder from 'sentry/components/placeholder';
  4. import {useReplayContext} from 'sentry/components/replays/replayContext';
  5. import {t} from 'sentry/locale';
  6. import useActiveReplayTab from 'sentry/utils/replays/hooks/useActiveReplayTab';
  7. import useOrganization from 'sentry/utils/useOrganization';
  8. import Console from 'sentry/views/replays/detail/console';
  9. import DomMutations from 'sentry/views/replays/detail/domMutations';
  10. import IssueList from 'sentry/views/replays/detail/issueList';
  11. import MemoryChart from 'sentry/views/replays/detail/memoryChart';
  12. import NetworkList from 'sentry/views/replays/detail/network';
  13. import Trace from 'sentry/views/replays/detail/trace';
  14. type Props = {};
  15. function FocusArea({}: Props) {
  16. const {getActiveTab} = useActiveReplayTab();
  17. const {currentTime, currentHoverTime, replay, setCurrentTime, setCurrentHoverTime} =
  18. useReplayContext();
  19. const organization = useOrganization();
  20. if (!replay) {
  21. return <Placeholder height="150px" />;
  22. }
  23. const replayRecord = replay.getReplay();
  24. const startTimestampMs = replayRecord.startedAt.getTime();
  25. switch (getActiveTab()) {
  26. case 'console':
  27. return (
  28. <Console
  29. breadcrumbs={replay.getConsoleCrumbs()}
  30. startTimestampMs={replayRecord.startedAt.getTime()}
  31. />
  32. );
  33. case 'network':
  34. return (
  35. <NetworkList
  36. replayRecord={replayRecord}
  37. networkSpans={replay.getNetworkSpans()}
  38. />
  39. );
  40. case 'trace':
  41. const features = ['organizations:performance-view'];
  42. const renderDisabled = () => (
  43. <FeatureDisabled
  44. featureName={t('Performance Monitoring')}
  45. features={features}
  46. message={t('Requires performance monitoring.')}
  47. hideHelpToggle
  48. />
  49. );
  50. return (
  51. <Feature
  52. organization={organization}
  53. hookName="feature-disabled:configure-distributed-tracing"
  54. features={features}
  55. renderDisabled={renderDisabled}
  56. >
  57. <Trace organization={organization} replayRecord={replayRecord} />
  58. </Feature>
  59. );
  60. case 'issues':
  61. return <IssueList replayId={replayRecord.id} projectId={replayRecord.projectId} />;
  62. case 'dom':
  63. return <DomMutations replay={replay} />;
  64. case 'memory':
  65. return (
  66. <MemoryChart
  67. currentTime={currentTime}
  68. currentHoverTime={currentHoverTime}
  69. memorySpans={replay.getMemorySpans()}
  70. setCurrentTime={setCurrentTime}
  71. setCurrentHoverTime={setCurrentHoverTime}
  72. startTimestampMs={startTimestampMs}
  73. />
  74. );
  75. default:
  76. return null;
  77. }
  78. }
  79. export default FocusArea;