Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/components/button_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class ButtonComponent < BaseComponent
:tag_options

def initialize(
action: nil,
url: nil,
method: nil,
icon: nil,
Expand All @@ -25,7 +24,6 @@ def initialize(
danger: false,
**tag_options
)
@action = action
@url = url
@method = method
@icon = icon
Expand Down Expand Up @@ -67,6 +65,8 @@ def content
end
end

private

def action
@action ||= begin
if url
Expand Down
10 changes: 2 additions & 8 deletions app/components/download_button_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,8 @@ class DownloadButtonComponent < ButtonComponent
def initialize(file_data:, file_name:, **tag_options)
super(
icon: :file_download,
action: ->(**tag_options, &block) do
link_to(
"data:text/plain;charset=utf-8,#{ERB::Util.url_encode(file_data)}",
download: file_name,
**tag_options,
&block
)
end,
url: "data:text/plain;charset=utf-8,#{ERB::Util.url_encode(file_data)}",
download: file_name,
**tag_options,
)

Expand Down
2 changes: 1 addition & 1 deletion app/components/manageable_authenticator_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
<div class="manageable-authenticator__name manageable-authenticator__summary-name"><%= configuration.name %></div>
<div class="manageable-authenticator__actions">
<%= render ButtonComponent.new(
action: ->(**tag_options, &block) { link_to(manage_url, **tag_options, &block) },
url: manage_url,
type: :button,
unstyled: true,
class: 'no-js',
Expand Down
2 changes: 1 addition & 1 deletion app/components/tab_navigation_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<% routes.each do |route| %>
<li class="usa-button-group__item">
<%= render ButtonComponent.new(
action: ->(**tag_options, &block) { link_to(route[:path], **tag_options, &block) },
url: route[:path],
big: true,
outline: !is_current_path?(route[:path]),
aria: { current: is_current_path?(route[:path]) ? 'page' : nil },
Expand Down
4 changes: 1 addition & 3 deletions app/views/accounts/_auth_apps.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@

<% if current_user.auth_app_configurations.count < IdentityConfig.store.max_auth_apps_per_account %>
<%= render ButtonComponent.new(
action: ->(**tag_options, &block) do
link_to(authenticator_setup_url, **tag_options, &block)
end,
url: authenticator_setup_url,
icon: :add,
class: 'usa-button usa-button--outline margin-top-2',
).with_content(t('account.index.auth_app_add')) %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/accounts/_emails.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</div>
<% if EmailPolicy.new(current_user).can_add_email? %>
<%= render ButtonComponent.new(
action: ->(**tag_options, &block) { link_to(add_email_path, **tag_options, &block) },
url: add_email_path,
outline: true,
icon: :add,
class: 'margin-top-2',
Expand Down
2 changes: 1 addition & 1 deletion app/views/accounts/_phone.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</div>
<% if current_user.phone_configurations.count < IdentityConfig.store.max_phone_numbers_per_account %>
<%= render ButtonComponent.new(
action: ->(**tag_options, &block) { link_to(phone_setup_path, **tag_options, &block) },
url: phone_setup_path,
outline: true,
icon: :add,
class: 'margin-top-2',
Expand Down
6 changes: 2 additions & 4 deletions app/views/accounts/_piv_cac.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<%= t('headings.account.federal_employee_id') %>
</h2>

<div role="list">
<div role="list">
<% MfaContext.new(current_user).piv_cac_configurations.each do |configuration| %>
<%= render ManageableAuthenticatorComponent.new(
configuration:,
Expand All @@ -21,9 +21,7 @@

<% if current_user.piv_cac_configurations.count < IdentityConfig.store.max_piv_cac_per_account %>
<%= render ButtonComponent.new(
action: ->(**tag_options, &block) do
link_to(setup_piv_cac_url, **tag_options, &block)
end,
url: setup_piv_cac_url,
icon: :add,
outline: true,
class: 'margin-top-2',
Expand Down
4 changes: 1 addition & 3 deletions app/views/accounts/_webauthn_platform.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
</div>

<%= render ButtonComponent.new(
action: ->(**tag_options, &block) do
link_to(webauthn_setup_path(platform: true), **tag_options, &block)
end,
url: webauthn_setup_path(platform: true),
icon: :add,
outline: true,
class: 'margin-top-2',
Expand Down
4 changes: 1 addition & 3 deletions app/views/accounts/_webauthn_roaming.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
</div>

<%= render ButtonComponent.new(
action: ->(**tag_options, &block) do
link_to(webauthn_setup_path, **tag_options, &block)
end,
url: webauthn_setup_path,
icon: :add,
outline: true,
class: 'margin-top-2',
Expand Down
4 changes: 1 addition & 3 deletions app/views/accounts/actions/_generate_backup_codes.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<%= render ButtonComponent.new(
action: ->(**tag_options, &block) do
link_to(backup_code_create_path, **tag_options, &block)
end,
url: backup_code_create_path,
icon: :add,
class: 'usa-button usa-button--outline margin-top-2',
).with_content(t('forms.backup_code.generate')) %>
4 changes: 1 addition & 3 deletions app/views/accounts/actions/_regenerate_backup_codes.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<%= render ButtonComponent.new(
action: ->(**tag_options, &block) do
link_to(backup_code_regenerate_path, **tag_options, &block)
end,
url: backup_code_regenerate_path,
icon: :add,
outline: true,
class: 'margin-top-2',
Expand Down
9 changes: 3 additions & 6 deletions app/views/idv/forgot_password/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@
</ul>

<% c.with_action_button(
action: ->(**tag_options, &block) do
link_to(idv_enter_password_path, **tag_options, &block)
end,
url: idv_enter_password_path,
) { t('idv.forgot_password.try_again') } %>

<% c.with_action_button(
action: ->(**tag_options, &block) do
button_to(idv_forgot_password_path, method: :post, **tag_options, &block)
end,
url: idv_forgot_password_path,
method: :post,
outline: true,
) { t('idv.forgot_password.reset_password') } %>
<% end %>
8 changes: 2 additions & 6 deletions app/views/idv/mail_only_warning/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,13 @@
<% end %>
</ul>
<% c.with_action_button(
action: ->(**tag_options, &block) do
link_to(idv_url, **tag_options, &block)
end,
url: idv_url,
big: true,
wide: true,
class: 'usa-button',
).with_content(t('doc_auth.buttons.continue')) %>
<% c.with_action_button(
action: ->(**tag_options, &block) do
link_to(exit_url, **tag_options, &block)
end,
url: exit_url,
big: true,
wide: true,
outline: true,
Expand Down
5 changes: 2 additions & 3 deletions app/views/idv/otp_verification/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@
<% end %>

<%= render ButtonComponent.new(
action: ->(**tag_options, &block) do
button_to(idv_resend_otp_path, method: :post, **tag_options, &block)
end,
url: idv_resend_otp_path,
method: :post,
outline: true,
icon: :loop,
class: 'margin-bottom-4',
Expand Down
2 changes: 1 addition & 1 deletion app/views/idv/phone_errors/failure.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<% if @gpo_letter_available %>
<div class="margin-y-5">
<%= render ButtonComponent.new(
action: ->(**tag_options, &block) { link_to idv_request_letter_path, **tag_options, &block },
url: idv_request_letter_path,
big: true,
wide: true,
).with_content(t('idv.failure.phone.rate_limited.gpo.button')) %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/idv/phone_errors/warning.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

<div class="margin-y-5">
<%= render ButtonComponent.new(
action: ->(**tag_options, &block) { link_to idv_phone_path, **tag_options, &block },
url: idv_phone_path,
big: true,
wide: true,
).with_content(t('idv.failure.phone.warning.try_again_button')) %>
Expand All @@ -51,7 +51,7 @@

<div class="margin-y-5">
<%= render ButtonComponent.new(
action: ->(**tag_options, &block) { link_to idv_request_letter_path, **tag_options, &block },
url: idv_request_letter_path,
big: true,
wide: true,
outline: true,
Expand Down
2 changes: 1 addition & 1 deletion app/views/idv/session_errors/warning.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<p><%= t('idv.warning.attempts_html', count: @remaining_submit_attempts) %></p>

<% c.with_action_button(
action: ->(**tag_options, &block) { link_to(@try_again_path, **tag_options, &block) },
url: @try_again_path,
class: 'margin-bottom-2',
) { t('idv.forgot_password.try_again') } %>
<% end %>
Expand Down
8 changes: 1 addition & 7 deletions app/views/idv/unavailable/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,7 @@
</p>

<% c.with_action_button(
action: ->(**tag_options, &block) do
link_to(
return_to_sp_failure_to_proof_path(step: :unavailable, location: :unavailable),
**tag_options,
&block
)
end,
url: return_to_sp_failure_to_proof_path(step: :unavailable, location: :unavailable),
big: true,
wide: true,
).with_content(t('idv.unavailable.exit_button', app_name: APP_NAME)) %>
Expand Down
9 changes: 3 additions & 6 deletions app/views/sign_up/cancellations/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@
</ul>

<% c.with_action_button(
action: ->(**tag_options, &block) do
button_to(sign_up_destroy_path, method: :delete, **tag_options, &block)
end,
url: sign_up_destroy_path,
method: :delete,
) { t('forms.buttons.cancel') } %>

<% c.with_action_button(
action: ->(**tag_options, &block) do
link_to(@presenter.go_back_path, **tag_options, &block)
end,
url: @presenter.go_back_path,
outline: true,
) { t('links.go_back') } %>
<% end %>
18 changes: 6 additions & 12 deletions app/views/two_factor_authentication/otp_verification/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,12 @@
<%= hidden_field_tag 'otp_make_default_number',
@presenter.otp_make_default_number %>
<%= render ButtonComponent.new(
action: ->(**tag_options, &block) do
link_to(
otp_send_path(
otp_delivery_selection_form: {
otp_delivery_preference: @presenter.otp_delivery_preference,
resend: true,
},
),
**tag_options,
&block
)
end,
url: otp_send_path(
otp_delivery_selection_form: {
otp_delivery_preference: @presenter.otp_delivery_preference,
resend: true,
},
),
outline: true,
icon: :loop,
class: 'margin-bottom-neg-1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

<div class="margin-y-5">
<%= render SpinnerButtonComponent.new(
action: ->(**tag_options, &block) do
link_to(@presenter.piv_cac_service_link, **tag_options, &block)
end,
url: @presenter.piv_cac_service_link,
big: true,
wide: true,
).with_content(@presenter.piv_cac_capture_text) %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</p>

<%= render ButtonComponent.new(
action: ->(**tag_options, &block) { link_to(authentication_methods_setup_path, **tag_options, &block) },
url: authentication_methods_setup_path,
big: true,
full_width: false,
class: 'margin-top-3 margin-bottom-1',
Expand All @@ -24,5 +24,5 @@
class: 'usa-button usa-button--unstyled',
) do %>
<%= t('forms.buttons.continue') %>
<% end %>
<% end %>
<% end %>
4 changes: 1 addition & 3 deletions app/views/users/piv_cac_login/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
</p>

<%= render SpinnerButtonComponent.new(
action: ->(**tag_options, &block) do
link_to(@presenter.piv_cac_service_link, **tag_options, &block)
end,
url: @presenter.piv_cac_service_link,
big: true,
wide: true,
).with_content(@presenter.piv_cac_capture_text) %>
Expand Down
18 changes: 4 additions & 14 deletions app/views/users/piv_cac_recommended/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,15 @@
</p>

<%= render ButtonComponent.new(
action: ->(**tag_options, &block) do
button_to(
login_piv_cac_recommended_add_path,
**tag_options,
&block
)
end,
url: login_piv_cac_recommended_add_path,
method: :post,
big: true,
class: 'margin-top-5 margin-bottom-2',
).with_content(t('two_factor_authentication.piv_cac_upsell.add_piv')) %>

<%= render ButtonComponent.new(
action: ->(**tag_options, &block) do
button_to(
login_piv_cac_recommended_skip_path,
**tag_options,
&block
)
end,
url: login_piv_cac_recommended_skip_path,
method: :post,
unstyled: true,
).with_content(@recommended_presenter.skip_text) %>

5 changes: 2 additions & 3 deletions app/views/users/piv_cac_setup_from_sign_in/prompt.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@
<% end %>

<%= render ButtonComponent.new(
action: ->(**tag_options, &block) do
button_to(login_add_piv_cac_prompt_path, **tag_options, method: :post, &block)
end,
url: login_add_piv_cac_prompt_path,
method: :post,
big: true,
wide: true,
outline: true,
Expand Down
Loading