routes.tsx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 generateProfileSummaryRoute({
  8. orgSlug,
  9. projectSlug,
  10. }: {
  11. orgSlug: Organization['slug'];
  12. projectSlug: Project['slug'];
  13. }): Path {
  14. return `/organizations/${orgSlug}/profiling/summary/${projectSlug}/`;
  15. }
  16. export function generateProfileFlamechartRoute({
  17. orgSlug,
  18. projectSlug,
  19. profileId,
  20. }: {
  21. orgSlug: Organization['slug'];
  22. profileId: Trace['id'];
  23. projectSlug: Project['slug'];
  24. }): string {
  25. return `/organizations/${orgSlug}/profiling/profile/${projectSlug}/${profileId}/flamechart/`;
  26. }
  27. export function generateProfileDetailsRoute({
  28. orgSlug,
  29. projectSlug,
  30. profileId,
  31. }: {
  32. orgSlug: Organization['slug'];
  33. profileId: Trace['id'];
  34. projectSlug: Project['slug'];
  35. }): string {
  36. return `/organizations/${orgSlug}/profiling/profile/${projectSlug}/${profileId}/details/`;
  37. }
  38. export function generateProfilingRouteWithQuery({
  39. orgSlug,
  40. query,
  41. }: {
  42. orgSlug: Organization['slug'];
  43. query?: Location['query'];
  44. }): LocationDescriptor {
  45. const pathname = generateProfilingRoute({orgSlug});
  46. return {
  47. pathname,
  48. query: {
  49. ...query,
  50. },
  51. };
  52. }
  53. export function generateProfileSummaryRouteWithQuery({
  54. orgSlug,
  55. projectSlug,
  56. transaction,
  57. query,
  58. }: {
  59. orgSlug: Organization['slug'];
  60. projectSlug: Project['slug'];
  61. transaction: string;
  62. query?: Location['query'];
  63. }): LocationDescriptor {
  64. const pathname = generateProfileSummaryRoute({orgSlug, projectSlug});
  65. return {
  66. pathname,
  67. query: {
  68. ...query,
  69. transaction,
  70. },
  71. };
  72. }
  73. export function generateProfileFlamechartRouteWithQuery({
  74. orgSlug,
  75. projectSlug,
  76. profileId,
  77. query,
  78. }: {
  79. orgSlug: Organization['slug'];
  80. profileId: Trace['id'];
  81. projectSlug: Project['slug'];
  82. query?: Location['query'];
  83. }): LocationDescriptor {
  84. const pathname = generateProfileFlamechartRoute({
  85. orgSlug,
  86. projectSlug,
  87. profileId,
  88. });
  89. return {
  90. pathname,
  91. query: {
  92. ...query,
  93. },
  94. };
  95. }
  96. export function generateProfileDetailsRouteWithQuery({
  97. orgSlug,
  98. projectSlug,
  99. profileId,
  100. query,
  101. }: {
  102. orgSlug: Organization['slug'];
  103. profileId: Trace['id'];
  104. projectSlug: Project['slug'];
  105. query?: Location['query'];
  106. }): LocationDescriptor {
  107. const pathname = generateProfileDetailsRoute({orgSlug, projectSlug, profileId});
  108. return {
  109. pathname,
  110. query: {
  111. ...query,
  112. },
  113. };
  114. }