Skip to content

Commit 644f987

Browse files
authored
fix(aci): conditionally show trigger logic type selector on automation edit (#100711)
since we've changed the trigger condition options, all of the new conditions conflict when using the "all" logic type, and only the "any" logic type can be used <img width="402" height="206" alt="Google Keep Note" src="https://github.com/user-attachments/assets/067b69f3-1834-4f21-8f13-514e04b648f9" /> therefore, we only want the "all" logic type to be available if the automation has already selected it previously (this is only possible if it was migrated from an issue alert rule) when creating a new automation or editing an existing automation that has the "any" logic type: <img width="303" height="124" alt="Screenshot 2025-10-01 at 11 51 43 AM" src="https://github.com/user-attachments/assets/2d69e426-212f-4c02-b582-e97a50b6aa9e" /> when editing an existing automation that has the "all" logic type: <img width="348" height="179" alt="Screenshot 2025-10-01 at 11 52 22 AM" src="https://github.com/user-attachments/assets/4018b898-c43b-4e2c-afbc-88be151cf964" />
1 parent 20b3832 commit 644f987

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import {useSendTestNotification} from 'sentry/views/automations/hooks';
3030
import {findConflictingConditions} from 'sentry/views/automations/hooks/utils';
3131

3232
export default function AutomationBuilder() {
33-
const {state, actions} = useAutomationBuilderContext();
33+
const {state, actions, showTriggerLogicTypeSelector} = useAutomationBuilderContext();
3434
const {mutationErrors} = useAutomationBuilderErrorContext();
3535
const organization = useOrganization();
3636
const api = useApi();
@@ -49,10 +49,9 @@ export default function AutomationBuilder() {
4949
<Flex direction="column" gap="md">
5050
<Step>
5151
<StepLead>
52-
{/* TODO: Only make this a selector of "all" is originally selected */}
5352
{tct('[when:When] [selector] of the following occur', {
5453
when: <ConditionBadge />,
55-
selector: (
54+
selector: showTriggerLogicTypeSelector ? (
5655
<EmbeddedWrapper>
5756
<EmbeddedSelectField
5857
styles={{
@@ -76,6 +75,8 @@ export default function AutomationBuilder() {
7675
size="xs"
7776
/>
7877
</EmbeddedWrapper>
78+
) : (
79+
t('any')
7980
),
8081
})}
8182
</StepLead>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ interface AutomationActions {
170170

171171
export const AutomationBuilderContext = createContext<{
172172
actions: AutomationActions;
173+
// Selector is only shown for existing automations with the "All" logic type
174+
showTriggerLogicTypeSelector: boolean;
173175
state: AutomationBuilderState;
174176
} | null>(null);
175177

static/app/views/automations/edit.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {useFormField} from 'sentry/components/workflowEngine/form/useFormField';
1515
import {useWorkflowEngineFeatureGate} from 'sentry/components/workflowEngine/useWorkflowEngineFeatureGate';
1616
import {t} from 'sentry/locale';
1717
import type {Automation, NewAutomation} from 'sentry/types/workflowEngine/automations';
18+
import {DataConditionGroupLogicType} from 'sentry/types/workflowEngine/dataConditions';
1819
import {useNavigate} from 'sentry/utils/useNavigate';
1920
import useOrganization from 'sentry/utils/useOrganization';
2021
import {useParams} from 'sentry/utils/useParams';
@@ -176,7 +177,14 @@ function AutomationEditForm({automation}: {automation: Automation}) {
176177
mutationErrors: error?.responseJSON,
177178
}}
178179
>
179-
<AutomationBuilderContext.Provider value={{state, actions}}>
180+
<AutomationBuilderContext.Provider
181+
value={{
182+
state,
183+
actions,
184+
showTriggerLogicTypeSelector:
185+
state.triggers.logicType === DataConditionGroupLogicType.ALL,
186+
}}
187+
>
180188
<AutomationForm model={model} />
181189
</AutomationBuilderContext.Provider>
182190
</AutomationBuilderErrorContext.Provider>

static/app/views/automations/new-settings.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,13 @@ export default function AutomationNewSettings() {
143143
mutationErrors: error?.responseJSON,
144144
}}
145145
>
146-
<AutomationBuilderContext.Provider value={{state, actions}}>
146+
<AutomationBuilderContext.Provider
147+
value={{
148+
state,
149+
actions,
150+
showTriggerLogicTypeSelector: false,
151+
}}
152+
>
147153
<AutomationForm model={model} />
148154
</AutomationBuilderContext.Provider>
149155
</AutomationBuilderErrorContext.Provider>

0 commit comments

Comments
 (0)