diff --git a/src/lib/installation/proposal_errors.rb b/src/lib/installation/proposal_errors.rb new file mode 100644 index 000000000..617717618 --- /dev/null +++ b/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 diff --git a/src/lib/installation/proposal_runner.rb b/src/lib/installation/proposal_runner.rb index c3b2e48a0..d10589ec9 100644 --- a/src/lib/installation/proposal_runner.rb +++ b/src/lib/installation/proposal_runner.rb @@ -22,6 +22,7 @@ require "yast" require "installation/proposal_store" +require "installation/proposal_errors" module Installation # Create and display reasonable proposal for basic @@ -66,6 +67,7 @@ def initialize(store = ::Installation::ProposalStore) # BNC #463567 @submods_already_called = [] @store_class = store + @errors = ProposalErrors.new end def run @@ -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 @@ -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, @@ -469,6 +474,7 @@ 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 @@ -476,6 +482,7 @@ def format_sub_proposal(prop) 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 diff --git a/test/proposal_errors_test.rb b/test/proposal_errors_test.rb new file mode 100644 index 000000000..b5dc3bb86 --- /dev/null +++ b/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