Skip to content

Commit

Permalink
Merge pull request #1142 from yast/fix_focus
Browse files Browse the repository at this point in the history
Fix focus
  • Loading branch information
jreidinger committed Mar 4, 2021
2 parents cb78ba6 + 2b6eb2a commit 4c985bb
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion library/control/src/modules/ProductProfile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def CheckCompliance(product_id)
),
continue_button,
cancel_button,
:no_button
:focus_no
)
if !ret && !product_id.nil?
# canceled adding add-on: remove profile stored before
Expand Down
9 changes: 8 additions & 1 deletion library/general/src/modules/Report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -352,16 +352,23 @@ def NumErrors
Builtins.size(@errors)
end

BACKWARD_MAPPING = {
focus_yes: :yes,
focus_no: :no
}.freeze

# Question with headline and Yes/No Buttons
# @param [String] headline Popup Headline
# @param [String] message Popup Message
# @param [String] yes_button_message Yes Button Message
# @param [String] no_button_message No Button Message
# @param [Symbol] focus Which Button has the focus
# @param [Symbol] focus Which Button has the focus. Possible values are `:yes` and :no`.
# For backward compatibility also `:focus_yes` and `:focus_no` is accepted.
# @return [Boolean] True if Yes is pressed, otherwise false
def AnyQuestion(headline, message, yes_button_message, no_button_message, focus)
Builtins.y2milestone(1, "%1", message) if @log_yesno_messages

focus = BACKWARD_MAPPING[focus] || focus
ret = false
if @display_yesno_messages
timeout = (@timeout_yesno_messages.to_s.to_i > 0) ? @timeout_yesno_messages : 0
Expand Down
10 changes: 10 additions & 0 deletions library/general/test/report_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -367,5 +367,15 @@
end
end
end

describe ".AnyQuestion" do
it "accepts also :focus_yes/:focus_no as focus parameter" do
subject.DisplayYesNoMessages(true, 0)
expect(Yast2::Popup).to receive(:show)
.with("Message", headline: "test", buttons: { yes: "yes", no: "no" }, focus: :no, timeout: 0)

subject.AnyQuestion("test", "Message", "yes", "no", :focus_no)
end
end
end
end
7 changes: 7 additions & 0 deletions package/yast2.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Thu Mar 4 12:41:56 UTC 2021 - Josef Reidinger <jreidinger@suse.com>

- Fix backward compatibility for focus parameter of
Report.AnyQuestion/Report.ErrorAnyQuestion (bsc#1183011)
- 4.3.56

-------------------------------------------------------------------
Fri Feb 12 13:46:19 UTC 2021 - Ancor Gonzalez Sosa <ancor@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2
Version: 4.3.55
Version: 4.3.56
Release: 0
Summary: YaST2 Main Package
License: GPL-2.0-only
Expand Down

0 comments on commit 4c985bb

Please sign in to comment.