Skip to content

Commit

Permalink
update Search widgets to PF4 class (#913)
Browse files Browse the repository at this point in the history
  • Loading branch information
mstrlc committed Aug 14, 2023
1 parent faefa46 commit 9fdcfce
Show file tree
Hide file tree
Showing 27 changed files with 60 additions and 107 deletions.
4 changes: 2 additions & 2 deletions airgun/views/ansible_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

from airgun.views.common import BaseLoggedInView
from airgun.views.common import SatTable
from airgun.views.common import SearchableViewMixin
from airgun.views.common import SearchableViewMixinPF4
from airgun.widgets import CustomParameter
from airgun.widgets import FilteredDropdown
from airgun.widgets import Pagination
from airgun.widgets import SatSelect


class AnsibleVariablesView(BaseLoggedInView, SearchableViewMixin):
class AnsibleVariablesView(BaseLoggedInView, SearchableViewMixinPF4):
"""Main Ansible Variables view"""

title = Text("//h1[contains(normalize-space(.),'Ansible Variables')]")
Expand Down
4 changes: 2 additions & 2 deletions airgun/views/architecture.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
from widgetastic_patternfly import BreadCrumb

from airgun.views.common import BaseLoggedInView
from airgun.views.common import SearchableViewMixin
from airgun.views.common import SearchableViewMixinPF4
from airgun.widgets import MultiSelect


class ArchitecturesView(BaseLoggedInView, SearchableViewMixin):
class ArchitecturesView(BaseLoggedInView, SearchableViewMixinPF4):
title = Text("//h1[normalize-space(.)='Architectures']")
new = Text("//a[contains(@href, '/architectures/new')]")
table = Table(
Expand Down
11 changes: 3 additions & 8 deletions airgun/views/audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

from airgun.exceptions import ReadOnlyWidgetError
from airgun.views.common import BaseLoggedInView
from airgun.views.common import SearchableViewMixinPF4
from airgun.widgets import SatTableWithoutHeaders
from airgun.widgets import Search


class AuditEntry(View):
Expand Down Expand Up @@ -38,15 +38,10 @@ def fill(self, values):
raise ReadOnlyWidgetError('View is read only, fill is prohibited')


class AuditsView(BaseLoggedInView):
class AuditsView(BaseLoggedInView, SearchableViewMixinPF4):
title = Text("//h1[normalize-space(.)='Audits']")
searchbox = Search()
entry = AuditEntry()
table = AuditEntry()

@property
def is_displayed(self):
return self.browser.wait_for_element(self.title, exception=False) is not None

def search(self, query):
self.searchbox.search(query)
return self.entry.read()
4 changes: 2 additions & 2 deletions airgun/views/bookmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
from widgetastic_patternfly import BreadCrumb

from airgun.views.common import BaseLoggedInView
from airgun.views.common import SearchableViewMixin
from airgun.views.common import SearchableViewMixinPF4
from airgun.widgets import SatTable


class BookmarksView(BaseLoggedInView, SearchableViewMixin):
class BookmarksView(BaseLoggedInView, SearchableViewMixinPF4):
title = Text("//h1[normalize-space(.)='Bookmarks']")
table = SatTable(
".//table",
Expand Down
26 changes: 3 additions & 23 deletions airgun/views/cloud_insights.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from selenium.webdriver.common.keys import Keys
from widgetastic.widget import Checkbox
from widgetastic.widget import Text
from widgetastic.widget import TextInput
Expand All @@ -11,7 +10,7 @@
from widgetastic_patternfly4.ouia import Switch

from airgun.views.common import BaseLoggedInView
from airgun.views.common import SearchableViewMixin
from airgun.views.common import SearchableViewMixinPF4


class CloudTokenView(BaseLoggedInView):
Expand Down Expand Up @@ -46,7 +45,7 @@ def is_displayed(self):
return self.title.wait_displayed()


class CloudInsightsView(BaseLoggedInView, SearchableViewMixin):
class CloudInsightsView(BaseLoggedInView, SearchableViewMixinPF4):
"""Main RH Cloud Insights view."""

title = Text('//h1[normalize-space(.)="Red Hat Insights"]')
Expand All @@ -71,23 +70,4 @@ class CloudInsightsView(BaseLoggedInView, SearchableViewMixin):

@property
def is_displayed(self):
return self.title.wait_displayed()

def search(self, query):
"""Perform search using searchbox on the page and return table
contents.
:param str query: search query to type into search field. E.g. ``foo``
or ``name = "bar"``.
:return: list of dicts representing table rows
:rtype: list
"""
if not hasattr(self.__class__, 'table'):
raise AttributeError(
f'Class {self.__class__.__name__} does not have attribute "table". '
'SearchableViewMixin only works with views, which have table for results. '
'Please define table or use custom search implementation instead'
)
self.searchbox.search(query + Keys.ENTER)
self.table.wait_displayed()
return self.table.read()
return self.browser.wait_for_element(self.title, exception=False) is not None
3 changes: 2 additions & 1 deletion airgun/views/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ def search(self, query):
if not self.is_searchable():
return None
self.searchbox.search(query)

self.title.click()
return self.table.read()


Expand Down Expand Up @@ -485,6 +485,7 @@ def search(self, query):
self.searchbox.search(query)
self.browser.plugin.ensure_page_safe(timeout='60s')
self.table.wait_displayed()
self.title.click()
return self.table.read()


Expand Down
4 changes: 2 additions & 2 deletions airgun/views/computeprofile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
from widgetastic_patternfly import BreadCrumb

from airgun.views.common import BaseLoggedInView
from airgun.views.common import SearchableViewMixin
from airgun.views.common import SearchableViewMixinPF4
from airgun.widgets import ActionsDropdown


class ComputeProfilesView(BaseLoggedInView, SearchableViewMixin):
class ComputeProfilesView(BaseLoggedInView, SearchableViewMixinPF4):
title = Text('//*[(self::h1 or self::h5) and normalize-space(.)="Compute Profiles"]')
new = Text('//a[normalize-space(.)="Create Compute Profile"]')
table = Table(
Expand Down
4 changes: 2 additions & 2 deletions airgun/views/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

from airgun.views.common import BaseLoggedInView
from airgun.views.common import SatTab
from airgun.views.common import SearchableViewMixin
from airgun.views.common import SearchableViewMixinPF4
from airgun.widgets import CustomParameter
from airgun.widgets import FilteredDropdown
from airgun.widgets import MultiSelect


class DomainListView(BaseLoggedInView, SearchableViewMixin):
class DomainListView(BaseLoggedInView, SearchableViewMixinPF4):
"""List of all domains."""

title = Text('//*[(self::h1 or self::h5) and normalize-space(.)="Domains"]')
Expand Down
4 changes: 2 additions & 2 deletions airgun/views/hardware_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from widgetastic_patternfly import Button

from airgun.views.common import BaseLoggedInView
from airgun.views.common import SearchableViewMixin
from airgun.views.common import SearchableViewMixinPF4
from airgun.widgets import ConfirmationDialog
from airgun.widgets import SatTable

Expand All @@ -14,7 +14,7 @@ class DeleteHardwareModelDialog(ConfirmationDialog):
cancel_dialog = Text(".//button[normalize-space(.)='Cancel']")


class HardwareModelsView(BaseLoggedInView, SearchableViewMixin):
class HardwareModelsView(BaseLoggedInView, SearchableViewMixinPF4):
delete_dialog = DeleteHardwareModelDialog()
title = Text("//h1[normalize-space(.)='Hardware Models']")
new = Text("//a[contains(@href, '/models/new')]")
Expand Down
4 changes: 2 additions & 2 deletions airgun/views/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from airgun.views.common import BaseLoggedInView
from airgun.views.common import SatTab
from airgun.views.common import SearchableViewMixin
from airgun.views.common import SearchableViewMixinPF4
from airgun.views.job_invocation import JobInvocationCreateView
from airgun.views.job_invocation import JobInvocationStatusView
from airgun.views.task import TaskDetailsView
Expand Down Expand Up @@ -196,7 +196,7 @@ def is_displayed(self):
return self.browser.wait_for_element(self.title, visible=True, exception=False) is not None


class HostsView(BaseLoggedInView, SearchableViewMixin):
class HostsView(BaseLoggedInView, SearchableViewMixinPF4):
title = Text("//h1[normalize-space(.)='Hosts']")
manage_columns = PF4Button("OUIA-Generated-Button-link-1")
export = Text(".//a[contains(@class, 'btn')][contains(@href, 'hosts.csv')]")
Expand Down
4 changes: 2 additions & 2 deletions airgun/views/hostgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from airgun.views.common import BaseLoggedInView
from airgun.views.common import SatTab
from airgun.views.common import SearchableViewMixin
from airgun.views.common import SearchableViewMixinPF4
from airgun.widgets import ActionsDropdown
from airgun.widgets import ConfigGroupMultiSelect
from airgun.widgets import FilteredDropdown
Expand All @@ -29,7 +29,7 @@ def items(self):
]


class HostGroupsView(BaseLoggedInView, SearchableViewMixin):
class HostGroupsView(BaseLoggedInView, SearchableViewMixinPF4):
title = Text(
"//h1[contains(., 'Host Group Configuration') or normalize-space(.)='Host Groups']"
)
Expand Down
4 changes: 2 additions & 2 deletions airgun/views/job_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from airgun.views.common import BaseLoggedInView
from airgun.views.common import SatTab
from airgun.views.common import SearchableViewMixin
from airgun.views.common import SearchableViewMixinPF4
from airgun.views.common import TemplateEditor
from airgun.views.common import TemplateInputItem
from airgun.widgets import ActionsDropdown
Expand All @@ -18,7 +18,7 @@
from airgun.widgets import RemovableWidgetsItemsListView


class JobTemplatesView(BaseLoggedInView, SearchableViewMixin):
class JobTemplatesView(BaseLoggedInView, SearchableViewMixinPF4):
title = Text("//h1[contains(., 'Job Templates')]")
import_template = Text("//a[normalize-space(.)='Import']")
new = Text("//a[contains(@href, '/job_templates/new')]")
Expand Down
4 changes: 2 additions & 2 deletions airgun/views/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

from airgun.views.common import BaseLoggedInView
from airgun.views.common import SatVerticalTab
from airgun.views.common import SearchableViewMixin
from airgun.views.common import SearchableViewMixinPF4
from airgun.widgets import ActionsDropdown
from airgun.widgets import CustomParameter
from airgun.widgets import FilteredDropdown
from airgun.widgets import MultiSelect


class LocationsView(BaseLoggedInView, SearchableViewMixin):
class LocationsView(BaseLoggedInView, SearchableViewMixinPF4):
title = Text("//h1[normalize-space(.)='Locations']")
new = Text("//a[contains(@href, '/locations/new')]")
table = Table(
Expand Down
4 changes: 2 additions & 2 deletions airgun/views/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

from airgun.views.common import BaseLoggedInView
from airgun.views.common import SatTab
from airgun.views.common import SearchableViewMixin
from airgun.views.common import SearchableViewMixinPF4
from airgun.widgets import FilteredDropdown
from airgun.widgets import MultiSelect


class MediumView(BaseLoggedInView, SearchableViewMixin):
class MediumView(BaseLoggedInView, SearchableViewMixinPF4):
title = Text("//h1[normalize-space(.)='Installation Media']")
new = Text("//a[contains(@href, '/media/new')]")
table = Table(
Expand Down
25 changes: 2 additions & 23 deletions airgun/views/modulestream.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,21 @@
from widgetastic.widget import Table
from widgetastic.widget import Text
from widgetastic.widget import TextInput
from widgetastic.widget import View
from widgetastic_patternfly import BreadCrumb
from widgetastic_patternfly import Button

from airgun.views.common import BaseLoggedInView
from airgun.views.common import SatTab
from airgun.views.common import SatTable
from airgun.views.common import SearchableViewMixinPF4
from airgun.widgets import SatTableWithUnevenStructure
from airgun.widgets import Search


class CustomSearch(Search):
search_field = TextInput(id='downshift-0-input')
search_button = Button('Search')


class ModuleStreamView(BaseLoggedInView):
class ModuleStreamView(BaseLoggedInView, SearchableViewMixinPF4):
"""Main Module_Streams view"""

title = Text("//h2[contains(., 'Module Streams')]")
table = SatTable('.//table', column_widgets={'Name': Text("./a")})

search_box = CustomSearch()

def search(self, query):
"""Perform search using search box on the page and return table
contents.
:param str query: search query to type into search field. E.g.
``name = "bar"``.
:return: list of dicts representing table rows
:rtype: list
"""
self.search_box.search(query)
return self.table.read()

@property
def is_displayed(self):
"""The view is displayed when it's title exists"""
Expand Down
4 changes: 2 additions & 2 deletions airgun/views/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

from airgun.views.common import BaseLoggedInView
from airgun.views.common import SatVerticalTab
from airgun.views.common import SearchableViewMixin
from airgun.views.common import SearchableViewMixinPF4
from airgun.widgets import ActionsDropdown
from airgun.widgets import CustomParameter
from airgun.widgets import FilteredDropdown
from airgun.widgets import MultiSelect


class OrganizationsView(BaseLoggedInView, SearchableViewMixin):
class OrganizationsView(BaseLoggedInView, SearchableViewMixinPF4):
title = Text("//h1[normalize-space(.)='Organizations']")
new = Text("//a[contains(@href, '/organizations/new')]")
table = Table(
Expand Down
4 changes: 2 additions & 2 deletions airgun/views/os.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from airgun.views.common import BaseLoggedInView
from airgun.views.common import SatTab
from airgun.views.common import SearchableViewMixin
from airgun.views.common import SearchableViewMixinPF4
from airgun.widgets import ActionsDropdown
from airgun.widgets import CustomParameter
from airgun.widgets import FilteredDropdown
Expand Down Expand Up @@ -69,7 +69,7 @@ def fill(self, value):
result[title].fill(select_value)


class OperatingSystemsView(BaseLoggedInView, SearchableViewMixin):
class OperatingSystemsView(BaseLoggedInView, SearchableViewMixinPF4):
title = Text("//h1[normalize-space(.)='Operating Systems']")
new = Text("//a[contains(@href, '/operatingsystems/new')]")
table = Table(
Expand Down
4 changes: 2 additions & 2 deletions airgun/views/oscapcontent.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

from airgun.views.common import BaseLoggedInView
from airgun.views.common import SatTab
from airgun.views.common import SearchableViewMixin
from airgun.views.common import SearchableViewMixinPF4
from airgun.widgets import ActionsDropdown
from airgun.widgets import MultiSelect
from airgun.widgets import SatTable


class SCAPContentsView(BaseLoggedInView, SearchableViewMixin):
class SCAPContentsView(BaseLoggedInView, SearchableViewMixinPF4):
title = Text("//h1[normalize-space(.)='SCAP Content']")
new = Text("//a[contains(@href, 'scap_contents/new')]")
table = SatTable(
Expand Down
4 changes: 2 additions & 2 deletions airgun/views/partitiontable.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from airgun.views.common import BaseLoggedInView
from airgun.views.common import SatTab
from airgun.views.common import SearchableViewMixin
from airgun.views.common import SearchableViewMixinPF4
from airgun.views.common import TemplateInputItem
from airgun.widgets import ACEEditor
from airgun.widgets import ActionsDropdown
Expand All @@ -18,7 +18,7 @@
from airgun.widgets import RemovableWidgetsItemsListView


class PartitionTablesView(BaseLoggedInView, SearchableViewMixin):
class PartitionTablesView(BaseLoggedInView, SearchableViewMixinPF4):

title = Text("//h1[text()='Partition Tables']")
new = Button("Create Partition Table")
Expand Down
Loading

0 comments on commit 9fdcfce

Please sign in to comment.