Class: Registration::UI::RegserviceSelectionDialog

Inherits:
Yast::Dialogs::ServiceSelection
  • Object
show all
Defined in:
src/lib/registration/ui/regservice_selection_dialog.rb

Overview

This class implements a SCC/SMT service selection dialog.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(services: [], heading: nil, description: nil) ⇒ RegserviceSelectionDialog

Constructor


60
61
62
63
64
65
66
67
68
69
# File 'src/lib/registration/ui/regservice_selection_dialog.rb', line 60

def initialize(services: [], heading: nil, description: nil)
  textdomain "registration"
  super(
    services:        [scc_service] + services,
    heading:         heading || _("Local Registration Servers"),
    description:     description || _("Select a detected registration server " \
                       "from the list\nor the default SUSE registration server."),
    no_selected_msg: _("No registration server selected")
  )
end

Class Method Details

.run(services:, heading: nil, description: nil) ⇒ SlpServiceClass::Service, Symbol

Run dialog

The return value will be:

  • A service in case one SMT server was selected
  • :scc symbol if default SCC was selected
  • :cancel symbol if the SCC was canceled (pressing the 'cancel' button)

Examples:

Select the default SCC service

Registration::UI::SelectionServiceDialog.run(services) #=> :scc

Select some SMT service

Registration::UI::SelectionServiceDialog.run(services)
  #=> #<Yast::SlpServiceClass::Service...>

See Also:

  • #run

49
50
51
# File 'src/lib/registration/ui/regservice_selection_dialog.rb', line 49

def self.run(services:, heading: nil, description: nil)
  new(services: services, heading: heading, description: description).run
end

Instance Method Details

#ok_handlerObject

Handler for the Ok button

If no option was selected, a error message is shown.

See Also:

  • Yast::Dialogs::ServiceSelection#ok_handler

76
77
78
79
# File 'src/lib/registration/ui/regservice_selection_dialog.rb', line 76

def ok_handler
  selected = super
  finish_dialog(:scc) if selected == scc_service
end

#service_to_description(service) ⇒ String

Return the service description to be shown to the user

This method just overrides the services description in case of a String is passed (instead of a SlpServiceClass::Service). It's needed because the "scc" option is not a proper service, just a special value.

See Also:

  • Yast::Dialogs::ServiceSelection#service_to_description

92
93
94
# File 'src/lib/registration/ui/regservice_selection_dialog.rb', line 92

def service_to_description(service)
  service.is_a?(String) ? service : super
end