projectScoreCards.tsx 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. selection={selection}
  39. isProjectStabilized={isProjectStabilized}
  40. hasSessions={hasSessions}
  41. query={query}
  42. field={SessionFieldWithOperation.CRASH_FREE_RATE_SESSIONS}
  43. />
  44. <ProjectStabilityScoreCard
  45. selection={selection}
  46. isProjectStabilized={isProjectStabilized}
  47. hasSessions={hasSessions}
  48. query={query}
  49. field={SessionFieldWithOperation.CRASH_FREE_RATE_USERS}
  50. />
  51. <ProjectVelocityScoreCard
  52. organization={organization}
  53. selection={selection}
  54. isProjectStabilized={isProjectStabilized}
  55. query={query}
  56. />
  57. {isPlatformANRCompatible(project?.platform) ? (
  58. <ProjectAnrScoreCard
  59. organization={organization}
  60. selection={selection}
  61. isProjectStabilized={isProjectStabilized}
  62. query={query}
  63. location={location}
  64. />
  65. ) : (
  66. <ProjectApdexScoreCard
  67. organization={organization}
  68. selection={selection}
  69. isProjectStabilized={isProjectStabilized}
  70. hasTransactions={hasTransactions}
  71. query={query}
  72. />
  73. )}
  74. </CardWrapper>
  75. );
  76. }
  77. const CardWrapper = styled('div')`
  78. @media (min-width: ${p => p.theme.breakpoints.medium}) {
  79. display: grid;
  80. grid-column-gap: ${space(2)};
  81. grid-template-columns: repeat(2, minmax(0, 1fr));
  82. }
  83. @media (min-width: 1600px) {
  84. grid-template-columns: repeat(4, minmax(0, 1fr));
  85. }
  86. `;
  87. export default ProjectScoreCards;