Browse Source

Change links

pull/2653/head
Manny Dinssa 2 years ago
parent
commit
f04964a111
  1. 6
      app/components/bulk_upload_summary_component.html.erb
  2. 45
      app/components/bulk_upload_summary_component.rb

6
app/components/bulk_upload_summary_component.html.erb

@ -13,9 +13,9 @@
<p class="govuk-hint govuk-!-font-size-16 govuk-!-margin-bottom-1">Time of upload: <%= bulk_upload.created_at.to_formatted_s(:govuk_date_and_time) %></p> <p class="govuk-hint govuk-!-font-size-16 govuk-!-margin-bottom-1">Time of upload: <%= bulk_upload.created_at.to_formatted_s(:govuk_date_and_time) %></p>
</div> </div>
<p class="govuk-body govuk-!-margin-bottom-3"> <p class="govuk-body govuk-!-margin-bottom-3">
<%= download_file_link(controller, bulk_upload) %> <%= download_file_link(bulk_upload) %>
<%= view_error_report_link(controller, bulk_upload) %> <%= view_error_report_link(bulk_upload) %>
<%= view_logs_link(controller, bulk_upload) %> <%= view_logs_link(bulk_upload) %>
</p> </p>
</div> </div>
<footer class="govuk-grid-column-one-third app-log-summary__footer"> <footer class="govuk-grid-column-one-third app-log-summary__footer">

45
app/components/bulk_upload_summary_component.rb

@ -16,11 +16,11 @@ class BulkUploadSummaryComponent < ViewComponent::Base
end end
def critical_errors_count def critical_errors_count
@bulk_upload_errors.where(category: [nil, ""]).count @bulk_upload_errors.where(category: [nil, "", "not_answered"]).count
end end
def potential_errors_count def potential_errors_count
@bulk_upload_errors.where(category: "soft_validations").count @bulk_upload_errors.where(category: "soft_validation").count
end end
def formatted_count_text(count, singular_text, plural_text = nil) def formatted_count_text(count, singular_text, plural_text = nil)
@ -39,15 +39,8 @@ class BulkUploadSummaryComponent < ViewComponent::Base
}.compact.join("").html_safe }.compact.join("").html_safe
end end
def download_file_link(controller, bulk_upload) def download_file_link(bulk_upload)
case controller.controller_name send("download_#{bulk_upload.log_type}_file_link", bulk_upload)
when "lettings_logs"
download_lettings_file_link(bulk_upload)
when "sales_logs"
download_sales_file_link(bulk_upload)
else
raise "Download file link not found for bulk upload"
end
end end
def download_lettings_file_link(bulk_upload) def download_lettings_file_link(bulk_upload)
@ -58,33 +51,15 @@ class BulkUploadSummaryComponent < ViewComponent::Base
link_to "Download file", download_sales_bulk_upload_path(bulk_upload), class: "govuk-link govuk-!-margin-right-2" link_to "Download file", download_sales_bulk_upload_path(bulk_upload), class: "govuk-link govuk-!-margin-right-2"
end end
def view_error_report_link(controller, bulk_upload) def view_error_report_link(bulk_upload)
return nil if %w[errors_fixed_in_service logs_uploaded_with_errors logs_uploaded_no_errors wrong_template blank_template].include?(bulk_upload.status.to_s) return nil if %w[errors_fixed_in_service logs_uploaded_with_errors logs_uploaded_no_errors wrong_template blank_template].include?(bulk_upload.status.to_s)
return link_to "View error report", send("summary_bulk_upload_#{bulk_upload.log_type}_result_url", bulk_upload), class: "govuk-link" if %w[important_errors].include?(bulk_upload.status.to_s)
case controller.controller_name link_to "View error report", send("bulk_upload_#{bulk_upload.log_type}_result_path", bulk_upload.id), class: "govuk-link"
when "lettings_logs"
return link_to "View error report", summary_bulk_upload_lettings_result_url(bulk_upload), class: "govuk-link" if %w[important_errors].include?(bulk_upload.status.to_s)
link_to "View error report", bulk_upload_lettings_result_path(bulk_upload.id), class: "govuk-link"
when "sales_logs"
return link_to "View error report", summary_bulk_upload_sales_result_url(bulk_upload), class: "govuk-link" if %w[important_errors].include?(bulk_upload.status.to_s)
link_to "View error report", bulk_upload_sales_result_path(bulk_upload.id), class: "govuk-link"
else
raise "Error report link not found for bulk upload"
end
end end
def view_logs_link(controller, bulk_upload) def view_logs_link(bulk_upload)
return nil if %w[errors_fixed_in_service logs_uploaded_no_errors wrong_template blank_template].include?(bulk_upload.status.to_s) return nil if %w[errors_fixed_in_service logs_uploaded_no_errors wrong_template blank_template].include?(bulk_upload.status.to_s)
return nil unless %w[errors_fixed_in_service logs_uploaded_with_errors logs_uploaded_no_errors].include?(bulk_upload.status.to_s)
case controller.controller_name link_to "View logs", send("#{bulk_upload.log_type}_logs_path", bulk_upload_id: [bulk_upload.id]), class: "govuk-link"
when "lettings_logs"
return nil unless %w[errors_fixed_in_service logs_uploaded_with_errors logs_uploaded_no_errors].include?(bulk_upload.status.to_s)
link_to "View logs", "/lettings-logs?bulk_upload_id%5B%5D=#{bulk_upload.id}", class: "govuk-link"
when "sales_logs"
return nil unless %w[errors_fixed_in_service logs_uploaded_with_errors logs_uploaded_no_errors].include?(bulk_upload.status.to_s)
link_to "View logs", "/sales-logs?bulk_upload_id%5B%5D=#{bulk_upload.id}", class: "govuk-link"
else
raise "View logs link not found for bulk upload"
end
end end
end end

Loading…
Cancel
Save