18F/identity-idp

View on GitHub
app/views/idv/shared/_error.html.erb

Summary

Maintainability
Test Coverage
<%#
yields: Page instruction content.
locals:
* type: `:warning` or `:error`. Defaults to `:error`.
* heading: Primary page heading text. Also used as page title if title is not given.
* title: Optional custom page title, defaulting to the heading.
* action: Optional hash of `text`, `url`, optional `method` of a primary action link.
* action_secondary: Optional hash of `text`, `url`, optional `method` of a secondary action link.
* current_step: Optionally identify the current step of the IdV flow. If provided, the step indicator will be rendered.
* options: Array of troubleshooting options.
%>
<% if local_assigns.fetch(:type, :error) == :error
     icon_name = :error
     troubleshooting_heading = t('idv.troubleshooting.headings.need_assistance')
else
  icon_name = :warning
  troubleshooting_heading = t('components.troubleshooting_options.default_heading')
end %>

<% self.title = local_assigns.fetch(:title, heading) %>

<% if local_assigns[:current_step] and defined?(step_indicator_steps) %>
  <% content_for(:pre_flash_content) do %>
    <%= render StepIndicatorComponent.new(
          steps: step_indicator_steps,
          current_step: local_assigns[:current_step],
          locale_scope: 'idv',
          class: 'margin-x-neg-2 margin-top-neg-4 tablet:margin-x-neg-6 tablet:margin-top-neg-4',
        ) %>
  <% end %>
<% end %>

<%= render AlertIconComponent.new(icon_name: icon_name, class: 'display-block margin-bottom-4') %>

<%= render PageHeadingComponent.new.with_content(heading) %>

<%= yield %>

<% if local_assigns[:action] %>
  <div class="margin-top-5">
    <%= button_or_link_to(
          action[:text],
          action[:url],
          class: 'usa-button usa-button--big usa-button--wide',
          method: action[:method],
        ) %>
  </div>

  <% if local_assigns[:action_secondary] %>
    <div class="margin-top-2">
      <%= button_or_link_to(
            action_secondary[:text],
            action_secondary[:url],
            class: 'usa-button usa-button--big usa-button--wide usa-button--outline',
            method: action_secondary[:method],
          ) %>
    </div>
  <% end %>
<% end %>

<%= render(
      'shared/troubleshooting_options',
      heading: troubleshooting_heading,
      options: local_assigns.fetch(:options, []),
      class: 'margin-top-5',
    ) %>