routes.tsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. import {Location, LocationDescriptor, Path} from 'history';
  2. import {Organization, Project} from 'sentry/types';
  3. import {Trace} from 'sentry/types/profiling/core';
  4. export function generateProfilingRoute({orgSlug}: {orgSlug: Organization['slug']}): Path {
  5. return `/organizations/${orgSlug}/profiling/`;
  6. }
  7. export function generateProfilingOnboardingRoute({
  8. orgSlug,
  9. }: {
  10. orgSlug: Organization['slug'];
  11. }): Path {
  12. return `/organizations/${orgSlug}/profiling/onboarding/`;
  13. }
  14. export function generateProfileSummaryRoute({
  15. orgSlug,
  16. projectSlug,
  17. }: {
  18. orgSlug: Organization['slug'];
  19. projectSlug: Project['slug'];
  20. }): Path {
  21. return `/organizations/${orgSlug}/profiling/summary/${projectSlug}/`;
  22. }
  23. export function generateProfileFlamegraphRoute({
  24. orgSlug,
  25. projectSlug,
  26. profileId,
  27. }: {
  28. orgSlug: Organization['slug'];
  29. profileId: Trace['id'];
  30. projectSlug: Project['slug'];
  31. }): string {
  32. return `/organizations/${orgSlug}/profiling/profile/${projectSlug}/${profileId}/flamegraph/`;
  33. }
  34. export function generateProfileDetailsRoute({
  35. orgSlug,
  36. projectSlug,
  37. profileId,
  38. }: {
  39. orgSlug: Organization['slug'];
  40. profileId: Trace['id'];
  41. projectSlug: Project['slug'];
  42. }): string {
  43. return `/organizations/${orgSlug}/profiling/profile/${projectSlug}/${profileId}/details/`;
  44. }
  45. export function generateProfilingRouteWithQuery({
  46. location,
  47. orgSlug,
  48. query,
  49. }: {
  50. orgSlug: Organization['slug'];
  51. location?: Location;
  52. query?: Location['query'];
  53. }): LocationDescriptor {
  54. const pathname = generateProfilingRoute({orgSlug});
  55. return {
  56. pathname,
  57. query: {
  58. ...location?.query,
  59. ...query,
  60. },
  61. };
  62. }
  63. export function generateProfileSummaryRouteWithQuery({
  64. location,
  65. orgSlug,
  66. projectSlug,
  67. transaction,
  68. query,
  69. }: {
  70. orgSlug: Organization['slug'];
  71. projectSlug: Project['slug'];
  72. transaction: string;
  73. location?: Location;
  74. query?: Location['query'];
  75. }): LocationDescriptor {
  76. const pathname = generateProfileSummaryRoute({orgSlug, projectSlug});
  77. return {
  78. pathname,
  79. query: {
  80. ...location?.query,
  81. ...query,
  82. transaction,
  83. },
  84. };
  85. }
  86. export function generateProfileFlamegraphRouteWithQuery({
  87. location,
  88. orgSlug,
  89. projectSlug,
  90. profileId,
  91. query,
  92. }: {
  93. orgSlug: Organization['slug'];
  94. profileId: Trace['id'];
  95. projectSlug: Project['slug'];
  96. location?: Location;
  97. query?: Location['query'];
  98. }): LocationDescriptor {
  99. const pathname = generateProfileFlamegraphRoute({orgSlug, projectSlug, profileId});
  100. return {
  101. pathname,
  102. query: {
  103. ...location?.query,
  104. ...query,
  105. },
  106. };
  107. }
  108. export function generateProfileDetailsRouteWithQuery({
  109. location,
  110. orgSlug,
  111. projectSlug,
  112. profileId,
  113. query,
  114. }: {
  115. orgSlug: Organization['slug'];
  116. profileId: Trace['id'];
  117. projectSlug: Project['slug'];
  118. location?: Location;
  119. query?: Location['query'];
  120. }): LocationDescriptor {
  121. const pathname = generateProfileDetailsRoute({orgSlug, projectSlug, profileId});
  122. return {
  123. pathname,
  124. query: {
  125. ...location?.query,
  126. ...query,
  127. },
  128. };
  129. }