Skip to content

Commit

Permalink
Adjust all hosts to use menu, add support for Build Management
Browse files Browse the repository at this point in the history
  • Loading branch information
sambible authored and pondrejk committed Aug 8, 2024
1 parent e488c25 commit 1e5c8a9
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
18 changes: 18 additions & 0 deletions airgun/entities/all_hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from airgun.views.all_hosts import (
AllHostsManageColumnsView,
AllHostsTableView,
BuildManagementDialog,
BulkHostDeleteDialog,
HostDeleteDialog,
)
Expand Down Expand Up @@ -62,6 +63,23 @@ def bulk_delete_all(self):
view.wait_displayed()
return view.no_results

def build_management(self, reboot=False, rebuild=False):
"""Build or rebuild hosts through build management popup"""
view = self.navigate_to(self, 'All')
self.browser.plugin.ensure_page_safe(timeout='5s')
view.wait_displayed()
view.select_all.fill(True)
view.bulk_actions.item_select('Build management')
build_management_modal = BuildManagementDialog(self.browser)
if build_management_modal.is_displayed:
if reboot:
build_management_modal.reboot_now.fill(True)
if rebuild:
build_management_modal.rebuild_provisioning_only.fill(True)
build_management_modal.confirm.click()
self.browser.wait_for_element(view.alert_message, exception=False)
return view.alert_message.read()

def manage_table_columns(self, values: dict):
"""
Select which columns should be displayed in the hosts table.
Expand Down
32 changes: 30 additions & 2 deletions airgun/views/all_hosts.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from widgetastic.widget import Checkbox, Text, View
from widgetastic_patternfly4 import Button, Dropdown
from widgetastic_patternfly4 import Button, Dropdown, Menu, Radio
from widgetastic_patternfly4.ouia import (
PatternflyTable,
)
Expand All @@ -11,12 +11,18 @@
from airgun.views.host_new import ManageColumnsView, PF4CheckboxTreeView


class AllHostsMenu(Menu):
IS_ALWAYS_OPEN = False
BUTTON_LOCATOR = ".//button[contains(@class, 'pf-c-menu-toggle')]"
ROOT = f"{BUTTON_LOCATOR}/.."


class AllHostsTableView(BaseLoggedInView, SearchableViewMixinPF4):
title = Text("//h1[normalize-space(.)='Hosts']")
select_all = Checkbox(
locator='.//input[@data-ouia-component-id="select-all-checkbox-dropdown-toggle-checkbox"]'
)
bulk_actions = Dropdown(locator='.//div[@data-ouia-component-id="action-buttons-dropdown"]')
bulk_actions = AllHostsMenu()
table_loading = Text("//h5[normalize-space(.)='Loading']")
no_results = Text("//h5[normalize-space(.)='No Results']")
manage_columns = Button("Manage columns")
Expand All @@ -28,6 +34,7 @@ class AllHostsTableView(BaseLoggedInView, SearchableViewMixinPF4):
2: Dropdown(locator='.//div[contains(@class, "pf-c-dropdown")]'),
},
)
alert_message = Text('.//div[@aria-label="Success Alert" or @aria-label="Danger Alert"]')

@property
def is_displayed(self):
Expand All @@ -52,6 +59,27 @@ def is_displayed(self):
return self.browser.wait_for_element(self.title, exception=False) is not None


class BuildManagementDialog(View):
"""Dialog for Build Management"""

ROOT = './/div[@data-ouia-component-id="bulk-build-hosts-modal"]'

title = Text(".//h1[normalize-space(.)='Build management']")

build = Radio(locator='.//input[@data-ouia-component-id="build-host-radio"]')
reboot_now = Checkbox(locator='.//input[@data-ouia-component-id="build-reboot-checkbox"]')
rebuild_provisioning_only = Checkbox(
locator='.//input[@data-ouia-component-id="rebuild-host-radio"]'
)

confirm = Button(locator='//button[normalize-space(.)="Confirm"]')
cancel = Button(locator='//button[normalize-space(.)="Cancel"]')

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


class BulkHostDeleteDialog(View):
"""Confirmation dialog for bulk deleting hosts or hosts with compute resources"""

Expand Down

0 comments on commit 1e5c8a9

Please sign in to comment.