@@ -12,7 +12,6 @@ import {t, tct} from 'sentry/locale';
12
12
import { space } from 'sentry/styles/space' ;
13
13
import type { SelectValue } from 'sentry/types/core' ;
14
14
import type {
15
- ConflictingConditions ,
16
15
DataConditionGroup ,
17
16
DataConditionGroupLogicType ,
18
17
} from 'sentry/types/workflowEngine/dataConditions' ;
@@ -21,6 +20,7 @@ import useApi from 'sentry/utils/useApi';
21
20
import useOrganization from 'sentry/utils/useOrganization' ;
22
21
import { FILTER_MATCH_OPTIONS } from 'sentry/views/automations/components/actionFilters/constants' ;
23
22
import ActionNodeList from 'sentry/views/automations/components/actionNodeList' ;
23
+ import { AutomationBuilderConflictContext } from 'sentry/views/automations/components/automationBuilderConflictContext' ;
24
24
import { useAutomationBuilderContext } from 'sentry/views/automations/components/automationBuilderContext' ;
25
25
import DataConditionNodeList from 'sentry/views/automations/components/dataConditionNodeList' ;
26
26
import { TRIGGER_MATCH_OPTIONS } from 'sentry/views/automations/components/triggers/constants' ;
@@ -36,86 +36,83 @@ export default function AutomationBuilder() {
36
36
fetchOrgMembers ( api , organization . slug ) ;
37
37
} , [ api , organization ] ) ;
38
38
39
- const { conflictingTriggers, conflictingActionFilters} =
40
- useMemo ( ( ) : ConflictingConditions => {
41
- return findConflictingConditions ( state . triggers , state . actionFilters ) ;
42
- } , [ state ] ) ;
39
+ const conflictData = useMemo ( ( ) => {
40
+ return findConflictingConditions ( state . triggers , state . actionFilters ) ;
41
+ } , [ state ] ) ;
43
42
44
43
return (
45
- < Flex direction = "column" gap = { space ( 1 ) } >
46
- < Step >
47
- < StepLead >
48
- { /* TODO: Only make this a selector of "all" is originally selected */ }
49
- { tct ( '[when:When] [selector] of the following occur' , {
50
- when : < ConditionBadge /> ,
51
- selector : (
52
- < EmbeddedWrapper >
53
- < EmbeddedSelectField
54
- styles = { {
55
- control : ( provided : any ) => ( {
56
- ...provided ,
57
- minHeight : '21px' ,
58
- height : '21px' ,
59
- } ) ,
60
- } }
61
- inline = { false }
62
- isSearchable = { false }
63
- isClearable = { false }
64
- name = "triggers.logicType"
65
- value = { state . triggers . logicType }
66
- onChange = { ( option : SelectValue < DataConditionGroupLogicType > ) =>
67
- actions . updateWhenLogicType ( option . value )
68
- }
69
- required
70
- flexibleControlStateSize
71
- options = { TRIGGER_MATCH_OPTIONS }
72
- size = "xs"
73
- />
74
- </ EmbeddedWrapper >
75
- ) ,
76
- } ) }
77
- </ StepLead >
78
- </ Step >
79
- < DataConditionNodeList
80
- handlerGroup = { DataConditionHandlerGroupType . WORKFLOW_TRIGGER }
81
- placeholder = { t ( 'Select a trigger...' ) }
82
- conditions = { state . triggers . conditions }
83
- group = "triggers"
84
- onAddRow = { type => actions . addWhenCondition ( type ) }
85
- onDeleteRow = { index => actions . removeWhenCondition ( index ) }
86
- updateCondition = { ( id , comparison ) => actions . updateWhenCondition ( id , comparison ) }
87
- conflictingConditionIds = { conflictingTriggers }
88
- />
89
- { state . actionFilters . map ( actionFilter => (
90
- < ActionFilterBlock
91
- key = { `actionFilters.${ actionFilter . id } ` }
92
- actionFilter = { actionFilter }
93
- conflictingConditions = { conflictingActionFilters [ actionFilter . id ] || [ ] }
44
+ < AutomationBuilderConflictContext . Provider value = { conflictData } >
45
+ < Flex direction = "column" gap = { space ( 1 ) } >
46
+ < Step >
47
+ < StepLead >
48
+ { /* TODO: Only make this a selector of "all" is originally selected */ }
49
+ { tct ( '[when:When] [selector] of the following occur' , {
50
+ when : < ConditionBadge /> ,
51
+ selector : (
52
+ < EmbeddedWrapper >
53
+ < EmbeddedSelectField
54
+ styles = { {
55
+ control : ( provided : any ) => ( {
56
+ ...provided ,
57
+ minHeight : '21px' ,
58
+ height : '21px' ,
59
+ } ) ,
60
+ } }
61
+ inline = { false }
62
+ isSearchable = { false }
63
+ isClearable = { false }
64
+ name = { `${ state . triggers . id } .logicType` }
65
+ value = { state . triggers . logicType }
66
+ onChange = { ( option : SelectValue < DataConditionGroupLogicType > ) =>
67
+ actions . updateWhenLogicType ( option . value )
68
+ }
69
+ required
70
+ flexibleControlStateSize
71
+ options = { TRIGGER_MATCH_OPTIONS }
72
+ size = "xs"
73
+ />
74
+ </ EmbeddedWrapper >
75
+ ) ,
76
+ } ) }
77
+ </ StepLead >
78
+ </ Step >
79
+ < DataConditionNodeList
80
+ handlerGroup = { DataConditionHandlerGroupType . WORKFLOW_TRIGGER }
81
+ placeholder = { t ( 'Select a trigger...' ) }
82
+ conditions = { state . triggers . conditions }
83
+ groupId = { state . triggers . id }
84
+ onAddRow = { type => actions . addWhenCondition ( type ) }
85
+ onDeleteRow = { index => actions . removeWhenCondition ( index ) }
86
+ updateCondition = { ( id , comparison ) =>
87
+ actions . updateWhenCondition ( id , comparison )
88
+ }
94
89
/>
95
- ) ) }
96
- < span >
97
- < PurpleTextButton
98
- borderless
99
- icon = { < IconAdd /> }
100
- size = "xs"
101
- onClick = { ( ) => actions . addIf ( ) }
102
- >
103
- { t ( 'If/Then Block' ) }
104
- </ PurpleTextButton >
105
- </ span >
106
- </ Flex >
90
+ { state . actionFilters . map ( actionFilter => (
91
+ < ActionFilterBlock
92
+ key = { `actionFilters.${ actionFilter . id } ` }
93
+ actionFilter = { actionFilter }
94
+ />
95
+ ) ) }
96
+ < span >
97
+ < PurpleTextButton
98
+ borderless
99
+ icon = { < IconAdd /> }
100
+ size = "xs"
101
+ onClick = { ( ) => actions . addIf ( ) }
102
+ >
103
+ { t ( 'If/Then Block' ) }
104
+ </ PurpleTextButton >
105
+ </ span >
106
+ </ Flex >
107
+ </ AutomationBuilderConflictContext . Provider >
107
108
) ;
108
109
}
109
110
110
111
interface ActionFilterBlockProps {
111
112
actionFilter : DataConditionGroup ;
112
- conflictingConditions : string [ ] ;
113
113
}
114
114
115
- function ActionFilterBlock ( {
116
- actionFilter,
117
- conflictingConditions = [ ] ,
118
- } : ActionFilterBlockProps ) {
115
+ function ActionFilterBlock ( { actionFilter} : ActionFilterBlockProps ) {
119
116
const { actions} = useAutomationBuilderContext ( ) ;
120
117
121
118
return (
@@ -164,15 +161,14 @@ function ActionFilterBlock({
164
161
</ Flex >
165
162
< DataConditionNodeList
166
163
handlerGroup = { DataConditionHandlerGroupType . ACTION_FILTER }
167
- placeholder = { t ( 'Filter by... ' ) }
168
- group = { `actionFilters. ${ actionFilter . id } ` }
164
+ placeholder = { t ( 'Any event ' ) }
165
+ groupId = { actionFilter . id }
169
166
conditions = { actionFilter ?. conditions || [ ] }
170
167
onAddRow = { type => actions . addIfCondition ( actionFilter . id , type ) }
171
168
onDeleteRow = { id => actions . removeIfCondition ( actionFilter . id , id ) }
172
169
updateCondition = { ( id , params ) =>
173
170
actions . updateIfCondition ( actionFilter . id , id , params )
174
171
}
175
- conflictingConditionIds = { conflictingConditions }
176
172
/>
177
173
</ Flex >
178
174
</ Step >
0 commit comments