Horizon selects are now themable: Admin Panels

Horizon was using a standard select input. Unfortunately
this type of input is only customizable to a small extent.

Co-Authored-By: Matthew Wood <woodm1979@gmail.com>
Co-Authored-By: Brian Tully <brian.tully@hp.com>

Change-Id: Id86abbf5e8f0fd9b4a7bab05f5b56e6d0d82b778
Partially-implements: blueprint horizon-theme-css-reorg
This commit is contained in:
Diana Whitten
2016-03-08 17:44:50 -07:00
parent 4a6df55120
commit d0ddd223cb
11 changed files with 50 additions and 45 deletions

View File

@@ -38,7 +38,7 @@ class MinifiedNode(Node):
def render(self, context): def render(self, context):
return ' '.join( return ' '.join(
force_text(self.nodelist.render(context).strip()).split() force_text(self.nodelist.render(context).strip()).split()
) ).replace(' > ', '>').replace(' <', '<')
@register.filter @register.filter

View File

@@ -25,7 +25,7 @@ class EvacuateHostForm(forms.SelfHandlingForm):
current_host = forms.CharField(label=_("Current Host"), current_host = forms.CharField(label=_("Current Host"),
widget=forms.TextInput( widget=forms.TextInput(
attrs={'readonly': 'readonly'})) attrs={'readonly': 'readonly'}))
target_host = forms.ChoiceField( target_host = forms.ThemableChoiceField(
label=_("Target Host"), label=_("Target Host"),
help_text=_("Choose a Host to evacuate servers to.")) help_text=_("Choose a Host to evacuate servers to."))
@@ -108,7 +108,7 @@ class MigrateHostForm(forms.SelfHandlingForm):
('live_migrate', _('Live Migrate')), ('live_migrate', _('Live Migrate')),
('cold_migrate', _('Cold Migrate')) ('cold_migrate', _('Cold Migrate'))
], ],
widget=forms.Select( widget=forms.ThemableSelectWidget(
attrs={ attrs={
'class': 'switchable', 'class': 'switchable',
'data-slug': 'source' 'data-slug': 'source'

View File

@@ -28,9 +28,10 @@ class LiveMigrateForm(forms.SelfHandlingForm):
required=False, required=False,
widget=forms.TextInput( widget=forms.TextInput(
attrs={'readonly': 'readonly'})) attrs={'readonly': 'readonly'}))
host = forms.ChoiceField(label=_("New Host"), host = forms.ThemableChoiceField(
help_text=_("Choose a Host to migrate to."), label=_("New Host"),
required=False) help_text=_("Choose a Host to migrate to."),
required=False)
disk_over_commit = forms.BooleanField(label=_("Disk Over Commit"), disk_over_commit = forms.BooleanField(label=_("Disk Over Commit"),
initial=False, required=False) initial=False, required=False)
block_migration = forms.BooleanField(label=_("Block Migration"), block_migration = forms.BooleanField(label=_("Block Migration"),

View File

@@ -36,7 +36,7 @@ class CreateNamespaceForm(forms.SelfHandlingForm):
required=False, required=False,
choices=[('file', _('Metadata Definition File')), choices=[('file', _('Metadata Definition File')),
('raw', _('Direct Input'))], ('raw', _('Direct Input'))],
widget=forms.Select( widget=forms.ThemableSelectWidget(
attrs={'class': 'switchable', 'data-slug': 'source'})) attrs={'class': 'switchable', 'data-slug': 'source'}))
metadef_file = forms.FileField( metadef_file = forms.FileField(

View File

@@ -29,9 +29,9 @@ class UsageReportForm(forms.SelfHandlingForm):
("365", _("Last year")), ("365", _("Last year")),
("other", _("Other")), ("other", _("Other")),
) )
period = forms.ChoiceField(label=_("Period"), period = forms.ThemableChoiceField(label=_("Period"),
required=True, required=True,
choices=PERIOD_CHOICES) choices=PERIOD_CHOICES)
date_from = forms.DateField(label=_("From"), required=False, date_from = forms.DateField(label=_("From"), required=False,
widget=forms.TextInput( widget=forms.TextInput(
attrs={'data-date-picker': True})) attrs={'data-date-picker': True}))

View File

@@ -27,7 +27,7 @@ class AddDHCPAgent(forms.SelfHandlingForm):
network_name = forms.CharField(label=_("Network Name"), network_name = forms.CharField(label=_("Network Name"),
widget=forms.TextInput( widget=forms.TextInput(
attrs={'readonly': 'readonly'})) attrs={'readonly': 'readonly'}))
agent = forms.ChoiceField( agent = forms.ThemableChoiceField(
label=_("New DHCP Agent"), label=_("New DHCP Agent"),
help_text=_("Choose an DHCP Agent to attach to.")) help_text=_("Choose an DHCP Agent to attach to."))

View File

@@ -93,7 +93,7 @@ class CreateNetwork(forms.SelfHandlingForm):
name = forms.CharField(max_length=255, name = forms.CharField(max_length=255,
label=_("Name"), label=_("Name"),
required=False) required=False)
tenant_id = forms.ChoiceField(label=_("Project")) tenant_id = forms.ThemableChoiceField(label=_("Project"))
if api.neutron.is_port_profiles_supported(): if api.neutron.is_port_profiles_supported():
widget = None widget = None
else: else:
@@ -105,7 +105,7 @@ class CreateNetwork(forms.SelfHandlingForm):
label=_("Provider Network Type"), label=_("Provider Network Type"),
help_text=_("The physical mechanism by which the virtual " help_text=_("The physical mechanism by which the virtual "
"network is implemented."), "network is implemented."),
widget=forms.Select(attrs={ widget=forms.ThemableSelectWidget(attrs={
'class': 'switchable', 'class': 'switchable',
'data-slug': 'network_type' 'data-slug': 'network_type'
})) }))
@@ -125,9 +125,10 @@ class CreateNetwork(forms.SelfHandlingForm):
'class': 'switched', 'class': 'switched',
'data-switch-on': 'network_type', 'data-switch-on': 'network_type',
})) }))
admin_state = forms.ChoiceField(choices=[(True, _('UP')), admin_state = forms.ThemableChoiceField(
(False, _('DOWN'))], choices=[(True, _('UP')),
label=_("Admin State")) (False, _('DOWN'))],
label=_("Admin State"))
shared = forms.BooleanField(label=_("Shared"), shared = forms.BooleanField(label=_("Shared"),
initial=False, required=False) initial=False, required=False)
external = forms.BooleanField(label=_("External Network"), external = forms.BooleanField(label=_("External Network"),
@@ -304,9 +305,9 @@ class UpdateNetwork(forms.SelfHandlingForm):
network_id = forms.CharField(label=_("ID"), network_id = forms.CharField(label=_("ID"),
widget=forms.TextInput( widget=forms.TextInput(
attrs={'readonly': 'readonly'})) attrs={'readonly': 'readonly'}))
admin_state = forms.ChoiceField(choices=[(True, _('UP')), admin_state = forms.ThemableChoiceField(choices=[(True, _('UP')),
(False, _('DOWN'))], (False, _('DOWN'))],
label=_("Admin State")) label=_("Admin State"))
shared = forms.BooleanField(label=_("Shared"), required=False) shared = forms.BooleanField(label=_("Shared"), required=False)
external = forms.BooleanField(label=_("External Network"), required=False) external = forms.BooleanField(label=_("External Network"), required=False)
failure_url = 'horizon:admin:networks:index' failure_url = 'horizon:admin:networks:index'

View File

@@ -43,9 +43,9 @@ class CreatePort(forms.SelfHandlingForm):
name = forms.CharField(max_length=255, name = forms.CharField(max_length=255,
label=_("Name"), label=_("Name"),
required=False) required=False)
admin_state = forms.ChoiceField(choices=[(True, _('UP')), admin_state = forms.ThemableChoiceField(choices=[(True, _('UP')),
(False, _('DOWN'))], (False, _('DOWN'))],
label=_("Admin State")) label=_("Admin State"))
device_id = forms.CharField(max_length=100, label=_("Device ID"), device_id = forms.CharField(max_length=100, label=_("Device ID"),
help_text=_("Device ID attached to the port"), help_text=_("Device ID attached to the port"),
required=False) required=False)
@@ -79,12 +79,14 @@ class CreatePort(forms.SelfHandlingForm):
if vnic_type[0] in supported_vnic_types if vnic_type[0] in supported_vnic_types
] ]
self.fields['binding__vnic_type'] = forms.ChoiceField( self.fields['binding__vnic_type'] = \
choices=vnic_type_choices, forms.ThemableChoiceField(
label=_("Binding: VNIC Type"), choices=vnic_type_choices,
help_text=_( label=_("Binding: VNIC Type"),
"The VNIC type that is bound to the neutron port"), help_text=_(
required=False) "The VNIC type that is bound to the neutron "
"port"),
required=False)
except Exception: except Exception:
msg = _("Unable to verify the VNIC types extension in Neutron") msg = _("Unable to verify the VNIC types extension in Neutron")
exceptions.handle(self.request, msg) exceptions.handle(self.request, msg)

