Skip to content

Commit

Permalink
move the code to Addon#available?
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Jun 23, 2014
1 parent a4d24a8 commit c3640f5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
13 changes: 10 additions & 3 deletions src/lib/registration/addon.rb
Expand Up @@ -65,7 +65,6 @@ def create_addon_with_deps(root)
# delegate methods to underlaying suse connect object
def_delegators :@pure_addon,
:arch,
:available,
:description,
:eula_url,
:free,
Expand Down Expand Up @@ -112,8 +111,7 @@ def selectable?
# Do not support unregister
return false if registered?
# Do not select not available addons
# (explicitly check for false, it's reported only by SMT)
return false if available == false
return false if !available?
# Do not allow to select child without selected or already registered parent
return false if depends_on && !(depends_on.selected? || depends_on.registered?)
# Do not allow to unselect parent if any children is selected
Expand All @@ -122,5 +120,14 @@ def selectable?
return true
end

# is the addon available? SMT may have mirrored only some extensions,
# the not mirrored extensions are marked as not available
# @return [Boolean] true if the addon is available to register
def available?
# explicitly check for false, undefined (nil) means it is available,
# it's only reported by SMT
@pure_addon.available != false
end

end
end
3 changes: 1 addition & 2 deletions src/lib/registration/ui/addon_selection_dialog.rb
Expand Up @@ -120,8 +120,7 @@ def addon_checkbox(addon, extra_spacing)
def addon_checkbox_element(addon)
# checkbox label for an unavailable extension
# (%s is an extension name)
label = (addon.available == false) ? (_("%s (not available)") % addon.label) :
label.addon
label = addon.available? ? addon.label : (_("%s (not available)") % addon.label)

CheckBox(Id(addon.identifier),
Opt(:notify),
Expand Down

0 comments on commit c3640f5

Please sign in to comment.