-
Notifications
You must be signed in to change notification settings - Fork 166
Add StatusPageComponent for standard status page layout #6140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <%= image_tag(icon_src, width: 54, height: 54, alt: icon_alt, class: 'display-block margin-bottom-4') %> | ||
|
|
||
| <%= header %> | ||
|
|
||
| <%= content %> | ||
|
|
||
| <% if action_buttons? %> | ||
| <div class="margin-top-4"> | ||
| <% action_buttons.each do |action| %> | ||
| <div class="margin-top-2"> | ||
| <%= action %> | ||
| </div> | ||
| <% end %> | ||
| </div> | ||
| <% end %> | ||
|
|
||
| <% if troubleshooting_options? %> | ||
| <div class="margin-top-5"> | ||
| <%= troubleshooting_options %> | ||
| </div> | ||
| <% end %> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| class StatusPageComponent < BaseComponent | ||
| ICONS = { | ||
| warning: [], | ||
| error: [:lock], | ||
| }.freeze | ||
|
|
||
| renders_one :header, ::PageHeadingComponent | ||
| renders_many :action_buttons, ->(**button_options) do | ||
| ButtonComponent.new(**button_options, big: true, wide: true) | ||
| end | ||
| renders_one :troubleshooting_options | ||
|
|
||
| attr_reader :status, :icon | ||
|
|
||
| def initialize(status: :error, icon: nil) | ||
| if !ICONS.key?(status) | ||
| raise ArgumentError, "`status` #{status} is invalid, expected one of #{ICONS.keys}" | ||
| end | ||
|
|
||
| if icon && !ICONS[status].include?(icon) | ||
| raise ArgumentError, "`icon` #{icon} is invalid, expected one of #{ICONS[status]}" | ||
| end | ||
|
|
||
| @icon = icon | ||
| @status = status | ||
| end | ||
|
|
||
| def icon_src | ||
| image_path("status/#{[status, icon].compact.join('-')}") | ||
| end | ||
|
|
||
| def icon_alt | ||
| # i18n-tasks-use t('components.status_page.icons.error') | ||
| # i18n-tasks-use t('components.status_page.icons.warning') | ||
| # i18n-tasks-use t('components.status_page.icons.lock') | ||
| t(icon || status, scope: [:components, :status_page, :icons]) | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,32 +1,13 @@ | ||
| class CancellationPresenter < FailurePresenter | ||
|
||
| include ActionView::Helpers::TranslationHelper | ||
| class CancellationPresenter | ||
| include Rails.application.routes.url_helpers | ||
|
|
||
| attr_reader :referer | ||
|
|
||
| def initialize(referer:, url_options:) | ||
| super(:warning) | ||
| @referer = referer | ||
| @url_options = url_options | ||
| end | ||
|
|
||
| def title | ||
| t('headings.cancellations.prompt') | ||
| end | ||
|
|
||
| def header | ||
| t('headings.cancellations.prompt') | ||
| end | ||
|
|
||
| def cancellation_warnings | ||
| [ | ||
| t('users.delete.bullet_1', app_name: APP_NAME), | ||
| t('users.delete.bullet_2_loa1'), | ||
| t('users.delete.bullet_3', app_name: APP_NAME), | ||
| t('users.delete.bullet_4', app_name: APP_NAME), | ||
| ] | ||
| end | ||
|
|
||
| def go_back_path | ||
| referer_path || two_factor_options_path | ||
| end | ||
|
|
||
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,21 +1,29 @@ | ||||||||||
| <%= render 'shared/failure', presenter: @presenter %> | ||||||||||
| <% title t('headings.cancellations.prompt') %> | ||||||||||
|
|
||||||||||
| <p class='margin-bottom-1 text-bold'> | ||||||||||
| <%= t('sign_up.cancel.warning_header') %> | ||||||||||
| </p> | ||||||||||
| <%= render StatusPageComponent.new(status: :warning) do |c| %> | ||||||||||
| <% c.header { t('headings.cancellations.prompt') } %> | ||||||||||
|
|
||||||||||
| <ul class='usa-list--unstyled <%= @presenter.state_color %>-dots'> | ||||||||||
| <% @presenter.cancellation_warnings.each do |warning| %> | ||||||||||
| <li><%= warning %></li> | ||||||||||
| <% end %> | ||||||||||
| </ul> | ||||||||||
| <p> | ||||||||||
| <strong><%= t('sign_up.cancel.warning_header') %></strong> | ||||||||||
| </p> | ||||||||||
|
|
||||||||||
| <div class='margin-top-4'> | ||||||||||
| <%= button_to t('forms.buttons.cancel'), destroy_user_path, | ||||||||||
| method: :delete, class: 'usa-button usa-button--big usa-button--wide' %> | ||||||||||
| </div> | ||||||||||
| <ul class="usa-list"> | ||||||||||
| <li><%= t('users.delete.bullet_1', app_name: APP_NAME) %></li> | ||||||||||
| <li><%= t('users.delete.bullet_2_loa1') %></li> | ||||||||||
| <li><%= t('users.delete.bullet_3', app_name: APP_NAME) %></li> | ||||||||||
| <li><%= t('users.delete.bullet_4', app_name: APP_NAME) %></li> | ||||||||||
| </ul> | ||||||||||
|
||||||||||
| <li class="margin-bottom-1"><%= t('users.delete.bullet_1', app_name: APP_NAME) %></li> | |
| <li class="margin-bottom-1"><%= current_user.decorate.delete_account_bullet_key %></li> | |
| <li class="margin-bottom-1"><%= t('users.delete.bullet_3', app_name: APP_NAME) %></li> | |
| <li class="margin-bottom-1"><%= t('users.delete.bullet_4', app_name: APP_NAME) %></li> |
I'm not sure how best to handle that, or if it's worth the trouble to refactor it. I'll probably leave it out of this pull request though.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Future work should adapt
app/views/shared/_troubleshooting_options.html.erbinto a component, so this could be implemented as a pass-through similar toPageHeadingComponentandButtonComponentabove.