View File

@@ -40,7 +40,7 @@ def populate_status_choices(initial, status_choices):
class UpdateStatus(forms.SelfHandlingForm): class UpdateStatus(forms.SelfHandlingForm):
status = forms.ChoiceField(label=_("Status")) status = forms.ThemableChoiceField(label=_("Status"))
def __init__(self, request, *args, **kwargs): def __init__(self, request, *args, **kwargs):
super(UpdateStatus, self).__init__(request, *args, **kwargs) super(UpdateStatus, self).__init__(request, *args, **kwargs)

View File

@@ -67,8 +67,8 @@ class CreateVolumeType(forms.SelfHandlingForm):
class CreateQosSpec(forms.SelfHandlingForm): class CreateQosSpec(forms.SelfHandlingForm):
name = forms.CharField(max_length=255, label=_("Name")) name = forms.CharField(max_length=255, label=_("Name"))
consumer = forms.ChoiceField(label=_("Consumer"), consumer = forms.ThemableChoiceField(label=_("Consumer"),
choices=cinder.CONSUMER_CHOICES) choices=cinder.CONSUMER_CHOICES)
def handle(self, request, data): def handle(self, request, data):
try: try:
@@ -96,12 +96,12 @@ class CreateVolumeTypeEncryption(forms.SelfHandlingForm):
widget=forms.TextInput(attrs={'readonly': widget=forms.TextInput(attrs={'readonly':
'readonly'})) 'readonly'}))
provider = forms.CharField(max_length=255, label=_("Provider")) provider = forms.CharField(max_length=255, label=_("Provider"))
control_location = forms.ChoiceField(label=_("Control Location"), control_location = forms.ThemableChoiceField(label=_("Control Location"),
choices=(('front-end', choices=(('front-end',
_('front-end')), _('front-end')),
('back-end', ('back-end',
_('back-end'))) _('back-end')))
) )
cipher = forms.CharField(label=_("Cipher"), required=False) cipher = forms.CharField(label=_("Cipher"), required=False)
key_size = forms.IntegerField(label=_("Key Size (bits)"), key_size = forms.IntegerField(label=_("Key Size (bits)"),
required=False, required=False,
@@ -158,7 +158,7 @@ class UpdateVolumeTypeEncryption(CreateVolumeTypeEncryption):
class ManageQosSpecAssociation(forms.SelfHandlingForm): class ManageQosSpecAssociation(forms.SelfHandlingForm):
qos_spec_choice = forms.ChoiceField( qos_spec_choice = forms.ThemableChoiceField(
label=_("QoS Spec to be associated"), label=_("QoS Spec to be associated"),
help_text=_("Choose associated QoS Spec.")) help_text=_("Choose associated QoS Spec."))
@@ -229,7 +229,7 @@ class EditQosSpecConsumer(forms.SelfHandlingForm):
widget=forms.TextInput( widget=forms.TextInput(
attrs={'readonly': 'readonly'}), attrs={'readonly': 'readonly'}),
required=False) required=False)
consumer_choice = forms.ChoiceField( consumer_choice = forms.ThemableChoiceField(
label=_("New QoS Spec Consumer"), label=_("New QoS Spec Consumer"),
choices=cinder.CONSUMER_CHOICES, choices=cinder.CONSUMER_CHOICES,
help_text=_("Choose consumer for this QoS Spec.")) help_text=_("Choose consumer for this QoS Spec."))

