From 9224067046d3c00132135f30ca4c2eb033784f20 Mon Sep 17 00:00:00 2001 From: Michal Filka Date: Thu, 9 Feb 2017 10:44:42 +0100 Subject: [PATCH 1/9] Implemented redrawing in the Overview widget. --- .../clients/inst_casp_overview.rb | 8 ++--- src/lib/installation/widgets/overview.rb | 30 +++++++++++++++---- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/lib/installation/clients/inst_casp_overview.rb b/src/lib/installation/clients/inst_casp_overview.rb index b547cd824..f19f4fe90 100644 --- a/src/lib/installation/clients/inst_casp_overview.rb +++ b/src/lib/installation/clients/inst_casp_overview.rb @@ -73,11 +73,11 @@ def run 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] + back_button: "" ) - next if ret == :redraw + + # TODO: check exception type + raise ArgumentError, "Unexpected return value" if ret != :next # do software proposal d = Yast::WFM.CallFunction("software_proposal", diff --git a/src/lib/installation/widgets/overview.rb b/src/lib/installation/widgets/overview.rb index fcefb5839..ce7721118 100644 --- a/src/lib/installation/widgets/overview.rb +++ b/src/lib/installation/widgets/overview.rb @@ -37,16 +37,14 @@ class Overview < CWM::CustomWidget def initialize(client:) 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 end def contents - VBox( - Left(PushButton(Id(button_id), label)), - * items.map { |i| Left(Label(" * #{i}")) } - ) + ReplacePoint(Id(@replace_point), widget) end def label @@ -80,9 +78,18 @@ def items @items = d["label_proposal"] end + def redraw + reset + + Yast::UI.ReplaceWidget(Id(@replace_point), widget) + end + def handle(_event) Yast::WFM.CallFunction(proposal_client, ["AskUser", {}]) - :redraw + + redraw + + nil end def validate @@ -107,6 +114,19 @@ def button_id # an arbitrary unique id "ask_" + proposal_client end + + 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 From 5f0ba87d85c80f3edf19fe78ecddc4cf9c224b61 Mon Sep 17 00:00:00 2001 From: Michal Filka Date: Thu, 9 Feb 2017 22:38:50 +0100 Subject: [PATCH 2/9] Removed useless testsuite all in one dialog do not call show several times anymore when opening dialog for proposal --- test/inst_casp_overview_test.rb | 8 -------- 1 file changed, 8 deletions(-) diff --git a/test/inst_casp_overview_test.rb b/test/inst_casp_overview_test.rb index 5eca2039a..faa9da845 100755 --- a/test/inst_casp_overview_test.rb +++ b/test/inst_casp_overview_test.rb @@ -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 From b1116580af07d7fb0b902524d17075a981ba92bf Mon Sep 17 00:00:00 2001 From: Michal Filka Date: Mon, 13 Feb 2017 09:22:40 +0100 Subject: [PATCH 3/9] Handle redraw in dependent overviews. --- src/lib/installation/clients/inst_casp_overview.rb | 10 +++++++--- src/lib/installation/widgets/overview.rb | 8 +++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/lib/installation/clients/inst_casp_overview.rb b/src/lib/installation/clients/inst_casp_overview.rb index f19f4fe90..084d40bd3 100644 --- a/src/lib/installation/clients/inst_casp_overview.rb +++ b/src/lib/installation/clients/inst_casp_overview.rb @@ -145,6 +145,10 @@ def quadrant_layout(upper_left:, lower_left:, upper_right:, lower_right:) # block installation def content controller_node = Installation::Widgets::ControllerNodePlace.new + + bootloader_overview = Installation::Widgets::Overview.new(client: "bootloader_proposal") + kdump_overview = Installation::Widgets::Overview.new(client: "kdump_proposal") + quadrant_layout( upper_left: VBox( ::Registration::Widgets::RegistrationCode.new, @@ -158,12 +162,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", on_redraw: [ kdump_overview, bootloader_overview ]), + bootloader_overview ), lower_right: VBox( Installation::Widgets::Overview.new(client: "network_proposal"), - Installation::Widgets::Overview.new(client: "kdump_proposal") + kdump_overview ) ) end diff --git a/src/lib/installation/widgets/overview.rb b/src/lib/installation/widgets/overview.rb index ce7721118..850e6becc 100644 --- a/src/lib/installation/widgets/overview.rb +++ b/src/lib/installation/widgets/overview.rb @@ -33,14 +33,18 @@ class Overview < CWM::CustomWidget attr_reader :proposal_client # @param client [String] A proposal client implementing simple_mode, + # @param redraw [Array] 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:, on_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 = on_redraw end def contents @@ -82,6 +86,8 @@ def redraw reset Yast::UI.ReplaceWidget(Id(@replace_point), widget) + + @overviews_for_redraw.each(&:redraw) end def handle(_event) From 71d58be930b40bca8fb265455c99cf047ebebf40 Mon Sep 17 00:00:00 2001 From: Michal Filka Date: Mon, 13 Feb 2017 11:04:17 +0100 Subject: [PATCH 4/9] Documentation --- src/lib/installation/widgets/overview.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib/installation/widgets/overview.rb b/src/lib/installation/widgets/overview.rb index 850e6becc..6e6cf9ea9 100644 --- a/src/lib/installation/widgets/overview.rb +++ b/src/lib/installation/widgets/overview.rb @@ -82,6 +82,7 @@ def items @items = d["label_proposal"] end + # Updates overview content def redraw reset @@ -90,6 +91,7 @@ def redraw @overviews_for_redraw.each(&:redraw) end + # Custom event handler def handle(_event) Yast::WFM.CallFunction(proposal_client, ["AskUser", {}]) @@ -121,6 +123,7 @@ def button_id "ask_" + proposal_client end + # The overview representation in common UI widgets def widget VBox( Left(PushButton(Id(button_id), label)), From 96951104fc573bf9849ddaefef5eca06b4e7850c Mon Sep 17 00:00:00 2001 From: Michal Filka Date: Mon, 13 Feb 2017 11:11:50 +0100 Subject: [PATCH 5/9] Fixed overview dependencies --- src/lib/installation/clients/inst_casp_overview.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/installation/clients/inst_casp_overview.rb b/src/lib/installation/clients/inst_casp_overview.rb index 084d40bd3..87a03ba06 100644 --- a/src/lib/installation/clients/inst_casp_overview.rb +++ b/src/lib/installation/clients/inst_casp_overview.rb @@ -146,8 +146,8 @@ def quadrant_layout(upper_left:, lower_left:, upper_right:, lower_right:) def content controller_node = Installation::Widgets::ControllerNodePlace.new - bootloader_overview = Installation::Widgets::Overview.new(client: "bootloader_proposal") kdump_overview = Installation::Widgets::Overview.new(client: "kdump_proposal") + bootloader_overview = Installation::Widgets::Overview.new(client: "bootloader_proposal", on_redraw: [ kdump_overview ]) quadrant_layout( upper_left: VBox( @@ -162,7 +162,7 @@ def content Tune::Widgets::SystemInformation.new ), upper_right: VBox( - Installation::Widgets::Overview.new(client: "partitions_proposal", on_redraw: [ kdump_overview, bootloader_overview ]), + Installation::Widgets::Overview.new(client: "partitions_proposal", on_redraw: [ bootloader_overview ]), bootloader_overview ), lower_right: VBox( From 5059ede8eb1c2b337cd578ae6a19f8652ac01303 Mon Sep 17 00:00:00 2001 From: Michal Filka Date: Mon, 13 Feb 2017 11:17:34 +0100 Subject: [PATCH 6/9] Happy rubocop --- src/lib/installation/clients/inst_casp_overview.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib/installation/clients/inst_casp_overview.rb b/src/lib/installation/clients/inst_casp_overview.rb index 87a03ba06..80e90b603 100644 --- a/src/lib/installation/clients/inst_casp_overview.rb +++ b/src/lib/installation/clients/inst_casp_overview.rb @@ -68,12 +68,12 @@ 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: "" + abort_button: "", + back_button: "" ) # TODO: check exception type @@ -147,7 +147,7 @@ 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", on_redraw: [ kdump_overview ]) + bootloader_overview = Installation::Widgets::Overview.new(client: "bootloader_proposal", on_redraw: [kdump_overview]) quadrant_layout( upper_left: VBox( @@ -162,7 +162,7 @@ def content Tune::Widgets::SystemInformation.new ), upper_right: VBox( - Installation::Widgets::Overview.new(client: "partitions_proposal", on_redraw: [ bootloader_overview ]), + Installation::Widgets::Overview.new(client: "partitions_proposal", on_redraw: [bootloader_overview]), bootloader_overview ), lower_right: VBox( From 2fac6f2abe1a5791df3bd8482bce209523675c6c Mon Sep 17 00:00:00 2001 From: Michal Filka Date: Mon, 13 Feb 2017 15:46:32 +0100 Subject: [PATCH 7/9] Changes according code review --- src/lib/installation/clients/inst_casp_overview.rb | 9 +++++---- src/lib/installation/widgets/overview.rb | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/lib/installation/clients/inst_casp_overview.rb b/src/lib/installation/clients/inst_casp_overview.rb index 80e90b603..4fdad3d57 100644 --- a/src/lib/installation/clients/inst_casp_overview.rb +++ b/src/lib/installation/clients/inst_casp_overview.rb @@ -76,8 +76,9 @@ def run back_button: "" ) - # TODO: check exception type - raise ArgumentError, "Unexpected return value" if ret != :next + # Currently no other return value is expected, behavior can + # be unpredictable if something else is received + raise RuntimeError, "Unexpected return value" if ret != :next # do software proposal d = Yast::WFM.CallFunction("software_proposal", @@ -147,7 +148,7 @@ 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", on_redraw: [kdump_overview]) + bootloader_overview = Installation::Widgets::Overview.new(client: "bootloader_proposal", redraw: [kdump_overview]) quadrant_layout( upper_left: VBox( @@ -162,7 +163,7 @@ def content Tune::Widgets::SystemInformation.new ), upper_right: VBox( - Installation::Widgets::Overview.new(client: "partitions_proposal", on_redraw: [bootloader_overview]), + Installation::Widgets::Overview.new(client: "partitions_proposal", redraw: [bootloader_overview]), bootloader_overview ), lower_right: VBox( diff --git a/src/lib/installation/widgets/overview.rb b/src/lib/installation/widgets/overview.rb index 6e6cf9ea9..2a69817b5 100644 --- a/src/lib/installation/widgets/overview.rb +++ b/src/lib/installation/widgets/overview.rb @@ -37,14 +37,14 @@ class Overview < CWM::CustomWidget # 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:, on_redraw: []) + 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 = on_redraw + @overviews_for_redraw = redraw end def contents From 4f37baf7124a2249b2254bc4c9557946018d5c65 Mon Sep 17 00:00:00 2001 From: Michal Filka Date: Mon, 13 Feb 2017 15:51:28 +0100 Subject: [PATCH 8/9] Updated changelog --- package/yast2-installation.changes | 9 +++++++++ package/yast2-installation.spec | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/package/yast2-installation.changes b/package/yast2-installation.changes index b9ca7668d..36c2a95a4 100644 --- a/package/yast2-installation.changes +++ b/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 diff --git a/package/yast2-installation.spec b/package/yast2-installation.spec index 91a98972e..cb67c4e39 100644 --- a/package/yast2-installation.spec +++ b/package/yast2-installation.spec @@ -17,7 +17,7 @@ Name: yast2-installation -Version: 3.1.217.22 +Version: 3.1.217.23 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build From 2577ba7153f941350ec2d66654bb42250b5977e2 Mon Sep 17 00:00:00 2001 From: Michal Filka Date: Mon, 13 Feb 2017 17:57:06 +0100 Subject: [PATCH 9/9] Happy rubocop --- src/lib/installation/clients/inst_casp_overview.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/installation/clients/inst_casp_overview.rb b/src/lib/installation/clients/inst_casp_overview.rb index 4fdad3d57..6b6f1bbcb 100644 --- a/src/lib/installation/clients/inst_casp_overview.rb +++ b/src/lib/installation/clients/inst_casp_overview.rb @@ -77,8 +77,9 @@ def run ) # Currently no other return value is expected, behavior can - # be unpredictable if something else is received - raise RuntimeError, "Unexpected return value" if ret != :next + # 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",