Skip to content

Commit

Permalink
Merge pull request #517 from mchf/bnc1022546-reset-on-change
Browse files Browse the repository at this point in the history
Do not reset all-in-one dialog when sub dialog is closed
  • Loading branch information
mchf committed Feb 14, 2017
2 parents acc7ad7 + 2577ba7 commit e52c223
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 25 deletions.
9 changes: 9 additions & 0 deletions package/yast2-installation.changes
@@ -1,3 +1,12 @@
-------------------------------------------------------------------
Mon Feb 13 14:49:14 UTC 2017 - mfilka@suse.com

- bnc#1022546
- update all-in-one's subdialog (network/kdump/partitioning/...)
overview when the dialog is closed and do not lose another
content already entered by user.
- 3.1.217.23

-------------------------------------------------------------------
Mon Feb 13 14:12:59 CET 2017 - schubi@suse.de

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-installation.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-installation
Version: 3.1.217.22
Version: 3.1.217.23
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
26 changes: 16 additions & 10 deletions src/lib/installation/clients/inst_casp_overview.rb
Expand Up @@ -68,16 +68,18 @@ def run
ret = Yast::CWM.show(
content,
# Title for installation overview dialog
caption: _("Installation Overview"),
caption: _("Installation Overview"),
# Button label: start the installation
next_button: _("Install"),
next_button: _("Install"),
# do not show abort and back button
abort_button: "",
back_button: "",
# do not store stuff when just redrawing
skip_store_for: [:redraw]
abort_button: "",
back_button: ""
)
next if ret == :redraw

# Currently no other return value is expected, behavior can
# be unpredictable if something else is received - raise
# RuntimeError
raise "Unexpected return value" if ret != :next

# do software proposal
d = Yast::WFM.CallFunction("software_proposal",
Expand Down Expand Up @@ -145,6 +147,10 @@ def quadrant_layout(upper_left:, lower_left:, upper_right:, lower_right:)
# block installation
def content
controller_node = Installation::Widgets::ControllerNodePlace.new

kdump_overview = Installation::Widgets::Overview.new(client: "kdump_proposal")
bootloader_overview = Installation::Widgets::Overview.new(client: "bootloader_proposal", redraw: [kdump_overview])

quadrant_layout(
upper_left: VBox(
::Registration::Widgets::RegistrationCode.new,
Expand All @@ -158,12 +164,12 @@ def content
Tune::Widgets::SystemInformation.new
),
upper_right: VBox(
Installation::Widgets::Overview.new(client: "partitions_proposal"),
Installation::Widgets::Overview.new(client: "bootloader_proposal")
Installation::Widgets::Overview.new(client: "partitions_proposal", redraw: [bootloader_overview]),
bootloader_overview
),
lower_right: VBox(
Installation::Widgets::Overview.new(client: "network_proposal"),
Installation::Widgets::Overview.new(client: "kdump_proposal")
kdump_overview
)
)
end
Expand Down
41 changes: 35 additions & 6 deletions src/lib/installation/widgets/overview.rb
Expand Up @@ -33,20 +33,22 @@ class Overview < CWM::CustomWidget
attr_reader :proposal_client

# @param client [String] A proposal client implementing simple_mode,
# @param redraw [Array<Overview>] list of other Overview clients. In case
# of :redraw action every of these clients will be redrawn too. Caller is
# responsible for not creating circular dependencies.
# eg. "bootloader_proposal"
def initialize(client:)
def initialize(client:, redraw: [])
textdomain "installation"
@proposal_client = client
@replace_point = "rp_" + client
# by default widget_id is the class name; must differentiate instances
self.widget_id = "overview_" + client
@blocking = false
@overviews_for_redraw = redraw
end

def contents
VBox(
Left(PushButton(Id(button_id), label)),
* items.map { |i| Left(Label(" * #{i}")) }
)
ReplacePoint(Id(@replace_point), widget)
end

def label
Expand Down Expand Up @@ -80,9 +82,22 @@ def items
@items = d["label_proposal"]
end

# Updates overview content
def redraw
reset

Yast::UI.ReplaceWidget(Id(@replace_point), widget)

@overviews_for_redraw.each(&:redraw)
end

# Custom event handler
def handle(_event)
Yast::WFM.CallFunction(proposal_client, ["AskUser", {}])
:redraw

redraw

nil
end

def validate
Expand All @@ -107,6 +122,20 @@ def button_id
# an arbitrary unique id
"ask_" + proposal_client
end

# The overview representation in common UI widgets
def widget
VBox(
Left(PushButton(Id(button_id), label)),
* items.map { |i| Left(Label(" * #{i}")) }
)
end

# Flush cache(s)
def reset
@label = nil
@items = nil
end
end
end
end
8 changes: 0 additions & 8 deletions test/inst_casp_overview_test.rb
Expand Up @@ -103,14 +103,6 @@ def label
subject.run
end

it "shows CWM widgets again if it returns redraw event" do
allow(Yast::Mode).to receive(:normal).and_return(true)

expect(Yast::CWM).to receive(:show).twice.and_return(:redraw, :next)

subject.run
end

it "adds caasp specific services to be enabled" do
subject.run

Expand Down

0 comments on commit e52c223

Please sign in to comment.