vitalInfo.tsx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import type {Location} from 'history';
  2. import type {Organization} from 'sentry/types';
  3. import type EventView from 'sentry/utils/discover/eventView';
  4. import type {WebVital} from 'sentry/utils/fields';
  5. import VitalsCardDiscoverQuery from 'sentry/utils/performance/vitals/vitalsCardsDiscoverQuery';
  6. import toArray from 'sentry/utils/toArray';
  7. import {VitalBar} from '../landing/vitalsCards';
  8. type ViewProps = Pick<
  9. EventView,
  10. 'environment' | 'project' | 'start' | 'end' | 'statsPeriod'
  11. >;
  12. type Props = ViewProps & {
  13. location: Location;
  14. orgSlug: Organization['slug'];
  15. vital: WebVital | WebVital[];
  16. hideBar?: boolean;
  17. hideDurationDetail?: boolean;
  18. hideStates?: boolean;
  19. hideVitalPercentNames?: boolean;
  20. hideVitalThresholds?: boolean;
  21. isLoading?: boolean;
  22. p75AllTransactions?: number;
  23. queryExtras?: Record<string, string>;
  24. };
  25. function VitalInfo({
  26. vital,
  27. location,
  28. isLoading,
  29. hideBar,
  30. hideStates,
  31. hideVitalPercentNames,
  32. hideVitalThresholds,
  33. hideDurationDetail,
  34. queryExtras,
  35. }: Props) {
  36. const vitals = toArray(vital);
  37. const contentCommonProps = {
  38. vital,
  39. showBar: !hideBar,
  40. showStates: !hideStates,
  41. showVitalPercentNames: !hideVitalPercentNames,
  42. showVitalThresholds: !hideVitalThresholds,
  43. showDurationDetail: !hideDurationDetail,
  44. };
  45. return (
  46. <VitalsCardDiscoverQuery
  47. location={location}
  48. vitals={vitals}
  49. queryExtras={queryExtras}
  50. >
  51. {({isLoading: loading, vitalsData}) => (
  52. <VitalBar
  53. {...contentCommonProps}
  54. isLoading={isLoading || loading}
  55. data={vitalsData}
  56. />
  57. )}
  58. </VitalsCardDiscoverQuery>
  59. );
  60. }
  61. export default VitalInfo;