Skip to content

Commit

Permalink
Merge branch 'SLE-12-SP2-CASP' into proposa_error_master
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Nov 14, 2016
2 parents 20b0426 + 0071468 commit 7f8500d
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 1 deletion.
7 changes: 7 additions & 0 deletions package/yast2-installation.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Mon Nov 14 14:30:12 UTC 2016 - jreidinger@suse.com

- The user has to confirm when the configuration proposal contains
a non-blocking error (generic fix for bsc#1003682)
- 3.2.9

-------------------------------------------------------------------
Fri Nov 11 16:41:25 CET 2016 - 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.2.8
Version: 3.2.9
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
51 changes: 51 additions & 0 deletions src/lib/installation/proposal_errors.rb
@@ -0,0 +1,51 @@
require "yast"

Yast.import "UI"
Yast.import "Label"
Yast.import "Mode"
Yast.import "Popup"

module Installation
class ProposalErrors
include Yast::I18n
include Yast::Logger

ERROR_PROPOSAL_TIMEOUT = 60

def initialize
textdomain "installation"
@errors = []
end

# clears previously stored errros
def clear
@errors = []
end

# appends new error with given message
def append(message)
@errors << message
end

# returns true if there is no error or user approved stored errors
def approved?
return true if @errors.empty?

headline = _("Error Found in Installation Settings")
text = _("The following errors were found in the configuration proposal.\n" \
"If you continue with the installation it may not be successful.\n" \
"Errors:\n")
sep = Yast::UI.TextMode ? "-" : "•"
text += "#{sep} " + @errors.join("\n#{sep} ")

if Yast::Mode.auto
!Yast::Popup.TimedErrorAnyQuestion(headline, text,
Yast::Label.BackButton, Yast::Label.ContinueButton, :focus_yes,
ERROR_PROPOSAL_TIMEOUT)
else
!Yast::Popup.ErrorAnyQuestion(headline, text,
Yast::Label.BackButton, Yast::Label.ContinueButton, :focus_yes)
end
end
end
end
7 changes: 7 additions & 0 deletions src/lib/installation/proposal_runner.rb
Expand Up @@ -22,6 +22,7 @@
require "yast"

require "installation/proposal_store"
require "installation/proposal_errors"

module Installation
# Create and display reasonable proposal for basic
Expand Down Expand Up @@ -66,6 +67,7 @@ def initialize(store = ::Installation::ProposalStore)
# BNC #463567
@submods_already_called = []
@store_class = store
@errors = ProposalErrors.new
end

def run
Expand Down Expand Up @@ -278,6 +280,8 @@ def pre_continue_handling
return nil
end

return nil unless @errors.approved?

if Yast::Stage.stage == "initial"
input = Yast::WFM.CallFunction("inst_doit", [])
# bugzilla #219097, #221571, yast2-update on running system
Expand Down Expand Up @@ -441,6 +445,7 @@ def make_proposal(force_reset, language_changed)
end
end

@errors.clear
@store.make_proposals(
force_reset: force_reset,
language_changed: language_changed,
Expand Down Expand Up @@ -469,13 +474,15 @@ def format_sub_proposal(prop)

if !warning.empty?
level = prop["warning_level"] || :warning
log.info "proposal returns warning with level #{level} and msg #{warning}"

case level
when :notice
warning = Yast::HTML.Bold(warning)
when :warning
warning = Yast::HTML.Colorize(warning, "red")
when :error
@errors.append(warning)
warning = Yast::HTML.Colorize(warning, "red")
when :blocker, :fatal
@have_blocker = true
Expand Down
33 changes: 33 additions & 0 deletions test/proposal_errors_test.rb
@@ -0,0 +1,33 @@
#! /usr/bin/env rspec

require_relative "./test_helper"

require "installation/proposal_errors"

describe ::Installation::ProposalErrors do
describe "#approved?" do
it "returns true if there is no error stored" do
expect(Yast::Popup).to_not receive(:ErrorAnyQuestion)
expect(subject.approved?).to eq true
end

it "asks user to approve errors and returns true if approved" do
subject.append("test")

expect(Yast::Popup).to receive(:ErrorAnyQuestion).and_return(false)
expect(subject.approved?).to eq true

expect(Yast::Popup).to receive(:ErrorAnyQuestion).and_return(true)
expect(subject.approved?).to eq false
end

it "in autoyast ask with timeout and return true if timeout exceed" do
subject.append("test")
allow(Yast::Mode).to receive(:auto).and_return(true)

# timed error return false when timeout exceed
expect(Yast::Popup).to receive(:TimedErrorAnyQuestion).and_return(false)
expect(subject.approved?).to eq true
end
end
end

0 comments on commit 7f8500d

Please sign in to comment.