Fix redirect after deleting from details page
On apache environments, when WEBROOT is "/dashboard/" and not "/", redirection after deleting from Angular details page is broken. If we go to image/key pair/server group/etc details page, and delete it from this page, redirect url is "/dashboard/dashboard/project/..." instead of "/dashboard/project/..." This patch switches from using WEBROOT depentent panel navigation to getting default index url directly from details view controller. It also cleans up a work around that was implemented for some pages. Change-Id: I6bd06ea479f473a319f8100cbf8d168424b62461
This commit is contained in:
@@ -113,7 +113,7 @@
|
|||||||
function loadIndexView() {
|
function loadIndexView() {
|
||||||
spinnerService.hideModalSpinner();
|
spinnerService.hideModalSpinner();
|
||||||
ctrl.showDetails = false;
|
ctrl.showDetails = false;
|
||||||
var url = navigationsService.getActivePanelUrl();
|
var url = ctrl.resourceType.getDefaultIndexUrl();
|
||||||
$location.url(url);
|
$location.url(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,8 +124,8 @@
|
|||||||
// That return includes the id and type of each created, updated, deleted
|
// That return includes the id and type of each created, updated, deleted
|
||||||
// and failed item.
|
// and failed item.
|
||||||
// Currently just refreshes the display each time.
|
// Currently just refreshes the display each time.
|
||||||
if (result.failed && result.deleted &&
|
if ((angular.isUndefined(result)) || (result.failed && result.deleted &&
|
||||||
result.failed.length === 0 && result.deleted.length > 0) {
|
result.failed.length === 0 && result.deleted.length > 0)) {
|
||||||
loadIndexView();
|
loadIndexView();
|
||||||
} else if (result) {
|
} else if (result) {
|
||||||
spinnerService.showModalSpinner(gettext('Please Wait'));
|
spinnerService.showModalSpinner(gettext('Please Wait'));
|
||||||
|
@@ -162,23 +162,23 @@
|
|||||||
|
|
||||||
it('handles deleted results and redirect back to index view', function() {
|
it('handles deleted results and redirect back to index view', function() {
|
||||||
spyOn(actionResultService, 'getIdsOfType').and.returnValue([1, 2, 3]);
|
spyOn(actionResultService, 'getIdsOfType').and.returnValue([1, 2, 3]);
|
||||||
spyOn(navigationsService, 'getActivePanelUrl');
|
spyOn(ctrl.resourceType, 'getDefaultIndexUrl');
|
||||||
var result = $q.defer();
|
var result = $q.defer();
|
||||||
result.resolve({created: [], updated: [], deleted: ['image1'], failed: []});
|
result.resolve({created: [], updated: [], deleted: ['image1'], failed: []});
|
||||||
ctrl.resultHandler(result.promise);
|
ctrl.resultHandler(result.promise);
|
||||||
$timeout.flush();
|
$timeout.flush();
|
||||||
expect(ctrl.showDetails).toBe(false);
|
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() {
|
it('handles general results and do not redirect back to index view', function() {
|
||||||
spyOn(navigationsService, 'getActivePanelUrl');
|
spyOn(ctrl.resourceType, 'getDefaultIndexUrl');
|
||||||
var result = $q.defer();
|
var result = $q.defer();
|
||||||
result.resolve({created: [], updated: ['image1'], deleted: [], failed: []});
|
result.resolve({created: [], updated: ['image1'], deleted: [], failed: []});
|
||||||
ctrl.resultHandler(result.promise);
|
ctrl.resultHandler(result.promise);
|
||||||
$timeout.flush();
|
$timeout.flush();
|
||||||
expect(ctrl.showDetails).toBe(false);
|
expect(ctrl.showDetails).toBe(false);
|
||||||
expect(navigationsService.getActivePanelUrl).not.toHaveBeenCalled();
|
expect(ctrl.resourceType.getDefaultIndexUrl).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@@ -81,14 +81,6 @@
|
|||||||
deleteModalResult.fail.forEach(function markFailed(item) {
|
deleteModalResult.fail.forEach(function markFailed(item) {
|
||||||
actionResult.failed(resourceType, item.context.id);
|
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) {
|
function labelize(count) {
|
||||||
|
@@ -79,13 +79,6 @@
|
|||||||
deleteModalResult.fail.forEach(function markFailed(item) {
|
deleteModalResult.fail.forEach(function markFailed(item) {
|
||||||
actionResult.failed(serverGroupResourceType, item.context.id);
|
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) {
|
function labelize(count) {
|
||||||
|
@@ -135,7 +135,8 @@
|
|||||||
|
|
||||||
function testDeleteResult() {
|
function testDeleteResult() {
|
||||||
$location.path("ngdetails/OS::Nova::ServerGroup/1");
|
$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'};
|
var servergroup = {id: 1, name: 'sg1'};
|
||||||
deferredModal.resolve({fail: [], pass:[{data:{"data": "", "status": "204"},
|
deferredModal.resolve({fail: [], pass:[{data:{"data": "", "status": "204"},
|
||||||
context:servergroup}]});
|
context:servergroup}]});
|
||||||
@@ -147,7 +148,6 @@
|
|||||||
var deleteFunction = contextArg.deleteEntity;
|
var deleteFunction = contextArg.deleteEntity;
|
||||||
deleteFunction(servergroup.id);
|
deleteFunction(servergroup.id);
|
||||||
expect(novaAPI.deleteServerGroup).toHaveBeenCalledWith(servergroup.id, true);
|
expect(novaAPI.deleteServerGroup).toHaveBeenCalledWith(servergroup.id, true);
|
||||||
expect($location.path()).toEqual("/project/server_groups");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}); // end of delete modal
|
}); // end of delete modal
|
||||||
|
@@ -82,17 +82,6 @@
|
|||||||
result.fail.forEach(function markFailed(item) {
|
result.fail.forEach(function markFailed(item) {
|
||||||
actionResult.failed(resourceType, item.context.id);
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user