diff --git a/horizon/static/framework/widgets/modal/delete-modal.service.js b/horizon/static/framework/widgets/modal/delete-modal.service.js index a13ed5cdb0..59a6989e46 100644 --- a/horizon/static/framework/widgets/modal/delete-modal.service.js +++ b/horizon/static/framework/widgets/modal/delete-modal.service.js @@ -71,6 +71,7 @@ * @param {function} context.deleteEntity * The function that should be called to delete each entity. * The first argument is the id of the Entity to delete. + * The second argument is the Entity itself. * Note: This callback might need to suppress errors on the * alert service. * @@ -100,7 +101,7 @@ } function deleteEntityPromise(entity) { - return {promise: context.deleteEntity(entity.id), context: entity}; + return {promise: context.deleteEntity(entity.id, entity), context: entity}; } function notify(result) { diff --git a/horizon/static/framework/widgets/modal/delete-modal.service.spec.js b/horizon/static/framework/widgets/modal/delete-modal.service.spec.js index b660b53a78..e968a0d541 100644 --- a/horizon/static/framework/widgets/modal/delete-modal.service.spec.js +++ b/horizon/static/framework/widgets/modal/delete-modal.service.spec.js @@ -117,8 +117,8 @@ $scope.$apply(); - expect(entityAPI.deleteEntity).toHaveBeenCalledWith('1'); - expect(entityAPI.deleteEntity).toHaveBeenCalledWith('2'); + expect(entityAPI.deleteEntity).toHaveBeenCalledWith('1', {name: 'entity1', id: '1'}); + expect(entityAPI.deleteEntity).toHaveBeenCalledWith('2', {name: 'entity2', id: '2'}); expect(toastService.add).toHaveBeenCalledWith('success', 'Deleted : entity1, entity2.'); expect($scope.$emit).toHaveBeenCalledWith('custom_delete_event_passed', [ '1', '2' ]); }); @@ -134,7 +134,7 @@ $scope.$apply(); - expect(entityAPI.deleteEntity).toHaveBeenCalledWith('bad'); + expect(entityAPI.deleteEntity).toHaveBeenCalledWith('bad', {name: 'entity1', id: 'bad'}); expect(toastService.add).toHaveBeenCalledWith('error', 'Unable to delete: entity1.'); expect($scope.$emit).toHaveBeenCalledWith('custom_delete_event_failed', ['bad']); }); @@ -153,8 +153,8 @@ $scope.$apply(); - expect(entityAPI.deleteEntity).toHaveBeenCalledWith('bad'); - expect(entityAPI.deleteEntity).toHaveBeenCalledWith('1'); + expect(entityAPI.deleteEntity).toHaveBeenCalledWith('bad', {name: 'bad_entity', id: 'bad'}); + expect(entityAPI.deleteEntity).toHaveBeenCalledWith('1', {name: 'entity2', id: '1'}); expect(toastService.add).toHaveBeenCalledWith('success', 'Deleted : entity2.'); expect(toastService.add).toHaveBeenCalledWith('error', 'Unable to delete: bad_entity.'); expect($scope.$emit).toHaveBeenCalledWith('custom_delete_event_passed', ['1']);