vitalInfo.tsx 1.5 KB

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