class ProvDiagForm(View): """Base form with common widgets for add and edit""" name = TextInput('name') description = TextInput('description') diag_type = BootstrapSelect(id='dialog_type') content = ScriptBox('//textarea[contains(@id, "content_data")]') cancel = Button('Cancel')
class MethodDetailsView(AutomateExplorerView): title = Text('#explorer_title_text') fqdn = SummaryFormItem( 'Main Info', 'Fully Qualified Name', text_filter=lambda text: [item.strip() for item in text.strip().lstrip('/').split('/')]) name = SummaryFormItem('Main Info', 'Name') display_name = SummaryFormItem('Main Info', 'Display Name') location = SummaryFormItem('Main Info', 'Location') created_on = SummaryFormItem('Main Info', 'Created On', text_filter=parsetime.from_iso_with_utc) inputs = Table(locator='#params_grid', assoc_column='Input Name') script = ScriptBox() embedded_method_table = Table( "//*[@id='embedded_methods_div']/table[contains(@class, 'table')]" ) @property def is_displayed(self): return ( self.in_explorer and self.title.text.startswith('Automate Method [{}'.format( self.context['object'].display_name or self.context['object'].name)) and self.fqdn.is_displayed and # We check namespace separately as in tree there is status included self.fqdn.text[0] in self.context['object'].tree_path_name_only[1] and # We need to chop off the leading Domain name and namespace(cheecked in previous line) self.fqdn.text[1:] == self.context['object'].tree_path_name_only[2:])
class MethodEditView(AutomateExplorerView): title = Text('#explorer_title_text') name = Input(name='method_name') display_name = Input(name='method_display_name') location = BootstrapSelect('method_location') script = ScriptBox() data = Input(name='method_data') validate_button = Button('Validate') save_button = Button('Save') reset_button = Button('Reset') cancel_button = Button('Cancel') # TODO: Input parameters @property def is_displayed(self): return ( self.in_explorer and self.datastore.is_opened and self.title.text == 'Editing Automate Method "{}"'.format( self.context['object'].name) and check_tree_path( self.datastore.tree.currently_selected, self.context['object'].tree_path))
class MethodAddView(AutomateExplorerView): title = Text('#explorer_title_text') location = BootstrapSelect('cls_method_location', can_hide_on_select=True) inline_name = Input(name='cls_method_name') inline_display_name = Input(name='cls_method_display_name') script = ScriptBox() data = Input(name='cls_method_data') validate_button = Button('Validate') # TODO: inline input parameters playbook_name = Input(name='name') playbook_display_name = Input(name='display_name') repository = PlaybookBootstrapSelect('provisioning_repository_id') playbook = PlaybookBootstrapSelect('provisioning_playbook_id') machine_credential = PlaybookBootstrapSelect( 'provisioning_machine_credential_id') hosts = Input('provisioning_inventory') max_ttl = Input('provisioning_execution_ttl') escalate_privilege = BootstrapSwitch('provisioning_become_enabled') verbosity = PlaybookBootstrapSelect('provisioning_verbosity') playbook_input_parameters = PlaybookInputParameters() add_button = Button('Add') cancel_button = Button('Cancel') @property def is_displayed(self): return (self.in_explorer and self.datastore.is_opened and self.title.text == 'Adding a new Automate Method' and check_tree_path(self.datastore.tree.currently_selected, self.context['object'].tree_path))
class TemplateForm(ServicesCatalogView): title = Text('#explorer_title_text') template_type = BootstrapSelect("type") name = Input(name='name') description = Input(name="description") draft = Checkbox(name='draft') content = ScriptBox(locator="//pre[@class=' CodeMirror-line ']/span")
class MethodAddView(AutomateExplorerView): title = Text('#explorer_title_text') location = BootstrapSelect('cls_method_location', can_hide_on_select=True) name = Input(name='cls_method_name') display_name = Input(name='cls_method_display_name') script = ScriptBox() data = Input(name='cls_method_data') validate_button = Button('Validate') add_button = Button('Add') cancel_button = Button('Cancel') # TODO: Input parameters @property def is_displayed(self): return ( self.in_explorer and self.datastore.is_opened and self.title.text == 'Adding a new Automate Method' and check_tree_path( self.datastore.tree.currently_selected, self.context['object'].tree_path))
class PXECustomizationTemplateForm(View): title = Text('//div[@id="main-content"]//h1') name = Input(id='name') description = Input(id='description') image_type = BootstrapSelect(id='img_typ') type = BootstrapSelect(id='typ') script = ScriptBox(locator='//textarea[contains(@id, "script_data")]') is_displayed = displayed_not_implemented
class CopyTemplateForm(ServicesCatalogView): title = Text('#explorer_title_text') name = Input(name='name') description = Input(name="description") draft = Checkbox(name='draft') content = ScriptBox(locator="//pre[@class=' CodeMirror-line ']/span") cancel_button = Button('Cancel')
class MethodEditView(AutomateExplorerView): title = Text('#explorer_title_text') # inline inline_name = Input(name='method_name') inline_display_name = Input(name='method_display_name') script = ScriptBox() data = Input(name='method_data') validate_button = Button('Validate') inputs = View.nested(Inputs) # playbook playbook_name = Input(name='name') playbook_display_name = Input(name='display_name') repository = PlaybookBootstrapSelect('provisioning_repository_id') playbook = PlaybookBootstrapSelect('provisioning_playbook_id') machine_credential = PlaybookBootstrapSelect('provisioning_machine_credential_id') hosts = Input('provisioning_inventory') max_ttl = Input('provisioning_execution_ttl') logging_output = PlaybookBootstrapSelect('provisioning_log_output') escalate_privilege = BootstrapSwitch('provisioning_become_enabled') verbosity = PlaybookBootstrapSelect('provisioning_verbosity') playbook_input_parameters = PlaybookInputParameters() # Edit embedded method embedded_method_table = Table('//*[@id="embedded_methods_div"]/table') embedded_method = EntryPoint(locator='//*[@id="automate-inline-method-select"]//button', tree_id="treeview-entrypoint_selection") save_button = Button('Save') reset_button = Button('Reset') cancel_button = Button('Cancel') def before_fill(self, values): location = self.context['object'].location.lower() if 'display_name' in values and location in ['inline', 'playbook']: values['{}_display_name'.format(location)] = values['display_name'] del values['display_name'] elif 'name' in values and location in ['inline', 'playbook']: values['{}_name'.format(location)] = values['name'] del values['name'] @property def is_displayed(self): return ( self.in_explorer and self.datastore.is_opened and (f'Editing Automate Method "{self.context["object"].name}"' in self.title.text) and check_tree_path( self.datastore.tree.currently_selected, self.context["object"].tree_path, partial=True, ) )
class PXECustomizationTemplateForm(View): title = Text('//div[@id="main-content"]//h1') name = Input(id='name') description = Input(id='description') image_type = BootstrapSelect(id='img_typ') type = BootstrapSelect(id='typ') script = ScriptBox(locator='//textarea[contains(@id, "script_data")]') @property def is_displayed(self): raise NotImplementedError( "This view has no unique markers for is_displayed check")
class PXECustomizationTemplateForm(View): title = Text('//div[@id="main-content"]//h1') flash = FlashMessages('.//div[@id="flash_msg_div"]/div[@id="flash_text_div" or ' 'contains(@class, "flash_text_div")]') name = Input(id='name') description = Input(id='description') image_type = BootstrapSelect(id='img_typ') type = BootstrapSelect(id='typ') script = ScriptBox(locator='//textarea[contains(@id, "script_data")]') @property def is_displayed(self): return False
class TemplateForm(ServicesCatalogView): title = Text('#explorer_title_text') template_type = VersionPicker({ "5.11": ReactSelect("type"), LOWEST: BootstrapSelect("type") }) name = Input(name='name') description = Input(name="description") draft = Checkbox(name='draft') content = VersionPicker({ "5.11": ReactCodeMirror(), LOWEST: ScriptBox(locator="//pre[@class=' CodeMirror-line ']/span") })
class MethodEditView(AutomateExplorerView): title = Text('#explorer_title_text') # inline inline_name = Input(name='method_name') inline_display_name = Input(name='method_display_name') script = ScriptBox() data = Input(name='method_data') validate_button = Button('Validate') inputs = View.nested(Inputs) # playbook playbook_name = Input(name='name') playbook_display_name = Input(name='display_name') repository = PlaybookBootstrapSelect('provisioning_repository_id') playbook = PlaybookBootstrapSelect('provisioning_playbook_id') machine_credential = PlaybookBootstrapSelect('provisioning_machine_credential_id') hosts = Input('provisioning_inventory') max_ttl = Input('provisioning_execution_ttl') escalate_privilege = BootstrapSwitch('provisioning_become_enabled') verbosity = PlaybookBootstrapSelect('provisioning_verbosity') playbook_input_parameters = PlaybookInputParameters() save_button = Button('Save') reset_button = Button('Reset') cancel_button = Button('Cancel') def before_fill(self, values): location = self.context['object'].location if 'display_name' in values and location in ['inline', 'playbook']: values['{}_display_name'.format(location)] = values['display_name'] del values['display_name'] elif 'name' in values and location in ['inline', 'playbook']: values['{}_name'.format(location)] = values['name'] del values['name'] @property def is_displayed(self): return ( self.in_explorer and self.datastore.is_opened and self.title.text == 'Editing Automate Method "{}"'.format( self.context['object'].name) and check_tree_path( self.datastore.tree.currently_selected, self.context['object'].tree_path))
class MethodAddView(AutomateExplorerView): fill_strategy = WaitFillViewStrategy() title = Text('#explorer_title_text') location = BootstrapSelect('cls_method_location', can_hide_on_select=True) inline_name = Input(name='cls_method_name') inline_display_name = Input(name='cls_method_display_name') script = ScriptBox() data = Input(name='cls_method_data') validate_button = Button('Validate') inputs = View.nested(Inputs) playbook_name = Input(name='name') playbook_display_name = Input(name='display_name') repository = PlaybookBootstrapSelect('provisioning_repository_id') playbook = PlaybookBootstrapSelect('provisioning_playbook_id') machine_credential = PlaybookBootstrapSelect('provisioning_machine_credential_id') hosts = Input('provisioning_inventory') max_ttl = Input('provisioning_execution_ttl') logging_output = PlaybookBootstrapSelect('provisioning_log_output') escalate_privilege = BootstrapSwitch('provisioning_become_enabled') verbosity = PlaybookBootstrapSelect('provisioning_verbosity') playbook_input_parameters = PlaybookInputParameters() # Add embedded method embedded_method_table = Table('//*[@id="embedded_methods_div"]/table') embedded_method = EntryPoint(locator='//*[@id="automate-inline-method-select"]//button', tree_id="treeview-entrypoint_selection") add_button = Button('Add') cancel_button = Button('Cancel') @property def is_displayed(self): return ( self.in_explorer and self.datastore.is_opened and self.title.text == 'Adding a new Automate Method' and check_tree_path( self.datastore.tree.currently_selected, self.context['object'].tree_path))
class entities(View): # noqa basic_information = SummaryTable(title="Basic Information") script = ScriptBox(locator='//textarea[contains(@id, "script_data")]')
class ProvDiagDetailsEntities(View): """Entities for details page""" title = Text('#explorer_title_text') basic_info = SummaryForm(group_title=group_title) content = ScriptBox('//textarea[contains(@id, "script_data")]')