Skip to content

Commit

Permalink
disable unavailable extensions (bnc#883148)
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Jun 23, 2014
1 parent 4fe81a5 commit 0459463
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/lib/registration/addon.rb
Expand Up @@ -65,6 +65,7 @@ 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 @@ -110,6 +111,9 @@ def label
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 addon.available == false
# 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 Down
7 changes: 6 additions & 1 deletion src/lib/registration/ui/addon_selection_dialog.rb
Expand Up @@ -118,9 +118,14 @@ def addon_checkbox(addon, extra_spacing)
end

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

CheckBox(Id(addon.identifier),
Opt(:notify),
addon.label,
label,
addon.selected? || addon.registered?)
end

Expand Down
6 changes: 6 additions & 0 deletions test/addon_spec.rb
Expand Up @@ -151,6 +151,12 @@
child.selected
expect(parent.selectable?).to be_false
end

it "returns false when the addon is not available" do
addon.available = true
expect(addon.selectable?).to be_false
end

end

end

0 comments on commit 0459463

Please sign in to comment.