diff --git a/static/app/router/routes.tsx b/static/app/router/routes.tsx index 764fb3dc187168..31088b4cf3ee01 100644 --- a/static/app/router/routes.tsx +++ b/static/app/router/routes.tsx @@ -1658,7 +1658,9 @@ function buildRoutes(): RouteObject[] { }, { path: ':alertId/', - component: make(() => import('sentry/views/alerts/incidentRedirect')), + component: make( + () => import('sentry/views/alerts/workflowEngineRedirectWrappers/incident') + ), }, { path: ':projectId/', diff --git a/static/app/views/alerts/workflowEngineRedirectWrappers/incident.tsx b/static/app/views/alerts/workflowEngineRedirectWrappers/incident.tsx new file mode 100644 index 00000000000000..0b9a3587ea9fdf --- /dev/null +++ b/static/app/views/alerts/workflowEngineRedirectWrappers/incident.tsx @@ -0,0 +1,9 @@ +import {lazy} from 'react'; + +import {withOpenPeriodRedirect} from 'sentry/views/alerts/workflowEngineRedirects'; + +const AlertWizardProjectProvider = lazy( + () => import('sentry/views/alerts/incidentRedirect') +); + +export default withOpenPeriodRedirect(AlertWizardProjectProvider); diff --git a/static/app/views/alerts/workflowEngineRedirects.tsx b/static/app/views/alerts/workflowEngineRedirects.tsx index c4d48c4e4b718d..7e3283dd707909 100644 --- a/static/app/views/alerts/workflowEngineRedirects.tsx +++ b/static/app/views/alerts/workflowEngineRedirects.tsx @@ -1,6 +1,7 @@ import LoadingIndicator from 'sentry/components/loadingIndicator'; import Redirect from 'sentry/components/redirect'; import {useApiQuery} from 'sentry/utils/queryClient'; +import {useLocation} from 'sentry/utils/useLocation'; import useOrganization from 'sentry/utils/useOrganization'; import {useParams} from 'sentry/utils/useParams'; import {useUser} from 'sentry/utils/useUser'; @@ -26,6 +27,13 @@ interface AlertRuleDetector { ruleId: string | null; } +interface IncidentGroupOpenPeriod { + groupId: string; + incidentId: string | null; + incidentIdentifier: string; + openPeriodId: string; +} + /** * HoC that wraps a component to handle workflow engine * redirects for issue alert rules. Fetches workflow data if needed and @@ -137,10 +145,86 @@ export const withAutomationEditRedirect =
>( export const withDetectorDetailsRedirect =
>( Component: React.ComponentType
-) =>
- withAlertRuleRedirect(Component, (detectorId, orgSlug) =>
- makeMonitorDetailsPathname(orgSlug, detectorId)
- );
+) => {
+ return function WorkflowEngineRedirectWrapper(props: P) {
+ const user = useUser();
+ const organization = useOrganization();
+ const {ruleId, detectorId} = useParams();
+ const location = useLocation();
+ const alertId = location.query.alert as string | undefined;
+
+ const shouldRedirect =
+ !user.isStaff && organization.features.includes('workflow-engine-ui');
+
+ // Check for incident open period if alertId is present
+ const {data: incidentGroupOpenPeriod, isPending: isOpenPeriodPending} =
+ useApiQuery >(
Component: React.ComponentType
@@ -183,3 +267,44 @@ export function withDetectorCreateRedirect >(
return >(
+ Component: React.ComponentType
+) {
+ return function OpenPeriodRedirectWrapper(props: P) {
+ const user = useUser();
+ const organization = useOrganization();
+ const {alertId} = useParams();
+
+ const shouldRedirect =
+ !user.isStaff && organization.features.includes('workflow-engine-ui');
+
+ const {data: incidentGroupOpenPeriod, isPending} =
+ useApiQuery