Using WrappingColumn to prevent long names breaking table layouts

Now WrappingColumn was introduced in Horizon, So we can using this
to prevent long names breaking table layouts.

Closes-Bug: #1618961
Change-Id: Ic5db239752a147c364823ed9fcd192181098f976
This commit is contained in:
zhurong 2016-08-25 23:12:00 +08:00 committed by Kirill Zaitsev
parent c82809ba9d
commit 9d7f30eef8
5 changed files with 30 additions and 19 deletions

View File

@ -22,6 +22,7 @@ from muranoclient.common import exceptions as exc
from oslo_log import log as logging from oslo_log import log as logging
from muranodashboard import api from muranodashboard import api
from muranodashboard.common import utils as md_utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -71,7 +72,7 @@ class DeleteCategory(tables.DeleteAction):
class CategoriesTable(tables.DataTable): class CategoriesTable(tables.DataTable):
name = tables.Column('name', verbose_name=_('Category Name')) name = md_utils.Column('name', verbose_name=_('Category Name'))
use_artifacts = getattr(settings, 'MURANO_USE_GLARE', False) use_artifacts = getattr(settings, 'MURANO_USE_GLARE', False)
if not use_artifacts: if not use_artifacts:
package_count = tables.Column('package_count', package_count = tables.Column('package_count',

View File

@ -23,6 +23,13 @@ from muranodashboard.dynamic_ui import yaql_expression
import six import six
import yaql import yaql
# WrappingColumn is only available in N-horizon
# This make murano-dashboard compatible with Mitaka-horizon
try:
from horizon.tables import WrappingColumn as Column
except ImportError:
from horizon.tables import Column as Column # noqa
def parse_api_error(api_error_html): def parse_api_error(api_error_html):
error_html = bs4.BeautifulSoup(api_error_html) error_html = bs4.BeautifulSoup(api_error_html)

View File

@ -30,11 +30,11 @@ from oslo_log import log as logging
from muranodashboard import api as api_utils from muranodashboard import api as api_utils
from muranodashboard.api import packages as pkg_api from muranodashboard.api import packages as pkg_api
from muranodashboard.catalog import views as catalog_views from muranodashboard.catalog import views as catalog_views
from muranodashboard.common import utils as md_utils
from muranodashboard.environments import api from muranodashboard.environments import api
from muranodashboard.environments import consts from muranodashboard.environments import consts
from muranodashboard.packages import consts as pkg_consts from muranodashboard.packages import consts as pkg_consts
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -426,12 +426,12 @@ class UpdateName(tables.UpdateAction):
class EnvironmentsTable(tables.DataTable): class EnvironmentsTable(tables.DataTable):
name = tables.Column('name', name = md_utils.Column(
link='horizon:murano:environments:services', 'name',
verbose_name=_('Name'), link='horizon:murano:environments:services',
form_field=forms.CharField(required=False), verbose_name=_('Name'),
update_action=UpdateName, form_field=forms.CharField(required=False),
truncate=40) update_action=UpdateName)
status = tables.Column('status', status = tables.Column('status',
verbose_name=_('Status'), verbose_name=_('Status'),
@ -462,9 +462,10 @@ def get_service_type(datum):
class ServicesTable(tables.DataTable): class ServicesTable(tables.DataTable):
name = tables.Column('name', name = md_utils.Column(
verbose_name=_('Name'), 'name',
link=get_service_details_link) verbose_name=_('Name'),
link=get_service_details_link)
_type = tables.Column(get_service_type, _type = tables.Column(get_service_type,
verbose_name=_('Type')) verbose_name=_('Type'))
@ -587,8 +588,7 @@ class DeploymentsTable(tables.DataTable):
class EnvConfigTable(tables.DataTable): class EnvConfigTable(tables.DataTable):
name = tables.Column('name', name = md_utils.Column('name', verbose_name=_('Name'))
verbose_name=_('Name'))
_type = tables.Column( _type = tables.Column(
lambda datum: get_service_type(datum) or 'Unknown', lambda datum: get_service_type(datum) or 'Unknown',
verbose_name=_('Type')) verbose_name=_('Type'))

View File

@ -19,6 +19,8 @@ from horizon import exceptions
from horizon import tables from horizon import tables
from openstack_dashboard.api import glance from openstack_dashboard.api import glance
from muranodashboard.common import utils as md_utils
class MarkImage(tables.LinkAction): class MarkImage(tables.LinkAction):
name = "mark_image" name = "mark_image"
@ -70,9 +72,8 @@ class MarkedImagesTable(tables.DataTable):
) )
type = tables.Column(lambda obj: getattr(obj, 'type', None), type = tables.Column(lambda obj: getattr(obj, 'type', None),
verbose_name=_('Type')) verbose_name=_('Type'))
title = tables.Column(lambda obj: getattr(obj, 'title', None), title = md_utils.Column(lambda obj: getattr(obj, 'title', None),
verbose_name=_('Title'), verbose_name=_('Title'))
truncate=40)
class Meta(object): class Meta(object):
name = 'marked_images' name = 'marked_images'

View File

@ -25,6 +25,7 @@ from oslo_log import log as logging
from muranoclient.common import exceptions as exc from muranoclient.common import exceptions as exc
from muranodashboard import api from muranodashboard import api
from muranodashboard.common import utils as md_utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -214,9 +215,10 @@ class ModifyPackage(tables.LinkAction):
class PackageDefinitionsTable(tables.DataTable): class PackageDefinitionsTable(tables.DataTable):
name = tables.Column('name', name = md_utils.Column(
link="horizon:murano:packages:detail", 'name',
verbose_name=_('Package Name')) link="horizon:murano:packages:detail",
verbose_name=_('Package Name'))
tenant_name = tables.Column('tenant_name', verbose_name=_('Tenant Name')) tenant_name = tables.Column('tenant_name', verbose_name=_('Tenant Name'))
enabled = tables.Column('enabled', verbose_name=_('Active')) enabled = tables.Column('enabled', verbose_name=_('Active'))
is_public = tables.Column('is_public', verbose_name=_('Public')) is_public = tables.Column('is_public', verbose_name=_('Public'))