Skip to content

Commit 1f4d4b7

Browse files
authored
Add search autocomplete to all hosts page (#2492)
1 parent a9c676c commit 1f4d4b7

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

airgun/entities/host_new.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,23 @@ def create(self, values):
6262
host_view.flash.assert_no_error()
6363
host_view.flash.dismiss()
6464

65+
def search_autocomplete(self, value):
66+
"""Search the All Hosts page and return autocomplete suggestions or error messages."""
67+
view = self.navigate_to(self, 'NewUIAll')
68+
view.searchbox.clear()
69+
view.searchbox.fill(value)
70+
results = (
71+
wait_for(
72+
view.autocomplete_menu.read,
73+
timeout=5,
74+
delay=0.5,
75+
handle_exception=True,
76+
silent_failure=True,
77+
)[0]
78+
or []
79+
)
80+
return results
81+
6582
def get_details(self, entity_name, widget_names=None):
6683
"""Read host values from Host Details page, optionally only the widgets in widget_names will be read."""
6784
view = self.navigate_to(self, 'NewDetails', entity_name=entity_name)

airgun/views/all_hosts.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
WizardStepView,
3636
)
3737
from airgun.views.host_new import ManageColumnsView, PF5CheckboxTreeView
38-
from airgun.widgets import ItemsList, SearchInput
38+
from airgun.widgets import ItemsList, PF5NavSearchMenu, SearchInput
3939

4040

4141
class MenuToggleDropdownInTable(PF5Dropdown):
@@ -122,6 +122,7 @@ class AllHostsTableView(BaseLoggedInView, SearchableViewMixinPF4):
122122
2: MenuToggleDropdownInTable(),
123123
},
124124
)
125+
autocomplete_menu = PF5NavSearchMenu(component_id='search-autocomplete-menu')
125126
alert_message = Text('.//div[contains(@class, "pf-v5-c-alert")]')
126127

127128
# Host status icon and popover widgets

0 commit comments

Comments
 (0)