Skip to content

Commit

Permalink
Pagination refactor (#947)
Browse files Browse the repository at this point in the history
* update views to use Widgetastic's PF4 Pagination

* rename to PF4Pagination

* fix SatTable locator

* add Pagination to location for testing

* pre-commit
  • Loading branch information
mstrlc committed Nov 14, 2023
1 parent 7f6bda9 commit d06ef2b
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 41 deletions.
18 changes: 9 additions & 9 deletions airgun/views/ansible_role.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from widgetastic.widget import Checkbox, Table, Text
from widgetastic_patternfly import BreadCrumb
from widgetastic_patternfly4 import Button, PatternflyTable
from widgetastic_patternfly4 import (
Button,
CompactPagination,
Pagination as PF4Pagination,
PatternflyTable,
)

from airgun.views.common import BaseLoggedInView, SearchableViewMixin
from airgun.widgets import ActionsDropdown, Pagination


class ImportPagination(Pagination):
PER_PAGE_BUTTON_DROPDOWN = ".//div[button[@id='pagination-options-menu-toggle-2']]"
total_items = Text("//span[@class='pf-c-optionsmenu__toggle-text']/b[2]")
from airgun.widgets import ActionsDropdown


class AnsibleRolesView(BaseLoggedInView, SearchableViewMixin):
Expand All @@ -26,7 +26,7 @@ class AnsibleRolesView(BaseLoggedInView, SearchableViewMixin):
'Actions': ActionsDropdown("./div[contains(@class, 'btn-group')]"),
},
)
pagination = Pagination()
pagination = PF4Pagination()

@property
def is_displayed(self):
Expand All @@ -45,7 +45,7 @@ class AnsibleRolesImportView(BaseLoggedInView):
0: Checkbox(locator='.//input[@type="checkbox"]'),
},
)
pagination = ImportPagination()
pagination = CompactPagination()
submit = Button('Submit')
cancel = Button('Cancel')

Expand Down
3 changes: 1 addition & 2 deletions airgun/views/ansible_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from widgetastic_patternfly import BreadCrumb

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


class AnsibleVariablesView(BaseLoggedInView, SearchableViewMixinPF4):
Expand All @@ -17,7 +17,6 @@ class AnsibleVariablesView(BaseLoggedInView, SearchableViewMixinPF4):
'Actions': Text(".//a[@data-method='delete']"),
},
)
pagination = Pagination()

@property
def is_displayed(self):
Expand Down
4 changes: 2 additions & 2 deletions airgun/views/cloud_insights.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from widgetastic.widget import Checkbox, Text, TextInput, View
from widgetastic_patternfly4 import Button, Pagination
from widgetastic_patternfly4 import Button, Pagination as PF4Pagination
from widgetastic_patternfly4.dropdown import Dropdown
from widgetastic_patternfly4.ouia import Modal, PatternflyTable, Switch

Expand Down Expand Up @@ -58,7 +58,7 @@ class CloudInsightsView(BaseLoggedInView, SearchableViewMixinPF4):
)
select_all_hits = Button('Select recommendations from all pages')
clear_hits_selection = Button('Clear Selection')
pagination = Pagination()
pagination = PF4Pagination()
remediation_window = View.nested(RemediationView)

@property
Expand Down
4 changes: 2 additions & 2 deletions airgun/views/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
View,
)
from widgetastic_patternfly import BreadCrumb
from widgetastic_patternfly4 import Pagination as PF4Pagination

from airgun.views.common import BaseLoggedInView, SatTab
from airgun.widgets import (
ActionsDropdown,
FilteredDropdown,
MultiSelect,
Pagination,
Search,
)

Expand All @@ -28,7 +28,7 @@ class FiltersView(BaseLoggedInView):
'Actions': ActionsDropdown("./div[contains(@class, 'btn-group')]"),
},
)
pagination = Pagination()
pagination = PF4Pagination()

@property
def is_displayed(self):
Expand Down
40 changes: 23 additions & 17 deletions airgun/views/host_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
from selenium.webdriver.common.keys import Keys
from widgetastic.widget import Checkbox, Text, TextInput, View, Widget
from widgetastic.widget.table import Table
from widgetastic_patternfly4 import Button, Dropdown, Pagination, Select, Tab
from widgetastic_patternfly4 import (
Button,
Dropdown,
Pagination as PF4Pagination,
Select,
Tab,
)
from widgetastic_patternfly4.ouia import (
BreadCrumb,
Button as OUIAButton,
Expand Down Expand Up @@ -364,7 +370,7 @@ class packages(Tab):
5: Dropdown(locator='.//div[contains(@class, "pf-c-dropdown")]'),
},
)
pagination = Pagination()
pagination = PF4Pagination()

@View.nested
class errata(Tab):
Expand All @@ -391,7 +397,7 @@ class errata(Tab):
8: Dropdown(locator='./div'),
},
)
pagination = Pagination()
pagination = PF4Pagination()

@View.nested
class module_streams(Tab):
Expand All @@ -417,7 +423,7 @@ class module_streams(Tab):
5: DropdownWithDescripton(locator='.//div[contains(@class, "pf-c-dropdown")]'),
},
)
pagination = Pagination()
pagination = PF4Pagination()

@View.nested
class repository_sets(Tab):
Expand Down Expand Up @@ -447,7 +453,7 @@ class repository_sets(Tab):
5: Dropdown(locator='.//div[contains(@class, "pf-c-dropdown")]'),
},
)
pagination = Pagination()
pagination = PF4Pagination()

