diff --git a/CHANGELOG.md b/CHANGELOG.md index 47b35483ca..7647a4c420 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ ## 24.1.0 +* Fix auditing screens ([PR #1927](https://github.com/alphagov/govuk_publishing_components/pull/1927)) * Update `data-module` on layout header and footer ([PR #1913](https://github.com/alphagov/govuk_publishing_components/pull/1913)) * Update design of accordion component ([PR #1884](https://github.com/alphagov/govuk_publishing_components/pull/1884)) diff --git a/app/views/govuk_publishing_components/audit/show.html.erb b/app/views/govuk_publishing_components/audit/show.html.erb index acc8ef74a8..f4f7cb7d13 100644 --- a/app/views/govuk_publishing_components/audit/show.html.erb +++ b/app/views/govuk_publishing_components/audit/show.html.erb @@ -39,98 +39,105 @@ -
- <% @applications.each_with_index do |application, index| %> -
-
-

- - <%= application[:name] %> - -

-
- <% if application[:application_found] %> - Warnings: - <% if application[:warning_count] > 0 %> - <%= application[:warning_count] %> - <% else %> - <%= application[:warning_count] %> - <% end %> - <% else %> - Application not found - <% end %> -
-
-
- <% if application[:application_found] %> - <% application[:warnings].each do |warning| %> -

- Warn - <%= warning[:component] %> - <%= warning[:message] %> -

- <% end %> + <% #application_items = [] %> + <% application_items = @applications.map do |application| %> + <% + summary = 'Application not found' - <%= render "govuk_publishing_components/components/heading", { - text: "Components used", - font_size: "m", - margin_bottom: 4, - heading_level: 3, - } %> + if application[:application_found] + summary = "Warnings: 0" + if application[:warning_count] > 0 + summary = "Warnings: #{application[:warning_count]}" + end + end + %> -
- <% application[:summary].each do |item| %> -
-
- <%= item[:name] %> -
-
- <% if item[:value].length > 0 %> - <%= item[:value] %> - <% else %> - None - <% end %> -
-
- <% end %> -
+ <% accordion_content = capture do %> + <% if application[:application_found] %> + <% application[:warnings].each do |warning| %> +

+ Warn + <%= warning[:component] %> - <%= warning[:message] %> +

+ <% end %> - <% if application[:gem_style_references].any? %> - <%= render "govuk_publishing_components/components/heading", { - text: "Component references", - font_size: "m", - margin_bottom: 4, - heading_level: 3, - } %> + <%= render "govuk_publishing_components/components/heading", { + text: "Components used", + font_size: "m", + margin_bottom: 4, + heading_level: 3, + } %> -

This shows instances of `gem-c-` classes found in the application. If a reference is found in a stylesheet or in code a warning is created, as this could be a style override or hard coded component markup.

-
    - <% application[:gem_style_references].each do |ref| %> -
  • <%= ref %>
  • +
    + <% application[:summary].each do |item| %> +
    +
    + <%= item[:name] %> +
    +
    + <% if item[:value].length > 0 %> + <%= item[:value] %> + <% else %> + None <% end %> -
+ +
+ <% end %> + + + <% if application[:gem_style_references].any? %> + <%= render "govuk_publishing_components/components/heading", { + text: "Component references", + font_size: "m", + margin_bottom: 4, + heading_level: 3, + } %> + +

This shows instances of `gem-c-` classes found in the application. If a reference is found in a stylesheet or in code a warning is created, as this could be a style override or hard coded component markup.

+ + <% end %> - <% if application[:jquery_references].any? %> - <%= render "govuk_publishing_components/components/heading", { - text: "jQuery references", - font_size: "m", - margin_bottom: 4, - heading_level: 3, - } %> -

This shows JavaScript files that might contain jQuery, which we are trying to remove our dependency on.

- + <% if application[:jquery_references].any? %> + <%= render "govuk_publishing_components/components/heading", { + text: "jQuery references", + font_size: "m", + margin_bottom: 4, + heading_level: 3, + } %> +

This shows JavaScript files that might contain jQuery, which we are trying to remove our dependency on.

+
-
+ + <% end %> + <% else %> +

This application was not found. This could be because you do not have this repository checked out locally.

+ <% end %> <% end %> - + + <% + { + heading: { + text: application[:name] + }, + summary: { + text: sanitize(summary) + }, + content: { + html: sanitize(accordion_content) + }, + } + %> + <% end %> + + <%= render "govuk_publishing_components/components/accordion", { + items: application_items + } %> <% else %>

No applications found.

<% end %> @@ -144,125 +151,130 @@ } %> <% if @components.any? %> -
-
-
-

- - Component files - -

-
- Lists what files each component has -
-
-
- - - - - - - - - - - - - <% @components[:component_listing].each do |component| %> - - - - - - - - - <% end %> - -
ComponentStylesheetPrint stylesheetJSTestJS test
- <%= component[:name] %> - - <% if component[:stylesheet] %> - Yes - <% end %> - - <% if component[:print_stylesheet] %> - Yes - <% end %> - - <% if component[:javascript] %> - Yes - <% end %> - - <% if component[:tests] %> - Yes - <% end %> - - <% if component[:js_tests] %> - Yes - <% end %> -
-
-
+ <% component_files = capture do %> + + + + + + + + + + + + + <% @components[:component_listing].each do |component| %> + + + + + + + + + <% end %> + +
ComponentStylesheetPrint stylesheetJSTestJS test
+ <%= component[:name] %> + + <% if component[:stylesheet] %> + Yes + <% end %> + + <% if component[:print_stylesheet] %> + Yes + <% end %> + + <% if component[:javascript] %> + Yes + <% end %> + + <% if component[:tests] %> + Yes + <% end %> + + <% if component[:js_tests] %> + Yes + <% end %> +
+ <% end %> -
-
-

- - Components containing components - -

-
- Shows which components contain other components -
-
-
-
- <% @components[:components_containing_components].each do |component| %> -
-
- <%= component[:component] %> -
-
- <%= component[:sub_components].join(', ') %> -
-
- <% end %> -
-
-
-
-
-

- - Components by application - -

-
- Shows which applications use each component + <% components_within_components = capture do %> +
+ <% @components[:components_containing_components].each do |component| %> +
+
+ <%= component[:component] %> +
+
+ <%= component[:sub_components].join(', ') %> +
-
-
- <% if @components[:components_by_application].any? %> -
- <% @components[:components_by_application].each do |component| %> -
-
- <%= component[:component] %> (<%= component[:count] %>) -
-
- <%= component[:list] %> -
-
- <% end %> -
- <% else %> -

Sorry, no applications found.

+ <% end %> + + <% end %> + + <% components_by_application = capture do %> + <% if @components[:components_by_application].any? %> +
+ <% @components[:components_by_application].each do |component| %> +
+
+ <%= component[:component] %> (<%= component[:count] %>) +
+
+ <%= component[:list] %> +
+
<% end %> -
-
-
+ + <% else %> +

Sorry, no applications found.

+ <% end %> + <% end %> + + <% + component_items = [ + { + heading: { + text: "Component files", + }, + summary: { + text: "Lists what files each component has", + }, + content: { + html: component_files + }, + }, + { + heading: { + text: "Components containing other components", + }, + summary: { + text: "Shows which components contain other components", + }, + content: { + html: components_within_components + }, + }, + { + heading: { + text: "Components by application", + }, + summary: { + text: "Shows which applications use each component", + }, + content: { + html: components_by_application + }, + }, + ] + %> + + <%= render "govuk_publishing_components/components/accordion", { + items: component_items + } %> <% else %>

No components found.

<% end %>