Skip to content

feat(aci): automation edit scaffolding #94595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 30, 2025
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
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@
"echarts": "5.4.0",
"echarts-for-react": "3.0.2",
"esbuild": "0.25.3",
"flattie": "^1.1.1",
"focus-trap": "^7.3.1",
"framer-motion": "12.7.3",
"fuse.js": "^6.6.2",
Expand Down
9 changes: 0 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

99 changes: 0 additions & 99 deletions static/app/components/workflowEngine/layout/edit.tsx

This file was deleted.

38 changes: 28 additions & 10 deletions static/app/views/automations/components/actionNodeList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Fragment, useMemo, useState} from 'react';
import {Fragment, useMemo} from 'react';
import styled from '@emotion/styled';
import {uuid4} from '@sentry/core';

Expand All @@ -8,6 +8,8 @@ import {
type Action,
ActionGroup,
type ActionHandler,
ActionType,
SentryAppIdentifier,
} from 'sentry/types/workflowEngine/actions';
import {
ActionNodeContext,
Expand All @@ -31,6 +33,30 @@ interface Option {
value: ActionHandler;
}

function getActionHandler(
action: Action,
availableActions: ActionHandler[]
): ActionHandler | undefined {
if (action.type === ActionType.SENTRY_APP) {
return availableActions.find(handler => {
if (handler.type !== ActionType.SENTRY_APP) {
return false;
}
const {sentry_app_identifier, target_identifier} = action.config;
const sentryApp = handler.sentryApp;

const isMatchingAppId =
sentry_app_identifier === SentryAppIdentifier.SENTRY_APP_ID &&
target_identifier === sentryApp?.id;
const isMatchingInstallationUuid =
sentry_app_identifier === SentryAppIdentifier.SENTRY_APP_INSTALLATION_UUID &&
target_identifier === sentryApp?.installationUuid;
return isMatchingAppId || isMatchingInstallationUuid;
});
}
return availableActions.find(handler => handler.type === action.type);
}

export default function ActionNodeList({
group,
placeholder,
Expand All @@ -40,9 +66,6 @@ export default function ActionNodeList({
updateAction,
}: ActionNodeListProps) {
const {data: availableActions = []} = useAvailableActionsQuery();
const [actionHandlerMap, setActionHandlerMap] = useState<Record<string, ActionHandler>>(
{}
);

const options = useMemo(() => {
const notificationActions: Option[] = [];
Expand Down Expand Up @@ -88,7 +111,7 @@ export default function ActionNodeList({
return (
<Fragment>
{actions.map(action => {
const handler = actionHandlerMap[action.id];
const handler = getActionHandler(action, availableActions);
if (!handler) {
return null;
}
Expand All @@ -97,7 +120,6 @@ export default function ActionNodeList({
key={`${group}.action.${action.id}`}
onDelete={() => {
onDeleteRow(action.id);
setActionHandlerMap(({[action.id]: _, ...rest}) => rest);
}}
>
<ActionNodeContext.Provider
Expand All @@ -118,10 +140,6 @@ export default function ActionNodeList({
onChange={(obj: any) => {
const actionId = uuid4();
onAddRow(actionId, obj.value);
setActionHandlerMap(currActionHandlerMap => ({
...currActionHandlerMap,
[actionId]: obj.value,
}));
}}
placeholder={placeholder}
value={null}
Expand Down
2 changes: 1 addition & 1 deletion static/app/views/automations/components/actionNodes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export const actionNodesMap = new Map<ActionType, ActionNode>([
label: t('Notify on preferred channel'),
action: EmailNode,
details: EmailDetails,
defaultData: {fallthrough_type: 'ActiveMembers'},
defaultData: {fallthroughType: 'ActiveMembers'},
},
],
[
Expand Down
10 changes: 5 additions & 5 deletions static/app/views/automations/components/actions/email.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export function EmailDetails({action}: {action: Action}) {
if (target_type === ActionTarget.ISSUE_OWNERS) {
return tct('Notify Suggested Assignees and, if none found, notify [fallthrough]', {
fallthrough:
FALLTHROUGH_CHOICES.find(choice => choice.value === action.data.fallthrough_type)
?.label || String(action.data.fallthrough_type),
FALLTHROUGH_CHOICES.find(choice => choice.value === action.data.fallthroughType)
?.label || String(action.data.fallthroughType),
});
}

Expand Down Expand Up @@ -129,11 +129,11 @@ function FallthroughField() {
const {action, actionId, onUpdate} = useActionNodeContext();
return (
<AutomationBuilderSelect
name={`${actionId}.data.fallthrough_type`}
value={action.data.fallthrough_type}
name={`${actionId}.data.fallthroughType`}
value={action.data.fallthroughType}
options={FALLTHROUGH_CHOICES}
onChange={(option: SelectValue<string>) =>
onUpdate({data: {fallthrough_type: option.value}})
onUpdate({data: {fallthroughType: option.value}})
}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ export default function AutomationBuilder() {
{t('If/Then Block')}
</PurpleTextButton>
</span>
<span>
<Button icon={<IconMail />}>{t('Send Test Notification')}</Button>
</span>
</Flex>
);
}
Expand Down Expand Up @@ -198,6 +195,9 @@ function ActionFilterBlock({
updateAction={(id, data) => actions.updateIfAction(actionFilter.id, id, data)}
/>
</Step>
<span>
<Button icon={<IconMail />}>{t('Send Test Notification')}</Button>
</span>
</IfThenWrapper>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
type ActionHandler,
ActionTarget,
ActionType,
SentryAppIdentifier,
} from 'sentry/types/workflowEngine/actions';
import {
type DataConditionGroup,
Expand All @@ -15,7 +16,7 @@ import {
import {actionNodesMap} from 'sentry/views/automations/components/actionNodes';
import {dataConditionNodesMap} from 'sentry/views/automations/components/dataConditionNodes';

export function useAutomationBuilderReducer() {
export function useAutomationBuilderReducer(initialState?: AutomationBuilderState) {
const reducer: Reducer<AutomationBuilderState, AutomationBuilderAction> = useCallback(
(state, action): AutomationBuilderState => {
switch (action.type) {
Expand Down Expand Up @@ -54,7 +55,10 @@ export function useAutomationBuilderReducer() {
[]
);

const [state, dispatch] = useReducer(reducer, initialAutomationBuilderState);
const [state, dispatch] = useReducer(
reducer,
initialState ?? initialAutomationBuilderState
);

const actions: AutomationActions = {
addWhenCondition: useCallback(
Expand Down Expand Up @@ -519,6 +523,9 @@ function getDefaultConfig(actionHandler: ActionHandler): ActionConfig {
return {
target_type: targetType,
...(targetIdentifier && {target_identifier: targetIdentifier}),
...(actionHandler.sentryApp?.id && {
sentry_app_identifier: SentryAppIdentifier.SENTRY_APP_ID,
}),
};
}

Expand Down
27 changes: 11 additions & 16 deletions static/app/views/automations/components/automationForm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {useEffect, useState} from 'react';
import {useState} from 'react';
import styled from '@emotion/styled';

import {Button} from 'sentry/components/core/button';
Expand All @@ -7,7 +7,6 @@ import {Flex} from 'sentry/components/core/layout';
import SelectField from 'sentry/components/forms/fields/selectField';
import type FormModel from 'sentry/components/forms/model';
import useDrawer from 'sentry/components/globalDrawer';
import {useDocumentTitle} from 'sentry/components/sentryDocumentTitle';
import {DebugForm} from 'sentry/components/workflowEngine/form/debug';
import {EnvironmentSelector} from 'sentry/components/workflowEngine/form/environmentSelector';
import {useFormField} from 'sentry/components/workflowEngine/form/useFormField';
Expand All @@ -23,24 +22,19 @@ import {useDetectorsQuery} from 'sentry/views/detectors/hooks';
import {makeMonitorBasePathname} from 'sentry/views/detectors/pathnames';

const FREQUENCY_OPTIONS = [
{value: '5', label: t('5 minutes')},
{value: '10', label: t('10 minutes')},
{value: '30', label: t('30 minutes')},
{value: '60', label: t('60 minutes')},
{value: '180', label: t('3 hours')},
{value: '720', label: t('12 hours')},
{value: '1440', label: t('24 hours')},
{value: '10080', label: t('1 week')},
{value: '43200', label: t('30 days')},
{value: 5, label: t('5 minutes')},
{value: 10, label: t('10 minutes')},
{value: 30, label: t('30 minutes')},
{value: 60, label: t('60 minutes')},
{value: 180, label: t('3 hours')},
{value: 720, label: t('12 hours')},
{value: 1440, label: t('24 hours')},
{value: 10080, label: t('1 week')},
{value: 43200, label: t('30 days')},
];

export default function AutomationForm({model}: {model: FormModel}) {
const organization = useOrganization();
const title = useDocumentTitle();

useEffect(() => {
model.setValue('name', title);
}, [title, model]);

const {data: monitors = []} = useDetectorsQuery();
const initialConnectedIds = useFormField('detectorIds');
Expand Down Expand Up @@ -116,6 +110,7 @@ export default function AutomationForm({model}: {model: FormModel}) {
<Card>
<Heading>{t('Action Interval')}</Heading>
<EmbeddedSelectField
required
name="frequency"
inline={false}
clearable={false}
Expand Down
Loading
Loading