NG details view route should not be '/project/...'

Right now the route includes the name 'project'
but we may have details view for 'identity' and
'admin' too, so it should be more general.

Picked just 'ngdetails' instead and moved this out as a
constant. Since this constant needs to be used
by the config blocks, I moved it out into its own
constant module.

Change-Id: I7603250dd70eb40568aa74be2ae4821ee8fcefcc
Closes-Bug: #1641250
This commit is contained in:
Cindy Lu 2016-11-11 16:32:13 -08:00
parent 6fa0a90318
commit c73e1c8fa8
9 changed files with 67 additions and 21 deletions

View File

@ -23,7 +23,8 @@
'$q', '$q',
'horizon.app.core.openstack-service-api.keystone', 'horizon.app.core.openstack-service-api.keystone',
'horizon.app.core.openstack-service-api.policy', 'horizon.app.core.openstack-service-api.policy',
'horizon.app.core.openstack-service-api.settings' 'horizon.app.core.openstack-service-api.settings',
'horizon.app.core.detailRoute'
]; ];
/* /*
@ -36,7 +37,7 @@
* but do not need to be restricted to such use. Each exposed function * but do not need to be restricted to such use. Each exposed function
* is documented below. * is documented below.
*/ */
function domainService($q, keystone, policy, settingsService) { function domainService($q, keystone, policy, settingsService, detailRoute) {
return { return {
getDetailsPath: getDetailsPath, getDetailsPath: getDetailsPath,
getDomainPromise: getDomainPromise, getDomainPromise: getDomainPromise,
@ -52,7 +53,7 @@
* view. * view.
*/ */
function getDetailsPath(item) { function getDetailsPath(item) {
return 'project/ngdetails/OS::Keystone::Domain/' + item.id; return detailRoute + 'OS::Keystone::Domain/' + item.id;
} }
/* /*

View File

@ -15,15 +15,16 @@
"use strict"; "use strict";
describe('domain service', function() { describe('domain service', function() {
var service, $scope; var service, $scope, detailRoute;
beforeEach(module('horizon.dashboard.identity.domains')); beforeEach(module('horizon.dashboard.identity.domains'));
beforeEach(inject(function($injector) { beforeEach(inject(function($injector) {
service = $injector.get('horizon.dashboard.identity.domains.service'); service = $injector.get('horizon.dashboard.identity.domains.service');
detailRoute = $injector.get('horizon.app.core.detailRoute');
})); }));
it("getDetailsPath creates urls using the item's ID", function() { it("getDetailsPath creates urls using the item's ID", function() {
var myItem = {id: "1234"}; var myItem = {id: "1234"};
expect(service.getDetailsPath(myItem)).toBe('project/ngdetails/OS::Keystone::Domain/1234'); expect(service.getDetailsPath(myItem)).toBe(detailRoute + 'OS::Keystone::Domain/1234');
}); });
describe('listDomains', function() { describe('listDomains', function() {

View File

@ -21,14 +21,15 @@
userService.$inject = [ userService.$inject = [
'$q', '$q',
'horizon.app.core.openstack-service-api.keystone' 'horizon.app.core.openstack-service-api.keystone',
'horizon.app.core.detailRoute'
]; ];
/* /*
* @ngdoc factory * @ngdoc factory
* @name horizon.dashboard.identity.users.service * @name horizon.dashboard.identity.users.service
*/ */
function userService($q, keystone) { function userService($q, keystone, detailRoute) {
return { return {
getDetailsPath: getDetailsPath, getDetailsPath: getDetailsPath,
getUserPromise: getUserPromise, getUserPromise: getUserPromise,
@ -43,7 +44,7 @@
* Given an user object, returns the relative path to the details view. * Given an user object, returns the relative path to the details view.
*/ */
function getDetailsPath(item) { function getDetailsPath(item) {
return 'project/ngdetails/OS::Keystone::User/' + item.id; return detailRoute + 'OS::Keystone::User/' + item.id;
} }
/* /*

View File

@ -17,19 +17,20 @@
"use strict"; "use strict";
describe('Identity user service', function() { describe('Identity user service', function() {
var service, keystone, scope, $q; var service, keystone, scope, $q, detailRoute;
beforeEach(module('horizon.dashboard.identity.users')); beforeEach(module('horizon.dashboard.identity.users'));
beforeEach(inject(function($injector, _$q_) { beforeEach(inject(function($injector, _$q_) {
service = $injector.get('horizon.dashboard.identity.users.service'); service = $injector.get('horizon.dashboard.identity.users.service');
keystone = $injector.get('horizon.app.core.openstack-service-api.keystone'); keystone = $injector.get('horizon.app.core.openstack-service-api.keystone');
detailRoute = $injector.get('horizon.app.core.detailRoute');
scope = $injector.get('$rootScope').$new(); scope = $injector.get('$rootScope').$new();
$q = _$q_; $q = _$q_;
})); }));
it("getDetailsPath creates proper url", function() { it("getDetailsPath creates proper url", function() {
var item = {id: 614}; var item = {id: 614};
expect(service.getDetailsPath(item)).toBe('project/ngdetails/OS::Keystone::User/614'); expect(service.getDetailsPath(item)).toBe(detailRoute + 'OS::Keystone::User/614');
}); });
describe('getUsersPromise', function() { describe('getUsersPromise', function() {

View File

@ -0,0 +1,32 @@
/*
* (c) Copyright 2016 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
(function () {
'use strict';
/**
* @ngdoc overview
* @name horizon.app.core.constants
* @description
*
* # horizon.app.core.constants
*
* This module hosts constants used by configuration blocks.
*/
angular
.module('horizon.app.core.constants', [])
.constant('horizon.app.core.detailRoute', 'ngdetails/');
})();

View File

@ -32,6 +32,7 @@
angular angular
.module('horizon.app.core', [ .module('horizon.app.core', [
'horizon.app.core.conf', 'horizon.app.core.conf',
'horizon.app.core.constants',
'horizon.app.core.cloud-services', 'horizon.app.core.cloud-services',
'horizon.app.core.flavors', 'horizon.app.core.flavors',
'horizon.app.core.images', 'horizon.app.core.images',
@ -47,13 +48,19 @@
// becomes available. For now there is no volumes module. // becomes available. For now there is no volumes module.
.constant('horizon.app.core.volumes.resourceType', VOLUME_RESOURCE_TYPE); .constant('horizon.app.core.volumes.resourceType', VOLUME_RESOURCE_TYPE);
config.$inject = ['$provide', '$windowProvider', '$routeProvider']; config.$inject = [
'$provide',
'$windowProvider',
'$routeProvider',
'horizon.app.core.detailRoute'
];
function config($provide, $windowProvider, $routeProvider) { function config($provide, $windowProvider, $routeProvider, detailRoute) {
var path = $windowProvider.$get().STATIC_URL + 'app/core/'; var path = $windowProvider.$get().STATIC_URL + 'app/core/';
$provide.constant('horizon.app.core.basePath', path); $provide.constant('horizon.app.core.basePath', path);
$routeProvider $routeProvider
.when('/project/ngdetails/:type/:path*', { .when('/' + detailRoute + ':type/:path*', {
templateUrl: $windowProvider.$get().STATIC_URL + templateUrl: $windowProvider.$get().STATIC_URL +
'framework/widgets/details/routed-details-view.html' 'framework/widgets/details/routed-details-view.html'
}); });

View File

@ -277,7 +277,8 @@
config.$inject = [ config.$inject = [
'$provide', '$provide',
'$windowProvider', '$windowProvider',
'$routeProvider' '$routeProvider',
'horizon.app.core.detailRoute'
]; ];
/** /**
@ -288,7 +289,7 @@
* @description Routes used by this module. * @description Routes used by this module.
* @returns {undefined} Returns nothing * @returns {undefined} Returns nothing
*/ */
function config($provide, $windowProvider, $routeProvider) { function config($provide, $windowProvider, $routeProvider, detailRoute) {
var path = $windowProvider.$get().STATIC_URL + 'app/core/images/'; var path = $windowProvider.$get().STATIC_URL + 'app/core/images/';
$provide.constant('horizon.app.core.images.basePath', path); $provide.constant('horizon.app.core.images.basePath', path);
@ -309,7 +310,7 @@
}); });
function goToAngularDetails(params) { function goToAngularDetails(params) {
return 'project/ngdetails/OS::Glance::Image/' + params.id; return detailRoute + 'OS::Glance::Image/' + params.id;
} }
} }

View File

@ -23,7 +23,8 @@
'$filter', '$filter',
'horizon.app.core.openstack-service-api.glance', 'horizon.app.core.openstack-service-api.glance',
'horizon.app.core.openstack-service-api.userSession', 'horizon.app.core.openstack-service-api.userSession',
'horizon.app.core.images.transitional-statuses' 'horizon.app.core.images.transitional-statuses',
'horizon.app.core.detailRoute'
]; ];
/* /*
@ -36,7 +37,7 @@
* but do not need to be restricted to such use. Each exposed function * but do not need to be restricted to such use. Each exposed function
* is documented below. * is documented below.
*/ */
function imageService($filter, glance, userSession, transitionalStatuses) { function imageService($filter, glance, userSession, transitionalStatuses, detailRoute) {
var version; var version;
return { return {
@ -56,7 +57,7 @@
* view. * view.
*/ */
function getDetailsPath(item) { function getDetailsPath(item) {
return 'project/ngdetails/OS::Glance::Image/' + item.id; return detailRoute + 'OS::Glance::Image/' + item.id;
} }
/* /*

View File

@ -17,15 +17,16 @@
"use strict"; "use strict";
describe('images service', function() { describe('images service', function() {
var service; var service, detailRoute;
beforeEach(module('horizon.app.core.images')); beforeEach(module('horizon.app.core.images'));
beforeEach(inject(function($injector) { beforeEach(inject(function($injector) {
service = $injector.get('horizon.app.core.images.service'); service = $injector.get('horizon.app.core.images.service');
detailRoute = $injector.get('horizon.app.core.detailRoute');
})); }));
it("getDetailsPath creates urls using the item's ID", function() { it("getDetailsPath creates urls using the item's ID", function() {
var myItem = {id: "1234"}; var myItem = {id: "1234"};
expect(service.getDetailsPath(myItem)).toBe('project/ngdetails/OS::Glance::Image/1234'); expect(service.getDetailsPath(myItem)).toBe(detailRoute + 'OS::Glance::Image/1234');
}); });
describe('imageType', function() { describe('imageType', function() {