Class: Installation::AutoinstIssues::IssuesPresenter
- Inherits:
-
Object
- Object
- Installation::AutoinstIssues::IssuesPresenter
- Includes:
- Yast::I18n
- Defined in:
- library/general/src/lib/installation/autoinst_issues/issues_presenter.rb
Overview
This class converts a list of issues into a message to be shown to users
The message will summarize the list of issues, separating them into non-fatal and fatal issues.
Instance Attribute Summary collapse
-
#issues_list ⇒ Installation::AutoinstIssues::List
readonly
List of issues.
Instance Method Summary collapse
-
#error_text(issues) ⇒ String
Return error message with a list of issues.
-
#initialize(issues_list) ⇒ IssuesPresenter
constructor
Constructor.
-
#issues_by_section(issues) ⇒ Hash<(#parent,#section_name),Installation::AutoinstIssues::Issue>
Return issues grouped by section where they were found.
-
#issues_list_content(issues) ⇒ String
Return an HTML representation for a list of issues.
-
#to_html ⇒ String
Return the text to be shown to the user regarding the list of issues.
-
#to_plain ⇒ String
Return the text to be shown to the user regarding the list of issues.
-
#warning_text(issues) ⇒ String
Return warning message with a list of issues.
Constructor Details
#initialize(issues_list) ⇒ IssuesPresenter
Constructor
38 39 40 41 |
# File 'library/general/src/lib/installation/autoinst_issues/issues_presenter.rb', line 38 def initialize(issues_list) textdomain "base" @issues_list = issues_list end |
Instance Attribute Details
#issues_list ⇒ Installation::AutoinstIssues::List (readonly)
Returns List of issues.
33 34 35 |
# File 'library/general/src/lib/installation/autoinst_issues/issues_presenter.rb', line 33 def issues_list @issues_list end |
Instance Method Details
#error_text(issues) ⇒ String
Return error message with a list of issues
85 86 87 88 89 |
# File 'library/general/src/lib/installation/autoinst_issues/issues_presenter.rb', line 85 def error_text(issues) Yast::HTML.Para( _("Important issues were detected:") ) + issues_list_content(issues) end |
#issues_by_section(issues) ⇒ Hash<(#parent,#section_name),Installation::AutoinstIssues::Issue>
Return issues grouped by section where they were found
120 121 122 123 124 125 126 |
# File 'library/general/src/lib/installation/autoinst_issues/issues_presenter.rb', line 120 def issues_by_section(issues) issues.each_with_object({}) do |issue, all| section = issue.section || :nosection all[section] ||= [] all[section] << issue end end |
#issues_list_content(issues) ⇒ String
Return an HTML representation for a list of issues
The issues are grouped by the section of the profile where they were detected. General issues (with no section) are listed first.
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'library/general/src/lib/installation/autoinst_issues/issues_presenter.rb', line 99 def issues_list_content(issues) all_issues = [] issues_map = issues_by_section(issues) if issues_map[:nosection] all_issues += issues_map[:nosection].map(&:message) issues_map.delete(:nosection) end issues_map.each do |section, items| = Yast::HTML.List(items.map(&:message)) all_issues << "#{section.section_path}:#{}" end Yast::HTML.List(all_issues) end |
#to_html ⇒ String
Return the text to be shown to the user regarding the list of issues
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'library/general/src/lib/installation/autoinst_issues/issues_presenter.rb', line 53 def to_html fatal, non_fatal = issues_list.partition(&:fatal?) parts = [] parts << error_text(fatal) unless fatal.empty? parts << warning_text(non_fatal) unless non_fatal.empty? parts << Yast::HTML.Newline parts << if fatal.empty? _("Do you want to continue?") else _("Please, correct these problems and try again.") end parts.join end |