Instance log and console actions now go to detail tabs.

Fixes bug 969630.

Change-Id: I28a591e5f765300f6a0bca021ef1fa802d277336
This commit is contained in:
Gabriel Hurley 2012-04-02 13:51:50 -07:00
parent 47f44598c8
commit ca5ea82ed0
2 changed files with 22 additions and 6 deletions

View File

@ -24,6 +24,8 @@ from horizon import api
from horizon import tables
from horizon.templatetags import sizeformat
from .tabs import InstanceDetailTabs, LogTab, VNCTab
LOG = logging.getLogger(__name__)
@ -158,22 +160,32 @@ class SnapshotLink(tables.LinkAction):
class ConsoleLink(tables.LinkAction):
name = "console"
verbose_name = _("VNC Console")
url = "horizon:nova:instances_and_volumes:instances:vnc"
url = "horizon:nova:instances_and_volumes:instances:detail"
classes = ("btn-console",)
def allowed(self, request, instance=None):
return instance.status in ACTIVE_STATES
def get_link_url(self, datum):
base_url = super(ConsoleLink, self).get_link_url(datum)
tab_query_string = VNCTab(InstanceDetailTabs).get_query_string()
return "?".join([base_url, tab_query_string])
class LogLink(tables.LinkAction):
name = "log"
verbose_name = _("View Log")
url = "horizon:nova:instances_and_volumes:instances:console"
url = "horizon:nova:instances_and_volumes:instances:detail"
classes = ("btn-log",)
def allowed(self, request, instance=None):
return instance.status in ACTIVE_STATES
def get_link_url(self, datum):
base_url = super(LogLink, self).get_link_url(datum)
tab_query_string = LogTab(InstanceDetailTabs).get_query_string()
return "?".join([base_url, tab_query_string])
class UpdateRow(tables.Row):
ajax = True

View File

@ -247,7 +247,7 @@ class Tab(html.HTMLElement):
preload = True
_active = None
def __init__(self, tab_group, request):
def __init__(self, tab_group, request=None):
super(Tab, self).__init__()
# Priority: constructor, class-defined, fallback
if not self.name:
@ -255,10 +255,11 @@ class Tab(html.HTMLElement):
self.name = unicode(self.name) # Force unicode.
if not self.slug:
raise ValueError("%s must have a slug." % self.__class__.__name__)
self.request = request
self.tab_group = tab_group
self._allowed = self.allowed(request)
self._enabled = self.enabled(request)
self.request = request
if request:
self._allowed = self.allowed(request)
self._enabled = self.enabled(request)
def __repr__(self):
return "<%s: %s>" % (self.__class__.__name__, self.slug)
@ -314,6 +315,9 @@ class Tab(html.HTMLElement):
"""
return SEPARATOR.join([self.tab_group.slug, self.slug])
def get_query_string(self):
return "=".join((self.tab_group.param_name, self.get_id()))
def get_default_classes(self):
"""
Returns a list of the default classes for the tab. Defaults to