Skip to content

Commit

Permalink
Fix product's validation on welcome screen
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Sep 1, 2017
1 parent 511b959 commit aed9110
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/lib/installation/clients/inst_complex_welcome.rb
Expand Up @@ -84,6 +84,10 @@ def handle_ret(ret)

when :next
return nil unless Language.CheckIncompleteTranslation(@language)
if selected_product.nil?
Yast::Popup.Error(_("Please select a product to install."))
return nil
end
setup_final_choice
merge_and_run_workflow if selected_product
:next
Expand Down
3 changes: 1 addition & 2 deletions src/lib/installation/dialogs/complex_welcome.rb
Expand Up @@ -77,7 +77,7 @@ def contents
#
# @return [::Installation::Widgets::ProductSelector]
def product_selector
::Installation::Widgets::ProductSelector.new(products)
::Installation::Widgets::ProductSelector.new(products, skip_validation: true)
end

# Product license widget
Expand All @@ -100,7 +100,6 @@ def show_license?
def filling
(show_license? || Yast::UI.TextMode) ? Empty() : VWeight(1, VStretch())
end

end
end
end
13 changes: 11 additions & 2 deletions src/lib/installation/widgets/product_selector.rb
Expand Up @@ -13,9 +13,11 @@ class ProductSelector < CWM::RadioButtons
attr_reader :product

# @param products [Array<Installation::Product>] to display
def initialize(products)
# @param skip_validation [Boolean] Skip value validation
def initialize(products, skip_validation: false)
@products = products
@items = products.map { |p| [p.name, p.label] }
@skip_validation = skip_validation
textdomain "installation"
end

Expand Down Expand Up @@ -49,11 +51,18 @@ def store
end

def validate
return true if value
return true if value || skip_validation?

Yast::Popup.Error(_("Please select a product to install."))
false
end

# Determine whether the validation should be skipped
#
# @see #initialize
def skip_validation?
@skip_validation
end
end
end
end
2 changes: 1 addition & 1 deletion test/dialogs/complex_welcome_test.rb
Expand Up @@ -49,7 +49,7 @@

it "shows the product selector" do
expect(Installation::Widgets::ProductSelector).to receive(:new)
.with(products)
.with(products, skip_validation: true)
expect(widget.contents.to_s).to include("selector_widget")
end
end
Expand Down

0 comments on commit aed9110

Please sign in to comment.