Merge "Use ThemableSelectWidget for themable selects."
This commit is contained in:
commit
c81516d8bc
@ -328,10 +328,12 @@ class ChoiceField(forms.ChoiceField, CustomPropertiesField):
|
||||
if isinstance(choices, dict):
|
||||
choices = list(choices.items())
|
||||
kwargs['choices'] = choices
|
||||
kwargs['widget'] = hz_forms.ThemableSelectWidget()
|
||||
super(ChoiceField, self).__init__(**kwargs)
|
||||
|
||||
|
||||
class DynamicChoiceField(hz_forms.DynamicChoiceField, CustomPropertiesField):
|
||||
class DynamicChoiceField(hz_forms.ThemableDynamicChoiceField,
|
||||
CustomPropertiesField):
|
||||
pass
|
||||
|
||||
|
||||
@ -421,8 +423,9 @@ def _disable_non_ready(data):
|
||||
|
||||
|
||||
class ImageChoiceField(ChoiceField):
|
||||
widget = hz_forms.SelectWidget(transform=_get_title,
|
||||
transform_html_attrs=_disable_non_ready)
|
||||
widget = hz_forms.ThemableSelectWidget(
|
||||
transform=_get_title,
|
||||
transform_html_attrs=_disable_non_ready)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.image_type = kwargs.pop('image_type', None)
|
||||
|
@ -54,13 +54,15 @@ class MarkImageForm(horizon_forms.SelfHandlingForm):
|
||||
'custom': "Custom type"
|
||||
}
|
||||
|
||||
image = forms.ChoiceField(label=_('Image'))
|
||||
image = forms.ChoiceField(
|
||||
label=_('Image'),
|
||||
widget=horizon_forms.ThemableSelectWidget())
|
||||
title = forms.CharField(max_length="255", label=_("Title"))
|
||||
type = forms.ChoiceField(
|
||||
label=_("Type"),
|
||||
choices=_metadata.items(),
|
||||
initial='custom',
|
||||
widget=forms.Select(attrs={
|
||||
widget=horizon_forms.ThemableSelectWidget(attrs={
|
||||
'class': 'switchable',
|
||||
'data-slug': 'type'}))
|
||||
custom_type = forms.CharField(
|
||||
|
@ -52,7 +52,7 @@ class ImportBundleForm(forms.Form):
|
||||
import_type = forms.ChoiceField(
|
||||
label=_("Package Bundle Source"),
|
||||
choices=IMPORT_BUNDLE_TYPE_CHOICES,
|
||||
widget=forms.Select(attrs={
|
||||
widget=horizon_forms.ThemableSelectWidget(attrs={
|
||||
'class': 'switchable',
|
||||
'data-slug': 'source'}))
|
||||
url = PackageURLField(
|
||||
@ -88,7 +88,7 @@ class ImportPackageForm(forms.Form):
|
||||
import_type = forms.ChoiceField(
|
||||
label=_("Package Source"),
|
||||
choices=IMPORT_TYPE_CHOICES,
|
||||
widget=forms.Select(attrs={
|
||||
widget=horizon_forms.ThemableSelectWidget(attrs={
|
||||
'class': 'switchable',
|
||||
'data-slug': 'source'}))
|
||||
url = PackageURLField(
|
||||
|
@ -253,12 +253,16 @@ class UITestCase(testtools.TestCase):
|
||||
el.click()
|
||||
|
||||
def select_from_list(self, list_name, value, sec=10):
|
||||
locator = (by.By.XPATH,
|
||||
"//select[contains(@name, '{0}')]"
|
||||
"/option[@value='{1}']".format(list_name, value))
|
||||
el = ui.WebDriverWait(self.driver, sec).until(
|
||||
EC.presence_of_element_located(locator))
|
||||
el.click()
|
||||
self.check_element_on_page(by.By.CSS_SELECTOR,
|
||||
consts.ThemableSelect.format(list_name))
|
||||
self.wait_element_is_clickable(
|
||||
by.By.CSS_SELECTOR, consts.ThemableSelect.format(
|
||||
list_name)).click()
|
||||
self.check_element_on_page(by.By.CSS_SELECTOR,
|
||||
consts.ThemableOption.format(value))
|
||||
self.wait_element_is_clickable(
|
||||
by.By.CSS_SELECTOR,
|
||||
consts.ThemableOption.format(value)).click()
|
||||
|
||||
def check_element_on_page(self, method, value, sec=10):
|
||||
try:
|
||||
|
@ -89,9 +89,10 @@ DeploymentHistoryLogs = "div#environment_details__env_logs div.reports.logs "\
|
||||
"div.report-info"
|
||||
PackageFilterDropdownBtn = 'div.table_search > div.themable-select.dropdown >'\
|
||||
' button'
|
||||
PackageFilterTypeBtn = "a[data-select-value='{0}']"
|
||||
PackageFilterInput = 'input[name="packages__filter_packages__q"]'
|
||||
PackageFilterBtn = "packages__action_filter_packages"
|
||||
ThemableSelect = 'label[for$="{0}"] ~ div div button.dropdown-toggle'
|
||||
ThemableOption = "a[data-select-value='{0}']"
|
||||
|
||||
# Panels
|
||||
AppCatalog = "//*[@id='main_content']/nav//a[contains(text(), 'App Catalog')]" # noqa
|
||||
|
@ -2433,7 +2433,7 @@ class TestSuitePackages(base.PackageTestCase):
|
||||
self.wait_element_is_clickable(
|
||||
by.By.CSS_SELECTOR, c.PackageFilterDropdownBtn).click()
|
||||
self.wait_element_is_clickable(
|
||||
by.By.CSS_SELECTOR, c.PackageFilterTypeBtn.format('name')).click()
|
||||
by.By.CSS_SELECTOR, c.ThemableOption.format('name')).click()
|
||||
|
||||
for package_name in packages_by_name:
|
||||
self.fill_field(by.By.CSS_SELECTOR, c.PackageFilterInput,
|
||||
@ -2473,7 +2473,7 @@ class TestSuitePackages(base.PackageTestCase):
|
||||
self.wait_element_is_clickable(
|
||||
by.By.CSS_SELECTOR, c.PackageFilterDropdownBtn).click()
|
||||
self.wait_element_is_clickable(
|
||||
by.By.CSS_SELECTOR, c.PackageFilterTypeBtn.format('type')).click()
|
||||
by.By.CSS_SELECTOR, c.ThemableOption.format('type')).click()
|
||||
|
||||
for package_type, package_list in packages_by_type.items():
|
||||
self.fill_field(by.By.CSS_SELECTOR, c.PackageFilterInput,
|
||||
@ -2529,7 +2529,7 @@ class TestSuitePackages(base.PackageTestCase):
|
||||
self.wait_element_is_clickable(
|
||||
by.By.CSS_SELECTOR, c.PackageFilterDropdownBtn).click()
|
||||
self.wait_element_is_clickable(
|
||||
by.By.CSS_SELECTOR, c.PackageFilterTypeBtn.format('search'))\
|
||||
by.By.CSS_SELECTOR, c.ThemableOption.format('search'))\
|
||||
.click()
|
||||
|
||||
for keyword, package_name in packages_by_keyword.items():
|
||||
@ -2831,10 +2831,7 @@ class TestSuiteRepository(base.PackageTestCase):
|
||||
self.navigate_to('Manage')
|
||||
self.go_to_submenu('Packages')
|
||||
self.driver.find_element_by_id(c.UploadPackage).click()
|
||||
sel = self.driver.find_element_by_css_selector(
|
||||
"select[name='upload-import_type']")
|
||||
sel = ui.Select(sel)
|
||||
sel.select_by_value("by_url")
|
||||
self.select_from_list('import_type', 'by_url')
|
||||
|
||||
el = self.driver.find_element_by_css_selector(
|
||||
"input[name='upload-url']")
|
||||
@ -2864,10 +2861,7 @@ class TestSuiteRepository(base.PackageTestCase):
|
||||
self.navigate_to('Manage')
|
||||
self.go_to_submenu('Packages')
|
||||
self.driver.find_element_by_id(c.UploadPackage).click()
|
||||
sel = self.driver.find_element_by_css_selector(
|
||||
"select[name='upload-import_type']")
|
||||
sel = ui.Select(sel)
|
||||
sel.select_by_value("by_name")
|
||||
self.select_from_list('import_type', 'by_name')
|
||||
|
||||
el = self.driver.find_element_by_css_selector(
|
||||
"input[name='upload-repo_name']")
|
||||
@ -2904,10 +2898,8 @@ class TestSuiteRepository(base.PackageTestCase):
|
||||
self.navigate_to('Manage')
|
||||
self.go_to_submenu('Packages')
|
||||
self.driver.find_element_by_id(c.ImportBundle).click()
|
||||
sel = self.driver.find_element_by_css_selector(
|
||||
"select[name='upload-import_type']")
|
||||
sel = ui.Select(sel)
|
||||
sel.select_by_value("by_url")
|
||||
|
||||
self.select_from_list('import_type', 'by_url')
|
||||
|
||||
el = self.driver.find_element_by_css_selector(
|
||||
"input[name='upload-url']")
|
||||
@ -2942,10 +2934,8 @@ class TestSuiteRepository(base.PackageTestCase):
|
||||
self.navigate_to('Manage')
|
||||
self.go_to_submenu('Packages')
|
||||
self.driver.find_element_by_id(c.ImportBundle).click()
|
||||
sel = self.driver.find_element_by_css_selector(
|
||||
"select[name='upload-import_type']")
|
||||
sel = ui.Select(sel)
|
||||
sel.select_by_value("by_name")
|
||||
|
||||
self.select_from_list('import_type', 'by_name')
|
||||
|
||||
el = self.driver.find_element_by_css_selector(
|
||||
"input[name='upload-name']")
|
||||
@ -2978,10 +2968,8 @@ class TestSuiteRepository(base.PackageTestCase):
|
||||
self.navigate_to('Manage')
|
||||
self.go_to_submenu('Packages')
|
||||
self.driver.find_element_by_id(c.UploadPackage).click()
|
||||
sel = self.driver.find_element_by_css_selector(
|
||||
"select[name='upload-import_type']")
|
||||
sel = ui.Select(sel)
|
||||
sel.select_by_value("by_name")
|
||||
|
||||
self.select_from_list('import_type', 'by_name')
|
||||
|
||||
el = self.driver.find_element_by_css_selector(
|
||||
"input[name='upload-repo_name']")
|
||||
@ -3008,10 +2996,7 @@ class TestSuiteRepository(base.PackageTestCase):
|
||||
|
||||
# Invalid folder
|
||||
self.driver.find_element_by_id(c.UploadPackage).click()
|
||||
sel = self.driver.find_element_by_css_selector(
|
||||
"select[name='upload-import_type']")
|
||||
sel = ui.Select(sel)
|
||||
sel.select_by_value("by_url")
|
||||
self.select_from_list('import_type', 'by_url')
|
||||
el = self.driver.find_element_by_css_selector(
|
||||
"input[name='upload-url']")
|
||||
el.send_keys("http://127.0.0.1:8099/None/{0}.zip".format(pkg_name))
|
||||
@ -3020,10 +3005,7 @@ class TestSuiteRepository(base.PackageTestCase):
|
||||
|
||||
# HTTP connect error
|
||||
self.driver.find_element_by_id(c.UploadPackage).click()
|
||||
sel = self.driver.find_element_by_css_selector(
|
||||
"select[name='upload-import_type']")
|
||||
sel = ui.Select(sel)
|
||||
sel.select_by_value("by_url")
|
||||
self.select_from_list('import_type', 'by_url')
|
||||
el = self.driver.find_element_by_css_selector(
|
||||
"input[name='upload-url']")
|
||||
el.send_keys("http://127.0.0.2:12345/apps/{0}.zip".format(pkg_name))
|
||||
@ -3032,10 +3014,7 @@ class TestSuiteRepository(base.PackageTestCase):
|
||||
|
||||
# Invalid app name
|
||||
self.driver.find_element_by_id(c.UploadPackage).click()
|
||||
sel = self.driver.find_element_by_css_selector(
|
||||
"select[name='upload-import_type']")
|
||||
sel = ui.Select(sel)
|
||||
sel.select_by_value("by_url")
|
||||
self.select_from_list('import_type', 'by_url')
|
||||
el = self.driver.find_element_by_css_selector(
|
||||
"input[name='upload-url']")
|
||||
el.send_keys(
|
||||
@ -3055,10 +3034,7 @@ class TestSuiteRepository(base.PackageTestCase):
|
||||
self.navigate_to('Manage')
|
||||
self.go_to_submenu('Packages')
|
||||
self.driver.find_element_by_id(c.UploadPackage).click()
|
||||
sel = self.driver.find_element_by_css_selector(
|
||||
"select[name='upload-import_type']")
|
||||
sel = ui.Select(sel)
|
||||
sel.select_by_value("by_name")
|
||||
self.select_from_list('import_type', 'by_name')
|
||||
|
||||
el = self.driver.find_element_by_css_selector(
|
||||
"input[name='upload-repo_name']")
|
||||
@ -3079,10 +3055,7 @@ class TestSuiteRepository(base.PackageTestCase):
|
||||
self.navigate_to('Manage')
|
||||
self.go_to_submenu('Packages')
|
||||
self.driver.find_element_by_id(c.UploadPackage).click()
|
||||
sel = self.driver.find_element_by_css_selector(
|
||||
"select[name='upload-import_type']")
|
||||
sel = ui.Select(sel)
|
||||
sel.select_by_value("by_name")
|
||||
self.select_from_list('import_type', 'by_name')
|
||||
|
||||
el = self.driver.find_element_by_css_selector(
|
||||
"input[name='upload-repo_name']")
|
||||
@ -3106,10 +3079,7 @@ class TestSuiteRepository(base.PackageTestCase):
|
||||
self.navigate_to('Manage')
|
||||
self.go_to_submenu('Packages')
|
||||
self.driver.find_element_by_id(c.UploadPackage).click()
|
||||
sel = self.driver.find_element_by_css_selector(
|
||||
"select[name='upload-import_type']")
|
||||
sel = ui.Select(sel)
|
||||
sel.select_by_value("by_name")
|
||||
self.select_from_list('import_type', 'by_name')
|
||||
|
||||
el = self.driver.find_element_by_css_selector(
|
||||
"input[name='upload-repo_name']")
|
||||
@ -3143,10 +3113,8 @@ class TestSuiteRepository(base.PackageTestCase):
|
||||
self.navigate_to('Manage')
|
||||
self.go_to_submenu('Packages')
|
||||
self.driver.find_element_by_id(c.UploadPackage).click()
|
||||
sel = self.driver.find_element_by_css_selector(
|
||||
"select[name='upload-import_type']")
|
||||
sel = ui.Select(sel)
|
||||
sel.select_by_value("by_name")
|
||||
|
||||
self.select_from_list('import_type', 'by_name')
|
||||
|
||||
el = self.driver.find_element_by_css_selector(
|
||||
"input[name='upload-repo_name']")
|
||||
@ -3182,10 +3150,7 @@ class TestSuiteRepository(base.PackageTestCase):
|
||||
self.navigate_to('Manage')
|
||||
self.go_to_submenu('Packages')
|
||||
self.driver.find_element_by_id(c.UploadPackage).click()
|
||||
sel = self.driver.find_element_by_css_selector(
|
||||
"select[name='upload-import_type']")
|
||||
sel = ui.Select(sel)
|
||||
sel.select_by_value("by_name")
|
||||
self.select_from_list('import_type', 'by_name')
|
||||
|
||||
el = self.driver.find_element_by_css_selector(
|
||||
"input[name='upload-repo_name']")
|
||||
@ -3234,10 +3199,7 @@ class TestSuiteRepository(base.PackageTestCase):
|
||||
self.navigate_to('Manage')
|
||||
self.go_to_submenu('Packages')
|
||||
self.driver.find_element_by_id(c.ImportBundle).click()
|
||||
sel = self.driver.find_element_by_css_selector(
|
||||
"select[name='upload-import_type']")
|
||||
sel = ui.Select(sel)
|
||||
sel.select_by_value("by_name")
|
||||
self.select_from_list('import_type', 'by_name')
|
||||
|
||||
el = self.driver.find_element_by_css_selector(
|
||||
"input[name='upload-name']")
|
||||
|
Loading…
Reference in New Issue
Block a user