Skip to content

Commit 118b08e

Browse files
ameliahsugetsantry[bot]
authored andcommitted
feat(aci): add action details to conditions panel (#93069)
added all actions except for sentry app actions (coming soon) --------- Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
1 parent a75cf70 commit 118b08e

File tree

14 files changed

+391
-36
lines changed

14 files changed

+391
-36
lines changed

static/app/views/automations/components/actionNodes.tsx

Lines changed: 72 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,47 @@ import {createContext, useContext} from 'react';
44
import {t} from 'sentry/locale';
55
import type {Action, ActionHandler} from 'sentry/types/workflowEngine/actions';
66
import {ActionType} from 'sentry/types/workflowEngine/actions';
7-
import {AzureDevOpsNode} from 'sentry/views/automations/components/actions/azureDevOps';
8-
import {DiscordNode} from 'sentry/views/automations/components/actions/discord';
9-
import {EmailNode} from 'sentry/views/automations/components/actions/email';
10-
import {GithubNode} from 'sentry/views/automations/components/actions/github';
11-
import {GithubEnterpriseNode} from 'sentry/views/automations/components/actions/githubEnterprise';
12-
import {JiraNode} from 'sentry/views/automations/components/actions/jira';
13-
import {JiraServerNode} from 'sentry/views/automations/components/actions/jiraServer';
14-
import {MSTeamsNode} from 'sentry/views/automations/components/actions/msTeams';
15-
import {OpsgenieNode} from 'sentry/views/automations/components/actions/opsgenie';
16-
import {PagerdutyNode} from 'sentry/views/automations/components/actions/pagerduty';
7+
import {
8+
AzureDevOpsDetails,
9+
AzureDevOpsNode,
10+
} from 'sentry/views/automations/components/actions/azureDevOps';
11+
import {
12+
DiscordDetails,
13+
DiscordNode,
14+
} from 'sentry/views/automations/components/actions/discord';
15+
import {EmailDetails, EmailNode} from 'sentry/views/automations/components/actions/email';
16+
import {
17+
GithubDetails,
18+
GithubNode,
19+
} from 'sentry/views/automations/components/actions/github';
20+
import {
21+
GithubEnterpriseDetails,
22+
GithubEnterpriseNode,
23+
} from 'sentry/views/automations/components/actions/githubEnterprise';
24+
import {JiraDetails, JiraNode} from 'sentry/views/automations/components/actions/jira';
25+
import {
26+
JiraServerDetails,
27+
JiraServerNode,
28+
} from 'sentry/views/automations/components/actions/jiraServer';
29+
import {
30+
MSTeamsDetails,
31+
MSTeamsNode,
32+
} from 'sentry/views/automations/components/actions/msTeams';
33+
import {
34+
OpsgenieDetails,
35+
OpsgenieNode,
36+
} from 'sentry/views/automations/components/actions/opsgenie';
37+
import {
38+
PagerdutyDetails,
39+
PagerdutyNode,
40+
} from 'sentry/views/automations/components/actions/pagerduty';
1741
import {PluginNode} from 'sentry/views/automations/components/actions/plugin';
1842
import {SentryAppNode} from 'sentry/views/automations/components/actions/sentryApp';
19-
import {SlackNode} from 'sentry/views/automations/components/actions/slack';
20-
import {WebhookNode} from 'sentry/views/automations/components/actions/webhook';
43+
import {SlackDetails, SlackNode} from 'sentry/views/automations/components/actions/slack';
44+
import {
45+
WebhookDetails,
46+
WebhookNode,
47+
} from 'sentry/views/automations/components/actions/webhook';
2148

2249
interface ActionNodeProps {
2350
action: Action;
@@ -43,42 +70,62 @@ type ActionNode = {
4370
};
4471

4572
export const actionNodesMap = new Map<ActionType, ActionNode>([
46-
[ActionType.AZURE_DEVOPS, {label: t('Azure DevOps'), action: AzureDevOpsNode}],
47-
[ActionType.EMAIL, {label: t('Notify on preferred channel'), action: EmailNode}],
73+
[
74+
ActionType.AZURE_DEVOPS,
75+
{label: t('Azure DevOps'), action: AzureDevOpsNode, details: AzureDevOpsDetails},
76+
],
77+
[
78+
ActionType.EMAIL,
79+
{label: t('Notify on preferred channel'), action: EmailNode, details: EmailDetails},
80+
],
4881
[
4982
ActionType.DISCORD,
5083
{
5184
label: t('Discord'),
5285
action: DiscordNode,
86+
details: DiscordDetails,
5387
},
5488
],
55-
[ActionType.GITHUB, {label: t('Github'), action: GithubNode}],
89+
[ActionType.GITHUB, {label: t('Github'), action: GithubNode, details: GithubDetails}],
5690
[
5791
ActionType.GITHUB_ENTERPRISE,
58-
{label: t('Github Enterprise'), action: GithubEnterpriseNode},
92+
{
93+
label: t('Github Enterprise'),
94+
action: GithubEnterpriseNode,
95+
details: GithubEnterpriseDetails,
96+
},
97+
],
98+
[ActionType.JIRA, {label: t('Jira'), action: JiraNode, details: JiraDetails}],
99+
[
100+
ActionType.JIRA_SERVER,
101+
{label: t('Jira Server'), action: JiraServerNode, details: JiraServerDetails},
59102
],
60-
[ActionType.JIRA, {label: t('Jira'), action: JiraNode}],
61-
[ActionType.JIRA_SERVER, {label: t('Jira Server'), action: JiraServerNode}],
62103
[
63104
ActionType.MSTEAMS,
64105
{
65106
label: t('MS Teams'),
66107
action: MSTeamsNode,
108+
details: MSTeamsDetails,
67109
},
68110
],
69-
[ActionType.OPSGENIE, {label: t('Opsgenie'), action: OpsgenieNode}],
111+
[
112+
ActionType.OPSGENIE,
113+
{label: t('Opsgenie'), action: OpsgenieNode, details: OpsgenieDetails},
114+
],
70115
[
71116
ActionType.PAGERDUTY,
72117
{
73118
label: t('Pagerduty'),
74119
action: PagerdutyNode,
120+
details: PagerdutyDetails,
75121
},
76122
],
77123
[
78124
ActionType.PLUGIN,
79125
{
80126
label: t('Legacy integrations'),
81127
action: PluginNode,
128+
details: PluginNode,
82129
},
83130
],
84131
[
@@ -92,10 +139,15 @@ export const actionNodesMap = new Map<ActionType, ActionNode>([
92139
{
93140
label: t('Slack'),
94141
action: SlackNode,
142+
details: SlackDetails,
95143
},
96144
],
97145
[
98146
ActionType.WEBHOOK,
99-
{label: t('Send a notification via an integration'), action: WebhookNode},
147+
{
148+
label: t('Send a notification via an integration'),
149+
action: WebhookNode,
150+
details: WebhookDetails,
151+
},
100152
],
101153
]);

static/app/views/automations/components/actions/azureDevOps.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
11
import {ActionMetadata} from 'sentry/components/workflowEngine/ui/actionMetadata';
22
import {tct} from 'sentry/locale';
3+
import type {Action, ActionHandler} from 'sentry/types/workflowEngine/actions';
34
import {ActionType} from 'sentry/types/workflowEngine/actions';
45
import {IntegrationField} from 'sentry/views/automations/components/actions/integrationField';
56
import {TicketActionSettingsButton} from 'sentry/views/automations/components/actions/ticketActionSettingsButton';
67

8+
export function AzureDevOpsDetails({
9+
action,
10+
handler,
11+
}: {
12+
action: Action;
13+
handler: ActionHandler;
14+
}) {
15+
const integrationName =
16+
handler.integrations?.find(i => i.id === action.integrationId)?.name ||
17+
action.integrationId;
18+
19+
return tct('Create an [logo] Azure DevOps work item in [integration]', {
20+
logo: ActionMetadata[ActionType.AZURE_DEVOPS]?.icon,
21+
integration: integrationName,
22+
});
23+
}
24+
725
export function AzureDevOpsNode() {
826
return tct(
927
'Create an [logo] Azure DevOps work item in [integration] with these [settings]',

static/app/views/automations/components/actions/discord.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,35 @@ import {BannerLink, InfoBanner} from 'sentry/components/workflowEngine/ui/infoBa
77
import {t, tct} from 'sentry/locale';
88
import {PluginIcon} from 'sentry/plugins/components/pluginIcon';
99
import {space} from 'sentry/styles/space';
10+
import type {Action, ActionHandler} from 'sentry/types/workflowEngine/actions';
1011
import {IntegrationField} from 'sentry/views/automations/components/actions/integrationField';
1112
import {TagsField} from 'sentry/views/automations/components/actions/tagsField';
1213
import {TargetDisplayField} from 'sentry/views/automations/components/actions/targetDisplayField';
1314
import {ICON_SIZE} from 'sentry/views/automations/components/automationBuilderRow';
1415

16+
export function DiscordDetails({
17+
action,
18+
handler,
19+
}: {
20+
action: Action;
21+
handler: ActionHandler;
22+
}) {
23+
const integrationName =
24+
handler.integrations?.find(i => i.id === action.integrationId)?.name ||
25+
action.integrationId;
26+
const tags = String(action.data.tags);
27+
28+
return tct(
29+
'Send a [logo] Discord message to [server] server, to channel with ID or URL [channel][tags]',
30+
{
31+
logo: <PluginIcon pluginId="discord" size={ICON_SIZE} />,
32+
server: integrationName,
33+
channel: String(action.config.target_identifier),
34+
tags: action.data.tags ? `, and in the message show tags [${tags}]` : null,
35+
}
36+
);
37+
}
38+
1539
export function DiscordNode() {
1640
return (
1741
<Flex column gap={space(1)} flex="1">

static/app/views/automations/components/actions/email.tsx

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ import TeamSelector from 'sentry/components/teamSelector';
55
import AutomationBuilderSelectField, {
66
selectControlStyles,
77
} from 'sentry/components/workflowEngine/form/automationBuilderSelectField';
8-
import {tct} from 'sentry/locale';
8+
import {t, tct} from 'sentry/locale';
9+
import type {Action} from 'sentry/types/workflowEngine/actions';
910
import {ActionTarget} from 'sentry/types/workflowEngine/actions';
1011
import useOrganization from 'sentry/utils/useOrganization';
12+
import {useTeamsById} from 'sentry/utils/useTeamsById';
13+
import useUserFromId from 'sentry/utils/useUserFromId';
1114
import {useActionNodeContext} from 'sentry/views/automations/components/actionNodes';
1215

1316
enum FallthroughChoiceType {
@@ -17,7 +20,7 @@ enum FallthroughChoiceType {
1720
}
1821

1922
const TARGET_TYPE_CHOICES = [
20-
{value: ActionTarget.ISSUE_OWNERS, label: 'Suggested assignees'},
23+
{value: ActionTarget.ISSUE_OWNERS, label: 'Suggested Assignees'},
2124
{value: ActionTarget.TEAM, label: 'Team'},
2225
{value: ActionTarget.USER, label: 'Member'},
2326
];
@@ -28,6 +31,38 @@ const FALLTHROUGH_CHOICES = [
2831
{value: FallthroughChoiceType.NO_ONE, label: 'No One'},
2932
];
3033

34+
export function EmailDetails({action}: {action: Action}) {
35+
const {target_type, target_identifier} = action.config;
36+
37+
if (target_type === ActionTarget.ISSUE_OWNERS) {
38+
return tct('Notify Suggested Assignees and, if none found, notify [fallthrough]', {
39+
fallthrough:
40+
FALLTHROUGH_CHOICES.find(choice => choice.value === action.data.fallthroughType)
41+
?.label || String(action.data.fallthroughType),
42+
});
43+
}
44+
45+
if (target_type === ActionTarget.TEAM && target_identifier) {
46+
return <AssignedToTeam teamId={target_identifier} />;
47+
}
48+
if (target_type === ActionTarget.USER && target_identifier) {
49+
return <AssignedToMember memberId={parseInt(target_identifier, 10)} />;
50+
}
51+
52+
return t('Notify on preferred channel');
53+
}
54+
55+
function AssignedToTeam({teamId}: {teamId: string}) {
56+
const {teams} = useTeamsById({ids: [teamId]});
57+
const team = teams.find(tm => tm.id === teamId);
58+
return t('Notify team %s', `#${team?.slug ?? 'unknown'}`);
59+
}
60+
61+
function AssignedToMember({memberId}: {memberId: number}) {
62+
const {data: user} = useUserFromId({id: memberId});
63+
return t('Notify member %s', `${user?.email ?? 'unknown'}`);
64+
}
65+
3166
export function EmailNode() {
3267
return tct('Notify [targetType] [identifier]', {
3368
targetType: <TargetTypeField />,

static/app/views/automations/components/actions/github.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
11
import {ActionMetadata} from 'sentry/components/workflowEngine/ui/actionMetadata';
22
import {tct} from 'sentry/locale';
3+
import type {Action, ActionHandler} from 'sentry/types/workflowEngine/actions';
34
import {ActionType} from 'sentry/types/workflowEngine/actions';
45
import {IntegrationField} from 'sentry/views/automations/components/actions/integrationField';
56
import {TicketActionSettingsButton} from 'sentry/views/automations/components/actions/ticketActionSettingsButton';
67

8+
export function GithubDetails({
9+
action,
10+
handler,
11+
}: {
12+
action: Action;
13+
handler: ActionHandler;
14+
}) {
15+
const integrationName =
16+
handler.integrations?.find(i => i.id === action.integrationId)?.name ||
17+
action.integrationId;
18+
19+
return tct('Create a [logo] GitHub issue in [integration]', {
20+
logo: ActionMetadata[ActionType.GITHUB]?.icon,
21+
integration: integrationName,
22+
});
23+
}
24+
725
export function GithubNode() {
826
return tct('Create a [logo] GitHub issue in [integration] with these [settings]', {
927
logo: ActionMetadata[ActionType.GITHUB]?.icon,

static/app/views/automations/components/actions/githubEnterprise.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
11
import {ActionMetadata} from 'sentry/components/workflowEngine/ui/actionMetadata';
22
import {tct} from 'sentry/locale';
3+
import type {Action, ActionHandler} from 'sentry/types/workflowEngine/actions';
34
import {ActionType} from 'sentry/types/workflowEngine/actions';
45
import {IntegrationField} from 'sentry/views/automations/components/actions/integrationField';
56
import {TicketActionSettingsButton} from 'sentry/views/automations/components/actions/ticketActionSettingsButton';
67

8+
export function GithubEnterpriseDetails({
9+
action,
10+
handler,
11+
}: {
12+
action: Action;
13+
handler: ActionHandler;
14+
}) {
15+
const integrationName =
16+
handler.integrations?.find(i => i.id === action.integrationId)?.name ||
17+
action.integrationId;
18+
19+
return tct('Create a [logo] GitHub Enterprise issue in [integration]', {
20+
logo: ActionMetadata[ActionType.GITHUB_ENTERPRISE]?.icon,
21+
integration: integrationName,
22+
});
23+
}
24+
725
export function GithubEnterpriseNode() {
826
return tct(
927
'Create a [logo] GitHub Enterprise issue in [integration] with these [settings]',

static/app/views/automations/components/actions/jira.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
import {ActionMetadata} from 'sentry/components/workflowEngine/ui/actionMetadata';
22
import {tct} from 'sentry/locale';
3+
import type {Action, ActionHandler} from 'sentry/types/workflowEngine/actions';
34
import {ActionType} from 'sentry/types/workflowEngine/actions';
45
import {IntegrationField} from 'sentry/views/automations/components/actions/integrationField';
56
import {TicketActionSettingsButton} from 'sentry/views/automations/components/actions/ticketActionSettingsButton';
67

8+
export function JiraDetails({action, handler}: {action: Action; handler: ActionHandler}) {
9+
const integrationName =
10+
handler.integrations?.find(i => i.id === action.integrationId)?.name ||
11+
action.integrationId;
12+
13+
return tct('Create a [logo] Jira issue in [integration]', {
14+
logo: ActionMetadata[ActionType.JIRA]?.icon,
15+
integration: integrationName,
16+
});
17+
}
18+
719
export function JiraNode() {
820
return tct('Create a [logo] Jira issue in [integration] with these [settings]', {
921
logo: ActionMetadata[ActionType.JIRA]?.icon,

static/app/views/automations/components/actions/jiraServer.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
11
import {ActionMetadata} from 'sentry/components/workflowEngine/ui/actionMetadata';
22
import {tct} from 'sentry/locale';
3+
import type {Action, ActionHandler} from 'sentry/types/workflowEngine/actions';
34
import {ActionType} from 'sentry/types/workflowEngine/actions';
45
import {IntegrationField} from 'sentry/views/automations/components/actions/integrationField';
56
import {TicketActionSettingsButton} from 'sentry/views/automations/components/actions/ticketActionSettingsButton';
67

8+
export function JiraServerDetails({
9+
action,
10+
handler,
11+
}: {
12+
action: Action;
13+
handler: ActionHandler;
14+
}) {
15+
const integrationName =
16+
handler.integrations?.find(i => i.id === action.integrationId)?.name ||
17+
action.integrationId;
18+
19+
return tct('Create a [logo] Jira Server issue in [integration]', {
20+
logo: ActionMetadata[ActionType.JIRA_SERVER]?.icon,
21+
integration: integrationName,
22+
});
23+
}
24+
725
export function JiraServerNode() {
826
return tct('Create a [logo] Jira Server issue in {integration} with these [settings]', {
927
logo: ActionMetadata[ActionType.JIRA_SERVER]?.icon,

0 commit comments

Comments
 (0)