From 70d47a5b1fd194879ead1a2730add3019d96410f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stephan=20M=C3=BCller?= Date: Fri, 27 Jul 2018 16:15:07 +0200 Subject: [PATCH] mgr/dashboard: Fix duplicate error messages MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Duplicate error messages currently appear if the task wrapper service is used. It calls 'notifyTask' on a failed task, this would be fine if we didn't have the API interceptor, which watches all API requests and triggers 'notifyTask' itself if an error appears. Fixes issue #25139 Signed-off-by: Stephan Müller --- .../src/app/shared/services/task-wrapper.service.spec.ts | 7 ++++++- .../src/app/shared/services/task-wrapper.service.ts | 1 - 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-wrapper.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-wrapper.service.spec.ts index 45910cd1905e..acd09955e784 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-wrapper.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-wrapper.service.spec.ts @@ -54,6 +54,7 @@ describe('TaskWrapperService', () => { notify = TestBed.get(NotificationService); summaryService = TestBed.get(SummaryService); spyOn(notify, 'show'); + spyOn(notify, 'notifyTask').and.stub(); spyOn(service, '_handleExecutingTasks').and.callThrough(); spyOn(summaryService, 'addRunningTask').and.callThrough(); }); @@ -77,7 +78,6 @@ describe('TaskWrapperService', () => { spyOn(taskManager, 'subscribe').and.callFake((name, metadata, onTaskFinished) => { onTaskFinished(); }); - spyOn(notify, 'notifyTask').and.stub(); callWrapTaskAroundCall(202, 'async').subscribe(null, null, () => (passed = true)); expect(notify.notifyTask).toHaveBeenCalled(); }); @@ -87,6 +87,11 @@ describe('TaskWrapperService', () => { expect(service._handleExecutingTasks).not.toHaveBeenCalled(); expect(passed).toBeTruthy(); expect(summaryService.addRunningTask).not.toHaveBeenCalled(); + /** + * A notification will be raised by the API interceptor. + * This resolves this bug https://tracker.ceph.com/issues/25139 + */ + expect(notify.notifyTask).not.toHaveBeenCalled(); }); }); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-wrapper.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-wrapper.service.ts index bed55d3f608d..7409608fefd2 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-wrapper.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-wrapper.service.ts @@ -38,7 +38,6 @@ export class TaskWrapperService { (resp) => { task.success = false; task.exception = resp.error; - this.notificationService.notifyTask(task); observer.error(); }, () => { -- 2.47.3