View File

@@ -50,7 +50,7 @@ class ManageVolume(forms.SelfHandlingForm):
max_length=255, max_length=255,
label=_("Identifier"), label=_("Identifier"),
help_text=_("Name or other identifier for existing volume")) help_text=_("Name or other identifier for existing volume"))
id_type = forms.ChoiceField( id_type = forms.ThemableChoiceField(
label=_("Identifier Type"), label=_("Identifier Type"),
help_text=_("Type of backend device identifier provided")) help_text=_("Type of backend device identifier provided"))
host = forms.CharField( host = forms.CharField(
@@ -71,10 +71,10 @@ class ManageVolume(forms.SelfHandlingForm):
label=_("Metadata"), required=False, label=_("Metadata"), required=False,
help_text=_("Comma-separated key=value pairs"), help_text=_("Comma-separated key=value pairs"),
validators=[utils_validators.validate_metadata]) validators=[utils_validators.validate_metadata])
volume_type = forms.ChoiceField( volume_type = forms.ThemableChoiceField(
label=_("Volume Type"), label=_("Volume Type"),
required=False) required=False)
availability_zone = forms.ChoiceField( availability_zone = forms.ThemableChoiceField(
label=_("Availability Zone"), label=_("Availability Zone"),
required=False) required=False)
@@ -174,8 +174,9 @@ class MigrateVolume(forms.SelfHandlingForm):
required=False, required=False,
widget=forms.TextInput( widget=forms.TextInput(
attrs={'readonly': 'readonly'})) attrs={'readonly': 'readonly'}))
host = forms.ChoiceField(label=_("Destination Host"), host = forms.ThemableChoiceField(
help_text=_("Choose a Host to migrate to.")) label=_("Destination Host"),
help_text=_("Choose a Host to migrate to."))
force_host_copy = forms.BooleanField(label=_("Force Host Copy"), force_host_copy = forms.BooleanField(label=_("Force Host Copy"),
initial=False, required=False) initial=False, required=False)
@@ -215,7 +216,7 @@ class MigrateVolume(forms.SelfHandlingForm):
class UpdateStatus(forms.SelfHandlingForm): class UpdateStatus(forms.SelfHandlingForm):
status = forms.ChoiceField(label=_("Status")) status = forms.ThemableChoiceField(label=_("Status"))
def __init__(self, request, *args, **kwargs): def __init__(self, request, *args, **kwargs):
super(UpdateStatus, self).__init__(request, *args, **kwargs) super(UpdateStatus, self).__init__(request, *args, **kwargs)