summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2022-09-19 18:25:33 +0000
committerGerrit Code Review <review@openstack.org>2022-09-19 18:25:33 +0000
commite53f5ce8fbfb6b23e22ae480cd4b7015eea9aaf5 (patch)
tree9d2dc78b3846a9cf78286aa1ff33af7aff4bdc11
parentfee268dd8922772db4870cd12f412c0b0410c020 (diff)
parent1011d4237ebe055a969e14076c69cddd43cf0578 (diff)
downloadhorizon-e53f5ce8fbfb6b23e22ae480cd4b7015eea9aaf5.tar.gz
Merge "Fix redirect after deleting from details page"
-rw-r--r--horizon/static/framework/widgets/details/routed-details-view.controller.js6
-rw-r--r--horizon/static/framework/widgets/details/routed-details-view.controller.spec.js8
-rw-r--r--openstack_dashboard/static/app/core/keypairs/actions/delete.service.js8
-rw-r--r--openstack_dashboard/static/app/core/server_groups/actions/delete.action.service.js7
-rw-r--r--openstack_dashboard/static/app/core/server_groups/actions/delete.action.service.spec.js4
-rw-r--r--openstack_dashboard/static/app/core/trunks/actions/delete.action.service.js11
6 files changed, 9 insertions, 35 deletions
diff --git a/horizon/static/framework/widgets/details/routed-details-view.controller.js b/horizon/static/framework/widgets/details/routed-details-view.controller.js
index cea3e4102..879b1311d 100644
--- a/horizon/static/framework/widgets/details/routed-details-view.controller.js
+++ b/horizon/static/framework/widgets/details/routed-details-view.controller.js
@@ -113,7 +113,7 @@
function loadIndexView() {
spinnerService.hideModalSpinner();
ctrl.showDetails = false;
- var url = navigationsService.getActivePanelUrl();
+ var url = ctrl.resourceType.getDefaultIndexUrl();
$location.url(url);
}
@@ -124,8 +124,8 @@
// That return includes the id and type of each created, updated, deleted
// and failed item.
// Currently just refreshes the display each time.
- if (result.failed && result.deleted &&
- result.failed.length === 0 && result.deleted.length > 0) {
+ if ((angular.isUndefined(result)) || (result.failed && result.deleted &&
+ result.failed.length === 0 && result.deleted.length > 0)) {
loadIndexView();
} else if (result) {
spinnerService.showModalSpinner(gettext('Please Wait'));
diff --git a/horizon/static/framework/widgets/details/routed-details-view.controller.spec.js b/horizon/static/framework/widgets/details/routed-details-view.controller.spec.js
index a765af331..02b51028b 100644
--- a/horizon/static/framework/widgets/details/routed-details-view.controller.spec.js
+++ b/horizon/static/framework/widgets/details/routed-details-view.controller.spec.js
@@ -162,23 +162,23 @@
it('handles deleted results and redirect back to index view', function() {
spyOn(actionResultService, 'getIdsOfType').and.returnValue([1, 2, 3]);
- spyOn(navigationsService, 'getActivePanelUrl');
+ spyOn(ctrl.resourceType, 'getDefaultIndexUrl');
var result = $q.defer();
result.resolve({created: [], updated: [], deleted: ['image1'], failed: []});
ctrl.resultHandler(result.promise);
$timeout.flush();
expect(ctrl.showDetails).toBe(false);
- expect(navigationsService.getActivePanelUrl).toHaveBeenCalled();
+ expect(ctrl.resourceType.getDefaultIndexUrl).toHaveBeenCalled();
});
it('handles general results and do not redirect back to index view', function() {
- spyOn(navigationsService, 'getActivePanelUrl');
+ spyOn(ctrl.resourceType, 'getDefaultIndexUrl');
var result = $q.defer();
result.resolve({created: [], updated: ['image1'], deleted: [], failed: []});
ctrl.resultHandler(result.promise);
$timeout.flush();
expect(ctrl.showDetails).toBe(false);
- expect(navigationsService.getActivePanelUrl).not.toHaveBeenCalled();
+ expect(ctrl.resourceType.getDefaultIndexUrl).not.toHaveBeenCalled();
});
});
diff --git a/openstack_dashboard/static/app/core/keypairs/actions/delete.service.js b/openstack_dashboard/static/app/core/keypairs/actions/delete.service.js
index a053ee544..439249088 100644
--- a/openstack_dashboard/static/app/core/keypairs/actions/delete.service.js
+++ b/openstack_dashboard/static/app/core/keypairs/actions/delete.service.js
@@ -81,14 +81,6 @@
deleteModalResult.fail.forEach(function markFailed(item) {
actionResult.failed(resourceType, item.context.id);
});
-
- var path = '/project/key_pairs';
- if ($location.url() !== path && actionResult.result.failed.length === 0 &&
- actionResult.result.deleted.length > 0) {
- $location.path(path);
- } else {
- return actionResult.result;
- }
}
function labelize(count) {
diff --git a/openstack_dashboard/static/app/core/server_groups/actions/delete.action.service.js b/openstack_dashboard/static/app/core/server_groups/actions/delete.action.service.js
index 51b8b2285..6d1a325c7 100644
--- a/openstack_dashboard/static/app/core/server_groups/actions/delete.action.service.js
+++ b/openstack_dashboard/static/app/core/server_groups/actions/delete.action.service.js
@@ -79,13 +79,6 @@
deleteModalResult.fail.forEach(function markFailed(item) {
actionResult.failed(serverGroupResourceType, item.context.id);
});
- var path = '/project/server_groups';
- if ($location.url() !== path && actionResult.result.failed.length === 0 &&
- actionResult.result.deleted.length > 0) {
- $location.path(path);
- } else {
- return actionResult.result;
- }
}
function labelize(count) {
diff --git a/openstack_dashboard/static/app/core/server_groups/actions/delete.action.service.spec.js b/openstack_dashboard/static/app/core/server_groups/actions/delete.action.service.spec.js
index 2105a9061..9575caf38 100644
--- a/openstack_dashboard/static/app/core/server_groups/actions/delete.action.service.spec.js
+++ b/openstack_dashboard/static/app/core/server_groups/actions/delete.action.service.spec.js
@@ -135,7 +135,8 @@
function testDeleteResult() {
$location.path("ngdetails/OS::Nova::ServerGroup/1");
- $httpBackend.expectGET('/static/app/core/server_groups/panel.html').respond({});
+ $httpBackend.expectGET('/static/framework/widgets/details/routed-details-view.html')
+ .respond({});
var servergroup = {id: 1, name: 'sg1'};
deferredModal.resolve({fail: [], pass:[{data:{"data": "", "status": "204"},
context:servergroup}]});
@@ -147,7 +148,6 @@
var deleteFunction = contextArg.deleteEntity;
deleteFunction(servergroup.id);
expect(novaAPI.deleteServerGroup).toHaveBeenCalledWith(servergroup.id, true);
- expect($location.path()).toEqual("/project/server_groups");
}
}); // end of delete modal
diff --git a/openstack_dashboard/static/app/core/trunks/actions/delete.action.service.js b/openstack_dashboard/static/app/core/trunks/actions/delete.action.service.js
index bef4dd273..b695e3bfd 100644
--- a/openstack_dashboard/static/app/core/trunks/actions/delete.action.service.js
+++ b/openstack_dashboard/static/app/core/trunks/actions/delete.action.service.js
@@ -82,17 +82,6 @@
result.fail.forEach(function markFailed(item) {
actionResult.failed(resourceType, item.context.id);
});
-
- var path = "admin/trunks";
- if ($location.url().indexOf("admin") === -1) {
- path = "project/trunks";
- }
- if ($location.url() !== path && actionResult.result.failed.length === 0 &&
- actionResult.result.deleted.length > 0) {
- $location.path(path);
- } else {
- return actionResult.result;
- }
}
}