Skip to content

Commit

Permalink
Small refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Mar 1, 2019
1 parent 0ce1858 commit ea8611d
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions src/lib/registration/ui/base_system_registration_dialog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -288,16 +288,6 @@ def register_scc_option
#
# @return [Yast::Term] UI terms
def register_local_option
# If not special URL is used, probe with SLP
if using_default_url?
# skip SLP discovery if the system is already registered
# during installation (the user is just going back)
urls = (Registration.is_registered? && !Yast::Mode.normal) ? [] : slp_urls
urls = [EXAMPLE_SMT_URL] if urls.empty?
else
urls = [reg_options[:custom_url]]
end

VBox(
Left(
RadioButton(
Expand All @@ -315,7 +305,7 @@ def register_local_option
VBox(
MinWidth(REG_CODE_WIDTH,
ComboBox(Id(:custom_url), Opt(:editable),
_("&Local Registration Server URL"), urls))
_("&Local Registration Server URL"), local_registration_urls))
)
)
),
Expand Down Expand Up @@ -564,6 +554,9 @@ def using_default_url?
# @return [Array<String>] The list of found URLs
#
def slp_urls
# do not scan again if the system has been registered during installation
# (the user is going back)
return [] if Registration.is_registered? && !Yast::Mode.normal
services = UrlHelpers.slp_discovery_feedback
services.map { |svc| UrlHelpers.service_url(svc.slp_url) }
end
Expand Down Expand Up @@ -624,6 +617,20 @@ def valid_custom_url?(custom_url)
rescue URI::InvalidURIError
false
end

#
# List of offered local registration servers
#
# @return [Array<String>] List of URLs
#
def local_registration_urls
# If no special URL is used, probe with SLP
return [reg_options[:custom_url]] unless using_default_url?

# use an example URL if no server was found via SLP
urls = slp_urls
urls.empty? ? [EXAMPLE_SMT_URL] : urls
end
end
end
end

0 comments on commit ea8611d

Please sign in to comment.