projectScoreCards.tsx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import styled from '@emotion/styled';
  2. import {Location} from 'history';
  3. import {space} from 'sentry/styles/space';
  4. import {
  5. Organization,
  6. PageFilters,
  7. Project,
  8. SessionFieldWithOperation,
  9. } from 'sentry/types';
  10. import {isPlatformANRCompatible} from 'sentry/views/projectDetail/utils';
  11. import {ProjectAnrScoreCard} from './projectAnrScoreCard';
  12. import ProjectApdexScoreCard from './projectApdexScoreCard';
  13. import ProjectStabilityScoreCard from './projectStabilityScoreCard';
  14. import ProjectVelocityScoreCard from './projectVelocityScoreCard';
  15. type Props = {
  16. hasSessions: boolean | null;
  17. isProjectStabilized: boolean;
  18. location: Location;
  19. organization: Organization;
  20. selection: PageFilters;
  21. hasTransactions?: boolean;
  22. project?: Project;
  23. query?: string;
  24. };
  25. function ProjectScoreCards({
  26. organization,
  27. selection,
  28. isProjectStabilized,
  29. hasSessions,
  30. hasTransactions,
  31. query,
  32. location,
  33. project,
  34. }: Props) {
  35. return (
  36. <CardWrapper>
  37. <ProjectStabilityScoreCard
  38. organization={organization}
  39. selection={selection}
  40. isProjectStabilized={isProjectStabilized}
  41. hasSessions={hasSessions}
  42. query={query}
  43. field={SessionFieldWithOperation.SESSIONS}
  44. />
  45. <ProjectStabilityScoreCard
  46. organization={organization}
  47. selection={selection}
  48. isProjectStabilized={isProjectStabilized}
  49. hasSessions={hasSessions}
  50. query={query}
  51. field={SessionFieldWithOperation.USERS}
  52. />
  53. <ProjectVelocityScoreCard
  54. organization={organization}
  55. selection={selection}
  56. isProjectStabilized={isProjectStabilized}
  57. query={query}
  58. />
  59. {isPlatformANRCompatible(project?.platform) ? (
  60. <ProjectAnrScoreCard
  61. organization={organization}
  62. selection={selection}
  63. isProjectStabilized={isProjectStabilized}
  64. query={query}
  65. location={location}
  66. />
  67. ) : (
  68. <ProjectApdexScoreCard
  69. organization={organization}
  70. selection={selection}
  71. isProjectStabilized={isProjectStabilized}
  72. hasTransactions={hasTransactions}
  73. query={query}
  74. />
  75. )}
  76. </CardWrapper>
  77. );
  78. }
  79. const CardWrapper = styled('div')`
  80. @media (min-width: ${p => p.theme.breakpoints.medium}) {
  81. display: grid;
  82. grid-column-gap: ${space(2)};
  83. grid-template-columns: repeat(2, minmax(0, 1fr));
  84. }
  85. @media (min-width: 1600px) {
  86. grid-template-columns: repeat(4, minmax(0, 1fr));
  87. }
  88. `;
  89. export default ProjectScoreCards;