Browse Source

feat(nav): Add pathname builder for alerts (#85252)

Malachi Willey 3 weeks ago
parent
commit
fb62884411
1 changed files with 19 additions and 0 deletions
  1. 19 0
      static/app/views/alerts/pathnames.tsx

+ 19 - 0
static/app/views/alerts/pathnames.tsx

@@ -0,0 +1,19 @@
+import type {Organization} from 'sentry/types/organization';
+import normalizeUrl from 'sentry/utils/url/normalizeUrl';
+
+const LEGACY_ALERTS_BASE_PATHNAME = 'alerts';
+const ALERTS_BASE_PATHNAME = 'issues/alerts';
+
+export function makeAlertsPathname({
+  path,
+  organization,
+}: {
+  organization: Organization;
+  path: '/' | `/${string}/`;
+}) {
+  return normalizeUrl(
+    organization.features.includes('navigation-sidebar-v2')
+      ? `/organizations/${organization.slug}/${ALERTS_BASE_PATHNAME}${path}`
+      : `/organizations/${organization.slug}/${LEGACY_ALERTS_BASE_PATHNAME}${path}`
+  );
+}