@@ -11,6 +11,7 @@ import {addErrorMessage, addSuccessMessage} from 'sentry/actionCreators/indicato
1111import { CompactSelect , type SelectOption } from 'sentry/components/core/compactSelect' ;
1212import { Flex } from 'sentry/components/core/layout/flex' ;
1313import { Switch } from 'sentry/components/core/switch' ;
14+ import { useUpdateBulkAutofixAutomationSettings } from 'sentry/components/events/autofix/preferences/hooks/useBulkAutofixAutomationSettings' ;
1415import {
1516 GuidedSteps ,
1617 useGuidedStepsContext ,
@@ -70,6 +71,9 @@ export function ConfigureRootCauseAnalysisStep() {
7071 const { mutate : submitOnboarding , isPending : isSubmitOnboardingPending } =
7172 useSubmitSeerOnboarding ( ) ;
7273
74+ const { mutate : updateAutofix , isPending : isUpdateAutofixPending } =
75+ useUpdateBulkAutofixAutomationSettings ( ) ;
76+
7377 useEffect ( ( ) => {
7478 if ( ! isCodeMappingsLoading && codeMappingsMap . size > 0 ) {
7579 const additionalMappings : Record < string , string [ ] > = { } ;
@@ -135,26 +139,56 @@ export function ConfigureRootCauseAnalysisStep() {
135139 return ;
136140 }
137141
138- submitOnboarding (
139- {
140- fixes : true ,
141- pr_creation : autoCreatePREnabled ,
142- project_repo_mapping : projectRepoMapping ,
143- } ,
144- {
145- onSuccess : ( ) => {
146- addSuccessMessage ( t ( 'Root Cause Analysis settings saved successfully' ) ) ;
147- setCurrentStep ( currentStep + 1 ) ;
148- } ,
149- onError : ( ) => {
150- addErrorMessage ( t ( 'Failed to save settings' ) ) ;
151- } ,
152- }
153- ) ;
142+ const doUpdateAutofix = ( ) =>
143+ new Promise < void > ( ( resolve , reject ) => {
144+ updateAutofix (
145+ {
146+ autofixAutomationTuning : 'medium' ,
147+ projectIds : Object . keys ( projectRepoMapping ) ,
148+ } ,
149+ {
150+ onSuccess : ( ) => {
151+ resolve ( ) ;
152+ } ,
153+ onError : ( ) => {
154+ reject ( new Error ( t ( 'Failed to update autofix settings' ) ) ) ;
155+ } ,
156+ }
157+ ) ;
158+ } ) ;
159+
160+ const doSubmitOnboarding = ( ) =>
161+ new Promise < void > ( ( resolve , reject ) => {
162+ submitOnboarding (
163+ {
164+ fixes : true ,
165+ pr_creation : autoCreatePREnabled ,
166+ project_repo_mapping : projectRepoMapping ,
167+ } ,
168+ {
169+ onSuccess : ( ) => {
170+ resolve ( ) ;
171+ } ,
172+ onError : ( ) => {
173+ reject ( new Error ( t ( 'Failed to save settings' ) ) ) ;
174+ } ,
175+ }
176+ ) ;
177+ } ) ;
178+
179+ Promise . all ( [ doUpdateAutofix ( ) , doSubmitOnboarding ( ) ] )
180+ . then ( ( ) => {
181+ addSuccessMessage ( t ( 'Root Cause Analysis settings saved successfully' ) ) ;
182+ setCurrentStep ( currentStep + 1 ) ;
183+ } )
184+ . catch ( ( ) => {
185+ addErrorMessage ( t ( 'Failed to save settings' ) ) ;
186+ } ) ;
154187 } , [
155188 setCurrentStep ,
156189 currentStep ,
157190 submitOnboarding ,
191+ updateAutofix ,
158192 repositoryProjectMapping ,
159193 selectedRootCauseAnalysisRepositories ,
160194 autoCreatePREnabled ,
@@ -287,12 +321,16 @@ export function ConfigureRootCauseAnalysisStep() {
287321 size = "md"
288322 onClick = { handleNextStep }
289323 priority = { isFinishDisabled ? 'default' : 'primary' }
290- disabled = { isSubmitOnboardingPending || isFinishDisabled }
324+ disabled = {
325+ isUpdateAutofixPending || isSubmitOnboardingPending || isFinishDisabled
326+ }
291327 aria-label = { t ( 'Next Step' ) }
292328 >
293329 { t ( 'Next Step' ) }
294330 </ Button >
295- { isSubmitOnboardingPending && < InlineLoadingIndicator size = { 20 } /> }
331+ { ( isUpdateAutofixPending || isSubmitOnboardingPending ) && (
332+ < InlineLoadingIndicator size = { 20 } />
333+ ) }
296334 </ GuidedSteps . ButtonWrapper >
297335 </ Fragment >
298336 ) ;
0 commit comments