Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Commit

Permalink
fix(bridge): project delete dialog was not closed (#5091)
Browse files Browse the repository at this point in the history
Signed-off-by: Klaus Strießnig <k.striessnig@gmail.com>
  • Loading branch information
Kirdock committed Sep 1, 2021
1 parent 17b8aae commit acdbd48
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
Expand Up @@ -160,6 +160,10 @@ describe('KtbProjectSettingsComponent', () => {
// when
const router = TestBed.inject(Router);
const routeSpy = jest.spyOn(router, 'navigate');
dataService.loadProjects = jest.fn().mockImplementation(() => {
// @ts-ignore
dataService._projects.next(dataService._projects.getValue().filter(project => project.projectName !== 'sockshop'));
});
component.deleteProject('sockshop');

// then
Expand Down
Expand Up @@ -9,7 +9,7 @@ import { DataService } from '../../_services/data.service';
import { DtToast } from '@dynatrace/barista-components/toast';
import { NotificationsService } from '../../_services/notifications.service';
import { EventService } from '../../_services/event.service';
import { filter, map, switchMap, take, takeUntil } from 'rxjs/operators';
import { filter, map, switchMap, takeUntil } from 'rxjs/operators';
import { Project } from '../../_models/project';
import { FormUtils } from '../../_utils/form.utils';
import { NotificationType, TemplateRenderedNotifications } from '../../_models/notification';
Expand Down Expand Up @@ -187,29 +187,26 @@ export class KtbProjectSettingsComponent implements OnInit, OnDestroy {
public deleteProject(projectName: string): void {
this.eventService.deletionProgressEvent.next({isInProgress: true});

this.dataService.projects
this.dataService.projectExists(projectName)
.pipe(
takeUntil(this.unsubscribe$),
take(1),
filter(status => status === false),
).subscribe(() => {
this.router.navigate(['/', 'dashboard']);
});

this.dataService.deleteProject(projectName)
.pipe(
takeUntil(this.unsubscribe$),
take(1),
).subscribe(() => {
this.dataService.loadProjects();
this.eventService.deletionProgressEvent.next({isInProgress: false, result: DeleteResult.SUCCESS});
}, (err) => {
const deletionError = 'Project could not be deleted: ' + err.message;
this.eventService.deletionProgressEvent.next({
error: deletionError,
isInProgress: false,
result: DeleteResult.ERROR,
.subscribe(() => {
this.dataService.loadProjects();
this.eventService.deletionProgressEvent.next({isInProgress: false, result: DeleteResult.SUCCESS});
}, (err) => {
const deletionError = 'Project could not be deleted: ' + err.message;
this.eventService.deletionProgressEvent.next({
error: deletionError,
isInProgress: false,
result: DeleteResult.ERROR,
});
});
});
}

public reset(): void {
Expand Down

0 comments on commit acdbd48

Please sign in to comment.