Skip to content

Commit

Permalink
remember the entered email and reg. code
Browse files Browse the repository at this point in the history
and display it when going back

also make the input fields disabled when already registered during installation
  • Loading branch information
lslezak committed Apr 4, 2014
1 parent 31fc923 commit aafc62c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
28 changes: 23 additions & 5 deletions src/clients/inst_scc.rb
Expand Up @@ -103,8 +103,17 @@ def register_base_system
when :network
::Registration::Helpers::run_network_configuration
when :next
# do not re-register during installation
return :next if ::Registration::Registration.is_registered? && !Mode.normal

email = UI.QueryWidget(:email, :Value)
reg_code = UI.QueryWidget(:reg_code, :Value)

# remember the entered values in case user goes back
options = ::Registration::Storage::InstallationOptions.instance
options.email = email
options.reg_code = reg_code

# reset the user input in case an exception is raised
ret = nil

Expand Down Expand Up @@ -152,6 +161,7 @@ def scc_credentials_dialog
_("Unknown product")

base_product_name << " " << ::Registration::SwMgmt.base_version(base_product["version"])
options = ::Registration::Storage::InstallationOptions.instance

VBox(
Mode.installation ?
Expand All @@ -169,9 +179,9 @@ def scc_credentials_dialog
scelerisque a justo. Maecenas bibendum, mauris ut cursus pharetra, mi nibh
ehicula massa, eu luctus turpis eros eu arcu. Suspendisse iaculis nunc eu."),
VSpacing(1),
MinWidth(33, InputField(Id(:email), _("&Email"))),
MinWidth(33, InputField(Id(:email), _("&Email"), options.email)),
VSpacing(0.5),
MinWidth(33, InputField(Id(:reg_code), _("Registration &Code")))
MinWidth(33, InputField(Id(:reg_code), _("Registration &Code"), options.reg_code))
)
),
VSpacing(3),
Expand All @@ -196,6 +206,12 @@ def show_scc_credentials_dialog
GetInstArgs.enable_back,
GetInstArgs.enable_next || Mode.normal
)

# disable the input fields when already registered
if ::Registration::Registration.is_registered?
UI.ChangeWidget(Id(:email), :Enabled, false)
UI.ChangeWidget(Id(:reg_code), :Enabled, false)
end
end

def repo_items(repos)
Expand Down Expand Up @@ -636,9 +652,11 @@ def display_registered_dialog
end

def registration_check
return :register unless ::Registration::Registration.is_registered?

display_registered_dialog
if Mode.normal && ::Registration::Registration.is_registered?
return display_registered_dialog
else
return :register
end
end

# UI workflow definition
Expand Down
10 changes: 10 additions & 0 deletions src/lib/registration/storage.rb
Expand Up @@ -39,6 +39,16 @@ class BaseProducts < Struct.new(:products)
include Singleton
end

# remember the registered base product
class InstallationOptions < Struct.new(:install_updates, :email, :reg_code)
include Singleton

def initialize
self.email = ""
self.reg_code = ""
end
end

# AutoYast configuration
class Config
include Singleton
Expand Down

0 comments on commit aafc62c

Please sign in to comment.