Skip to content

Commit

Permalink
Separated restart network confirmation dialog into own class.
Browse files Browse the repository at this point in the history
The dialog is displayed only during installation when virtual proposals
are in game (it happens when installing VM host)
  • Loading branch information
mchf committed Dec 16, 2013
1 parent 8a2b49a commit 04b1414
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 62 deletions.
3 changes: 2 additions & 1 deletion src/Makefile.am
Expand Up @@ -110,7 +110,8 @@ desktop_DATA = \

ylibdir = "${yast2dir}/lib/network"
ylib_DATA = \
lib/network/edit_nic_name.rb
lib/network/edit_nic_name.rb \
lib/network/confirm_virt_proposal.rb

EXTRA_DIST = \
$(module_DATA) \
Expand Down
94 changes: 94 additions & 0 deletions src/lib/network/confirm_virt_proposal.rb
@@ -0,0 +1,94 @@
# encoding: utf-8

require 'yast'

module Yast

Yast.import "UI"
Yast.import "LanItems"
Yast.import "Popup"

# The class represents a simple dialog which asks user for confirmation of
# network.service restart during installation.
class ConfirmVirtProposal

include UIShortcuts
include I18n

def self.run
open

# for autoinstallation popup has timeout 10 seconds (#192181)
# timeout for every case (bnc#429562)
ret = UI.TimeoutUserInput(10 * 1000)

close

ret
end

private

def self.open
UI.OpenDialog(
Opt(:decorated),
HBox(
HSpacing(1),
HCenter(
HSquash(
VBox(
HCenter(
HSquash(
VBox(
# This is the heading of the popup box
Left(Heading(_("Confirm Network Restart"))),
VSpacing(0.5),
# This is in information message. Next come the
# hardware class name (network cards).
HVCenter(
Label(
_(
"Because of the bridged network, YaST2 needs to restart the network to apply the settings."
)
)
),
VSpacing(0.5)
)
)
),
ButtonBox(
HWeight(
1,
PushButton(
Id(:ok),
Opt(:default, :okButton),
Label.OKButton
)
),
# PushButton label
HWeight(
1,
PushButton(
Id(:cancel),
Opt(:cancelButton),
Label.CancelButton
)
)
),
VSpacing(0.2)
)
)
),
HSpacing(1)
)
)

UI.SetFocus(Id(:ok))
end

def self.close
UI.CloseDialog
end

end
end
65 changes: 4 additions & 61 deletions src/modules/Lan.rb
Expand Up @@ -30,6 +30,7 @@
# Representation of the configuration of network cards.
# Input and output routines.
require "yast"
require "network/confirm_virt_proposal"

module Yast
class LanClass < Module
Expand Down Expand Up @@ -642,74 +643,16 @@ def Write
)
end

Builtins.y2internal("virt_net_proposal %1", @virt_net_proposal)
Builtins.y2milestone("virt_net_proposal %1", @virt_net_proposal)
if Stage.cont && @virt_net_proposal == true &&
(Linuxrc.usessh || Linuxrc.vnc || Linuxrc.display_ip)
UI.OpenDialog(
Opt(:decorated),
HBox(
HSpacing(1),
HCenter(
HSquash(
VBox(
HCenter(
HSquash(
VBox(
# This is the heading of the popup box
Left(Heading(_("Confirm Network Restart"))),
VSpacing(0.5),
# This is in information message. Next come the
# hardware class name (network cards).
HVCenter(
Label(
_(
"Because of the bridged network, YaST2 needs to restart the network to apply the settings."
)
)
),
VSpacing(0.5)
)
)
),
ButtonBox(
HWeight(
1,
PushButton(
Id(:ok),
Opt(:default, :okButton),
Label.OKButton
)
),
# PushButton label
HWeight(
1,
PushButton(
Id(:cancel),
Opt(:cancelButton),
Label.CancelButton
)
)
),
VSpacing(0.2)
)
)
),
HSpacing(1)
)
)

UI.SetFocus(Id(:ok))

# for autoinstallation popup has timeout 10 seconds (#192181)
# timeout for every case (bnc#429562)
ret = UI.TimeoutUserInput(10 * 1000)
if ret == :ok
Builtins.y2internal(
if ConfirmVirtProposal.run == :ok
Builtins.y2milestone(
"Restarting network because of bridged proposal"
)
NetworkService.Restart
end
UI.CloseDialog
# For ssh/vnc installation don't reload/restart network because possibility of IP change (bnc#347482)
elsif Stage.cont &&
(Linuxrc.usessh || Linuxrc.vnc || Linuxrc.display_ip)
Expand Down

0 comments on commit 04b1414

Please sign in to comment.