@@ -13,6 +13,7 @@ import { ProvisionerService } from '../../services/provisioner.service';
1313import { AzureService } from '../../services/azure.service' ;
1414import { AppUser } from '../../models/app-user' ;
1515import { CreateIncidentParameter } from '../../openapi/component-provisioner' ;
16+ import { ComponentStatus } from '../../models/component-status' ;
1617
1718@Component ( {
1819 selector : 'app-project-components-screen' ,
@@ -139,6 +140,13 @@ export class ProjectComponentsScreenComponent implements OnInit, OnDestroy {
139140 }
140141
141142 private submitDeletionRequest ( result : RequestDeletionDialogResult ) : void {
143+ // Apply optimistic UI and set the current component to deleting status
144+ const componentIndex = this . projectComponents . findIndex ( c => c . name === result . componentName ) ;
145+ let originalStatus : ComponentStatus | undefined = undefined ;
146+ if ( componentIndex !== - 1 ) {
147+ originalStatus = this . projectComponents [ componentIndex ] . status ;
148+ this . projectComponents [ componentIndex ] . status = 'DELETING' ;
149+ }
142150 this . azureService . getRefreshedAccessToken ( ) . subscribe ( {
143151 next : ( accessToken ) => {
144152 /* eslint-disable @typescript-eslint/no-wrapper-object-types */
@@ -181,19 +189,19 @@ export class ProjectComponentsScreenComponent implements OnInit, OnDestroy {
181189 result . componentName ,
182190 incidentParams
183191 ) . subscribe ( {
184- next : ( ) => this . onDeletionRequestSuccess ( result . componentName ) ,
185- error : ( error ) => this . onDeletionRequestError ( error )
192+ next : ( ) => this . onDeletionRequestSuccess ( ) ,
193+ error : ( error ) => {
194+ this . onDeletionRequestError ( error )
195+ if ( originalStatus && componentIndex !== - 1 ) {
196+ this . projectComponents [ componentIndex ] . status = originalStatus ;
197+ }
198+ }
186199 } ) ;
187200 }
188201 } ) ;
189202 }
190203
191- private onDeletionRequestSuccess ( componentName : string ) : void {
192- // Apply optimistic UI and set the current component to deleting status
193- const componentIndex = this . projectComponents . findIndex ( c => c . name === componentName ) ;
194- if ( componentIndex !== - 1 ) {
195- this . projectComponents [ componentIndex ] . status = 'DELETING' ;
196- }
204+ private onDeletionRequestSuccess ( ) : void {
197205 this . toastService . showToast ( {
198206 id : '' ,
199207 read : false ,
0 commit comments