Skip to content

Commit

Permalink
Merge pull request #10510 from romanblanco/toolbar_buttons_basic
Browse files Browse the repository at this point in the history
Documentation for toolbar buttons Basic class
  • Loading branch information
mzazrivec committed Aug 18, 2016
2 parents 57c8625 + 27a0fc4 commit e112ce7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
8 changes: 1 addition & 7 deletions app/assets/javascripts/miq_application.js
Original file line number Diff line number Diff line change
Expand Up @@ -1482,13 +1482,7 @@ function miqToolbarOnClick(_e) {
}
}

var collect_log_buttons = [
'server_collect_logs_choice__collect_logs',
'server_collect_logs_choice__collect_current_logs',
'zone_collect_logs_choice__zone_collect_logs',
'zone_collect_logs_choice__zone_collect_current_logs'
];
if (jQuery.inArray(button.attr('name'), collect_log_buttons) >= 0 && button.data('prompt')) {
if (button.data('prompt')) {
tb_url = miqSupportCasePrompt(tb_url);
if (!tb_url) {
return false;
Expand Down
12 changes: 12 additions & 0 deletions app/helpers/application_helper/button/basic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ def localized(key)
end
end

# Sets the attributes for the button:
# self[:enabled] -- displayed button is enabled
# self[:title] -- button has the title on hover
# self[:prompt] -- the user has to confirm the action
# self[:hidden] -- the button is not displayed in the toolbar
# self[:text] -- text for the button
def calculate_properties
self[:enabled] = !disabled? if self[:enabled].nil?
end
Expand All @@ -32,10 +38,14 @@ def skipped?
skip?
end

# Tells whether the button should displayed in the toolbar or not:
# false => button will be displayed
# true => button will be hidden
def skip?
false
end

# Tells whether the displayed button should be disabled or not
def disabled?
false
end
Expand All @@ -44,6 +54,8 @@ def disabled?
class << self
attr_reader :record_needed

# Used to avoid rendering buttons dependent on `@record` instance variable
# if the variable is not set
def needs_record
@record_needed = true
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def initialize(view_context, view_binding, instance_data, props)
def skip?
begin
return !@record.send("supports_#{@feature}?")
rescue NoMethodError
rescue NoMethodError # TODO: remove with deleting AvailabilityMixin module
return !@record.is_available?(@feature)
end
end
Expand Down

0 comments on commit e112ce7

Please sign in to comment.