Class: ForemanTasks::TroubleshootingHelpGenerator
- Inherits:
 - 
      Object
      
        
- Object
 - ForemanTasks::TroubleshootingHelpGenerator
 
 
- Defined in:
 - app/services/foreman_tasks/troubleshooting_help_generator.rb
 
Defined Under Namespace
Instance Method Summary collapse
- #description ⇒ Object
 - #generate_html ⇒ Object
 - #generic_info ⇒ Object
 - 
  
    
      #initialize(action)  ⇒ TroubleshootingHelpGenerator 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of TroubleshootingHelpGenerator.
 - #link_anchor ⇒ Object
 - #link_descriptions_html ⇒ Object
 - #links ⇒ Object
 - #troubleshooting_link(generic_only: false) ⇒ Object
 
Constructor Details
#initialize(action) ⇒ TroubleshootingHelpGenerator
Returns a new instance of TroubleshootingHelpGenerator.
      36 37 38 39  | 
    
      # File 'app/services/foreman_tasks/troubleshooting_help_generator.rb', line 36 def initialize(action) @action = action @custom_info = action.troubleshooting_info if action.respond_to?(:troubleshooting_info) end  | 
  
Instance Method Details
#description ⇒ Object
      53 54 55 56 57  | 
    
      # File 'app/services/foreman_tasks/troubleshooting_help_generator.rb', line 53 def description ret = generic_info.description_lines ret += @custom_info.description_lines if @custom_info ret end  | 
  
#generate_html ⇒ Object
      41 42 43 44 45  | 
    
      # File 'app/services/foreman_tasks/troubleshooting_help_generator.rb', line 41 def generate_html # rubocop:disable Rails/OutputSafety (description + link_descriptions_html).join('<br/>').html_safe # rubocop:enable Rails/OutputSafety end  | 
  
#generic_info ⇒ Object
      65 66 67 68 69 70 71 72 73 74 75 76  | 
    
      # File 'app/services/foreman_tasks/troubleshooting_help_generator.rb', line 65 def generic_info @generic_info ||= Info.new.tap do |i| i.add_line _('A paused task represents a process that has not finished properly. '\ 'Any task in paused state can lead to potential inconsistency '\ 'and needs to be resolved.') i.add_line _("The recommended approach is to investigate the error messages below and in 'errors' tab, "\ 'address the primary cause of the issue and resume the task.') if (link = troubleshooting_link) i.add_link(link) end end end  | 
  
#link_anchor ⇒ Object
      88 89 90  | 
    
      # File 'app/services/foreman_tasks/troubleshooting_help_generator.rb', line 88 def link_anchor @action.label.to_s end  | 
  
#link_descriptions_html ⇒ Object
      47 48 49 50 51  | 
    
      # File 'app/services/foreman_tasks/troubleshooting_help_generator.rb', line 47 def link_descriptions_html links.map do |link| link.description % { link: %(<a href="%{href}">%{title}</a>) % link.to_h } end end  | 
  
#links ⇒ Object
      59 60 61 62 63  | 
    
      # File 'app/services/foreman_tasks/troubleshooting_help_generator.rb', line 59 def links links = generic_info.links links += @custom_info.links if @custom_info links end  | 
  
#troubleshooting_link(generic_only: false) ⇒ Object
      78 79 80 81 82 83 84 85 86  | 
    
      # File 'app/services/foreman_tasks/troubleshooting_help_generator.rb', line 78 def troubleshooting_link(generic_only: false) url_template = Setting[:foreman_tasks_troubleshooting_url] return if url_template.blank? url = url_template % { label: generic_only ? '' : link_anchor, version: SETTINGS[:version].short } Link.new(name: :troubleshooting, title: _('troubleshooting documentation'), description: _('See %{link} for more details on how to resolve the issue'), href: url) end  |