diff --git a/static/app/views/automations/detail.tsx b/static/app/views/automations/detail.tsx index 4a72a11a596a48..f17317e32dbc11 100644 --- a/static/app/views/automations/detail.tsx +++ b/static/app/views/automations/detail.tsx @@ -18,7 +18,6 @@ import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle'; import TimeSince from 'sentry/components/timeSince'; import DetailLayout from 'sentry/components/workflowEngine/layout/detail'; import Section from 'sentry/components/workflowEngine/ui/section'; -import {useWorkflowEngineFeatureGate} from 'sentry/components/workflowEngine/useWorkflowEngineFeatureGate'; import {IconEdit} from 'sentry/icons'; import {t, tct} from 'sentry/locale'; import type {Automation} from 'sentry/types/workflowEngine/automations'; @@ -196,7 +195,6 @@ function AutomationDetailLoadingStates({automationId}: {automationId: string}) { } export default function AutomationDetail() { - useWorkflowEngineFeatureGate({redirect: true}); const params = useParams<{automationId: string}>(); const {data: automation, isPending} = useAutomationQuery(params.automationId); diff --git a/static/app/views/automations/edit.tsx b/static/app/views/automations/edit.tsx index dc49a8d4b28b4a..90e5a87f69225a 100644 --- a/static/app/views/automations/edit.tsx +++ b/static/app/views/automations/edit.tsx @@ -14,7 +14,6 @@ import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle'; import {FullHeightForm} from 'sentry/components/workflowEngine/form/fullHeightForm'; import {useFormField} from 'sentry/components/workflowEngine/form/useFormField'; import {StickyFooter} from 'sentry/components/workflowEngine/ui/footer'; -import {useWorkflowEngineFeatureGate} from 'sentry/components/workflowEngine/useWorkflowEngineFeatureGate'; import {t} from 'sentry/locale'; import type {Automation, NewAutomation} from 'sentry/types/workflowEngine/automations'; import {DataConditionGroupLogicType} from 'sentry/types/workflowEngine/dataConditions'; @@ -72,8 +71,6 @@ function AutomationBreadcrumbs({automationId}: {automationId: string}) { export default function AutomationEdit() { const params = useParams<{automationId: string}>(); - useWorkflowEngineFeatureGate({redirect: true}); - const { data: automation, isPending, diff --git a/static/app/views/automations/list.tsx b/static/app/views/automations/list.tsx index 0006d4320fc015..e34f05915c6afe 100644 --- a/static/app/views/automations/list.tsx +++ b/static/app/views/automations/list.tsx @@ -6,7 +6,6 @@ import {ProjectPageFilter} from 'sentry/components/organizations/projectPageFilt import Pagination from 'sentry/components/pagination'; import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle'; import ListLayout from 'sentry/components/workflowEngine/layout/list'; -import {useWorkflowEngineFeatureGate} from 'sentry/components/workflowEngine/useWorkflowEngineFeatureGate'; import {IconAdd} from 'sentry/icons'; import {t} from 'sentry/locale'; import parseLinkHeader from 'sentry/utils/parseLinkHeader'; @@ -25,8 +24,6 @@ import {useAutomationsQuery} from 'sentry/views/automations/hooks'; import {makeAutomationCreatePathname} from 'sentry/views/automations/pathnames'; export default function AutomationsList() { - useWorkflowEngineFeatureGate({redirect: true}); - const location = useLocation(); const navigate = useNavigate(); const {selection, isReady} = usePageFilters(); diff --git a/static/app/views/automations/new.tsx b/static/app/views/automations/new.tsx index b96019d29dd228..ae4ab9b26239be 100644 --- a/static/app/views/automations/new.tsx +++ b/static/app/views/automations/new.tsx @@ -12,7 +12,6 @@ import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle'; import {FullHeightForm} from 'sentry/components/workflowEngine/form/fullHeightForm'; import {useFormField} from 'sentry/components/workflowEngine/form/useFormField'; import {StickyFooter} from 'sentry/components/workflowEngine/ui/footer'; -import {useWorkflowEngineFeatureGate} from 'sentry/components/workflowEngine/useWorkflowEngineFeatureGate'; import {t} from 'sentry/locale'; import {useLocation} from 'sentry/utils/useLocation'; import {useNavigate} from 'sentry/utils/useNavigate'; @@ -71,7 +70,6 @@ export default function AutomationNewSettings() { const navigate = useNavigate(); const location = useLocation(); const organization = useOrganization(); - useWorkflowEngineFeatureGate({redirect: true}); const model = useMemo(() => new FormModel(), []); const {state, actions} = useAutomationBuilderReducer(); const theme = useTheme(); diff --git a/static/app/views/automations/routes.tsx b/static/app/views/automations/routes.tsx index 97a348517fb5b3..dd00005eebb0b4 100644 --- a/static/app/views/automations/routes.tsx +++ b/static/app/views/automations/routes.tsx @@ -1,15 +1,24 @@ +import Redirect from 'sentry/components/redirect'; import {makeLazyloadComponent as make} from 'sentry/makeLazyloadComponent'; import type {SentryRouteObject} from 'sentry/router/types'; +import useOrganization from 'sentry/utils/useOrganization'; +import {useUser} from 'sentry/utils/useUser'; +import {makeAlertsPathname} from 'sentry/views/alerts/pathnames'; export const automationRoutes: SentryRouteObject = { path: 'alerts/', children: [ { - index: true, - component: make(() => import('sentry/views/automations/list')), + component: RedirectToRuleList, + deprecatedRouteProps: true, + children: [ + {index: true, component: make(() => import('sentry/views/automations/list'))}, + ], }, { path: 'new', + component: RedirectToNewRule, + deprecatedRouteProps: true, children: [ { index: true, @@ -19,6 +28,8 @@ export const automationRoutes: SentryRouteObject = { }, { path: ':automationId/', + component: RedirectToRuleList, + deprecatedRouteProps: true, children: [ { index: true, @@ -32,3 +43,45 @@ export const automationRoutes: SentryRouteObject = { }, ], }; + +function RedirectToRuleList({children}: {children: React.ReactNode}) { + const user = useUser(); + const organization = useOrganization(); + + const shouldRedirect = + !user.isStaff && !organization.features.includes('workflow-engine-ui'); + + if (shouldRedirect) { + return ( + + ); + } + + return children; +} + +function RedirectToNewRule({children}: {children: React.ReactNode}) { + const user = useUser(); + const organization = useOrganization(); + + const shouldRedirect = + !user.isStaff && !organization.features.includes('workflow-engine-ui'); + + if (shouldRedirect) { + return ( + + ); + } + + return children; +}