Fix the path of the panel navigator

This commit also introduces an admin_urls module, because there
are two containers panels (admin and project) and each panel
need to have a dedicate instance of urlpatterns.
In before, both panels share the same urlpattern in the urls
module, which lead to issues that both panels try to set
the 'dashboard' and 'panel' parameters in the same view.
As a result, the UI could use the wrong dashboard and panel
to render the view.

Change-Id: I046742fa5889be6b2cf9e616b7fd2f62928c7147
Closes-Bug: #1822925
This commit is contained in:
Hongbin Lu 2019-05-25 22:16:11 +00:00
parent 7204d987af
commit aad1d14050
3 changed files with 26 additions and 8 deletions

View File

@ -0,0 +1,23 @@
# 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.
from django.conf.urls import url
from django.utils.translation import ugettext_lazy as _
from horizon.browsers import views
from zun_ui.content.container.containers import views as zun_views
title = _("Containers")
urlpatterns = [
url(r'^(?P<container_id>[^/]+)/console',
zun_views.SerialConsoleView.as_view(), name='console'),
url('', views.AngularIndexView.as_view(title=title), name='index'),
]

View File

@ -26,3 +26,4 @@ class Containers(horizon.Panel):
class ContainersForAdmin(horizon.Panel): class ContainersForAdmin(horizon.Panel):
name = _("Containers") name = _("Containers")
slug = "container.containers" slug = "container.containers"
urls = "admin_urls"

View File

@ -22,7 +22,6 @@
'$location', '$location',
'horizon.app.core.detailRoute', 'horizon.app.core.detailRoute',
'horizon.app.core.openstack-service-api.zun', 'horizon.app.core.openstack-service-api.zun',
'horizon.framework.util.navigations.service'
]; ];
/* /*
@ -33,7 +32,7 @@
* This service provides functions that are used through * This service provides functions that are used through
* the containers features. * the containers features.
*/ */
function containersService($location, detailRoute, zun, navigation) { function containersService($location, detailRoute, zun) {
return { return {
getDefaultIndexUrl: getDefaultIndexUrl, getDefaultIndexUrl: getDefaultIndexUrl,
getDetailsPath: getDetailsPath, getDetailsPath: getDetailsPath,
@ -42,19 +41,14 @@
}; };
function getDefaultIndexUrl() { function getDefaultIndexUrl() {
var dashboard, breadcrumbDashboard; var dashboard;
var path = "/container/containers"; var path = "/container/containers";
if (zun.isAdmin()) { if (zun.isAdmin()) {
dashboard = "/admin"; dashboard = "/admin";
breadcrumbDashboard = gettext("Admin");
} else { } else {
dashboard = "/project"; dashboard = "/project";
breadcrumbDashboard = gettext("Project");
} }
var url = dashboard + path + "/"; var url = dashboard + path + "/";
navigation.setBreadcrumb([
breadcrumbDashboard, gettext("Container"), gettext("Containers")]);
navigation.expandNavigationByUrl(url);
return url; return url;
} }
/* /*