Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions static/app/views/automations/detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 0 additions & 3 deletions static/app/views/automations/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -72,8 +71,6 @@ function AutomationBreadcrumbs({automationId}: {automationId: string}) {
export default function AutomationEdit() {
const params = useParams<{automationId: string}>();

useWorkflowEngineFeatureGate({redirect: true});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also call this on DetectorViewContainer which is the top level component for automations and detectors, so I think we need to remove it on that file as well

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the callout, I'll wait until I have all of the detector redirects set up to safely remove it on the DetectorViewContainer


const {
data: automation,
isPending,
Expand Down
3 changes: 0 additions & 3 deletions static/app/views/automations/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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();
Expand Down
2 changes: 0 additions & 2 deletions static/app/views/automations/new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();
Expand Down
57 changes: 55 additions & 2 deletions static/app/views/automations/routes.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -19,6 +28,8 @@ export const automationRoutes: SentryRouteObject = {
},
{
path: ':automationId/',
component: RedirectToRuleList,
deprecatedRouteProps: true,
children: [
{
index: true,
Expand All @@ -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 (
<Redirect
to={makeAlertsPathname({
path: '/rules/',
organization,
})}
/>
);
}

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 (
<Redirect
to={makeAlertsPathname({
path: '/new/',
organization,
})}
/>
);
}

return children;
}
Loading