@View.nested
class parameters(Tab):
Expand Down Expand Up @@ -482,7 +488,7 @@ class parameters(Tab):
5: Dropdown(locator='.//div[contains(@class, "pf-c-dropdown")]'),
},
)
pagination = Pagination()
pagination = PF4Pagination()

@View.nested
class traces(Tab):
Expand All @@ -505,7 +511,7 @@ class traces(Tab):
4: Button(locator='.//button[contains(@aria-label, "Actions")]'),
},
)
pagination = Pagination()
pagination = PF4Pagination()

@View.nested
class ansible(Tab):
Expand All @@ -524,7 +530,7 @@ class roles(Tab):
locator='.//table[contains(@class, "pf-c-table")]',
column_widgets={'Name': Text('.//a')},
)
pagination = Pagination()
pagination = PF4Pagination()

@View.nested
class variables(Tab):
Expand All @@ -546,7 +552,7 @@ class variables(Tab):
7: Button(locator='.//button[@aria-label="Edit override button"]'),
},
)
pagination = Pagination()
pagination = PF4Pagination()

@View.nested
class inventory(Tab):
Expand Down Expand Up @@ -590,7 +596,7 @@ class jobs(Tab):
4: Dropdown(locator='.//div[contains(@class, "pf-c-dropdown")]'),
},
)
pagination = Pagination()
pagination = PF4Pagination()

@property
def is_displayed(self):
Expand All @@ -610,7 +616,7 @@ class previous(Tab):
'Schedule': Text('./span'),
},
)
pagination = Pagination()
pagination = PF4Pagination()

@property
def is_displayed(self):
Expand All @@ -634,7 +640,7 @@ class puppet(Tab):
7: Button(locator='.//button[contains(@aria-label, "Actions")]'),
},
)
pagination = Pagination()
pagination = PF4Pagination()

@View.nested
class enc_preview(Tab):
Expand Down Expand Up @@ -675,7 +681,7 @@ class reports(Tab):
},
)

pagination = Pagination()
pagination = PF4Pagination()

@View.nested
class insights(Tab):
Expand All @@ -700,7 +706,7 @@ class insights(Tab):
4: Button(locator='.//button[contains(@aria-label, "Actions")]'),
},
)
pagination = Pagination()
pagination = PF4Pagination()


class InstallPackagesView(View):
Expand All @@ -719,7 +725,7 @@ class InstallPackagesView(View):
'Version': Text('./parent::td'),
},
)
pagination = Pagination()
pagination = PF4Pagination()

install = Button(locator='.//button[(normalize-space(.)="Install")]')
cancel = Button('Cancel')
Expand All @@ -734,7 +740,7 @@ class AllAssignedRolesView(View):
locator='.//table[contains(@class, "pf-c-table")]',
column_widgets={'Name': Text('.//a'), 'Source': Text('.//a')},
)
pagination = Pagination()
pagination = PF4Pagination()


class EnableTracerView(View):
Expand Down Expand Up @@ -773,7 +779,7 @@ class ManageHostCollectionModal(View):
},
)

pagination = Pagination()
pagination = PF4Pagination()

add = OUIAButton('add-button')
remove = OUIAButton('add-button')
Expand Down
2 changes: 2 additions & 0 deletions airgun/views/location.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from widgetastic.widget import Checkbox, Table, Text, TextInput, View
from widgetastic_patternfly import BreadCrumb
from widgetastic_patternfly4 import Pagination as PF4Pagination

from airgun.views.common import BaseLoggedInView, SatVerticalTab, SearchableViewMixinPF4
from airgun.widgets import (
Expand All @@ -20,6 +21,7 @@ class LocationsView(BaseLoggedInView, SearchableViewMixinPF4):
'Actions': ActionsDropdown("./div[contains(@class, 'btn-group')]"),
},
)
pagination = PF4Pagination()

@property
def is_displayed(self):
Expand Down
2 changes: 0 additions & 2 deletions airgun/views/task.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from wait_for import wait_for
from widgetastic.widget import Table, Text, View
from widgetastic_patternfly import BreadCrumb
from widgetastic_patternfly4 import Pagination

from airgun.views.common import BaseLoggedInView, SatTab, SearchableViewMixinPF4
from airgun.widgets import (
Expand Down Expand Up @@ -33,7 +32,6 @@ class TasksView(BaseLoggedInView, SearchableViewMixinPF4):
'Action': Text('./a'),
},
)
pagination = Pagination()

@property
def is_displayed(self):
Expand Down
11 changes: 4 additions & 7 deletions airgun/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
Kebab,
VerticalNavigation,
)
from widgetastic_patternfly4 import Pagination as PF4Pagination
from widgetastic_patternfly4.ouia import (
BaseSelect,
Button as PF4Button,
Expand Down Expand Up @@ -1670,12 +1671,6 @@ def fill(self, values):
widget.fill(value)


class SatTablePagination(Pagination):
"""Paginator widget for use within SatTable."""

ROOT = "//form[contains(@class, 'content-view-pf-pagination')]"


class SatTable(Table):
"""Satellite version of table.
Expand Down Expand Up @@ -1716,7 +1711,9 @@ class SatTable(Table):
"contains(@data-block, 'no-search-results-message')]"
)
tbody_row = Text('./tbody/tr')
pagination = SatTablePagination()
pagination = PF4Pagination(
locator="//div[contains(@class, 'pf-c-pagination') and not(contains(@class, 'pf-m-compact'))]"
)

@property
def has_rows(self):
Expand Down

0 comments on commit d06ef2b

Please sign in to comment.