From cf859d151b494a0786c07167f26dc52d0cfd407f Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Wed, 2 Oct 2024 09:08:40 -0400 Subject: [PATCH] More link/button conversion across views (#32199) --- app/views/admin/accounts/show.html.haml | 2 +- app/views/admin/instances/show.html.haml | 12 ++++++------ app/views/admin/invites/index.html.haml | 2 +- app/views/admin/reports/_actions.html.haml | 2 +- app/views/admin/reports/show.html.haml | 4 ++-- app/views/disputes/strikes/show.html.haml | 4 ++-- app/views/settings/exports/show.html.haml | 2 +- .../otp_authentication/show.html.haml | 2 +- .../index.html.haml | 4 ++-- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app/views/admin/accounts/show.html.haml b/app/views/admin/accounts/show.html.haml index f148b9a082..2d9e30e368 100644 --- a/app/views/admin/accounts/show.html.haml +++ b/app/views/admin/accounts/show.html.haml @@ -30,7 +30,7 @@ = render 'admin/accounts/counters', account: @account - if @account.local? && @account.user.nil? - = link_to t('admin.accounts.unblock_email'), unblock_email_admin_account_path(@account.id), method: :post, class: 'button' if can?(:unblock_email, @account) && CanonicalEmailBlock.exists?(reference_account_id: @account.id) + = button_to t('admin.accounts.unblock_email'), unblock_email_admin_account_path(@account.id), class: :button if can?(:unblock_email, @account) && CanonicalEmailBlock.exists?(reference_account_id: @account.id) - else .table-wrapper %table.table.inline-table diff --git a/app/views/admin/instances/show.html.haml b/app/views/admin/instances/show.html.haml index 812a9c8870..dd4c50549c 100644 --- a/app/views/admin/instances/show.html.haml +++ b/app/views/admin/instances/show.html.haml @@ -21,7 +21,7 @@ - if @instance.domain_allow = link_to t('admin.domain_allows.undo'), admin_domain_allow_path(@instance.domain_allow), class: 'button button--destructive', data: { confirm: t('admin.accounts.are_you_sure'), method: :delete } - else - = link_to t('admin.domain_allows.add_new'), admin_domain_allows_path(domain_allow: { domain: @instance.domain }), class: 'button', method: :post + = button_to t('admin.domain_allows.add_new'), admin_domain_allows_path(domain_allow: { domain: @instance.domain }), class: :button - else %p= t('admin.instances.content_policies.description_html') @@ -40,7 +40,7 @@ %td= @instance.domain_block.policies.map { |policy| t(policy, scope: 'admin.instances.content_policies.policies') }.join(' ยท ') = link_to t('admin.domain_blocks.edit'), edit_admin_domain_block_path(@instance.domain_block), class: 'button' - = link_to t('admin.domain_blocks.undo'), admin_domain_block_path(@instance.domain_block), class: 'button', data: { confirm: t('admin.accounts.are_you_sure'), method: :delete } + = button_to t('admin.domain_blocks.undo'), admin_domain_block_path(@instance.domain_block), class: :button, data: { confirm: t('admin.accounts.are_you_sure'), method: :delete } - else = link_to t('admin.domain_blocks.add_new'), new_admin_domain_block_path(_domain: @instance.domain), class: 'button' @@ -70,16 +70,16 @@ - if @instance.unavailable? %span.negative-hint = t('admin.instances.availability.failure_threshold_reached', date: l(@instance.unavailable_domain.created_at.to_date)) - = link_to t('admin.instances.delivery.restart'), restart_delivery_admin_instance_path(@instance), data: { confirm: t('admin.accounts.are_you_sure'), method: :post } + = button_to t('admin.instances.delivery.restart'), restart_delivery_admin_instance_path(@instance), data: { confirm: t('admin.accounts.are_you_sure') } - elsif @instance.exhausted_deliveries_days.empty? %span.positive-hint = t('admin.instances.availability.no_failures_recorded') - = link_to t('admin.instances.delivery.stop'), stop_delivery_admin_instance_path(@instance), data: { confirm: t('admin.accounts.are_you_sure'), method: :post } + = button_to t('admin.instances.delivery.stop'), stop_delivery_admin_instance_path(@instance), data: { confirm: t('admin.accounts.are_you_sure') } - else %span.negative-hint = t('admin.instances.availability.failures_recorded', count: @instance.delivery_failure_tracker.days) - %span= link_to t('admin.instances.delivery.clear'), clear_delivery_errors_admin_instance_path(@instance), data: { confirm: t('admin.accounts.are_you_sure'), method: :post } unless @instance.exhausted_deliveries_days.empty? - %span= link_to t('admin.instances.delivery.stop'), stop_delivery_admin_instance_path(@instance), data: { confirm: t('admin.accounts.are_you_sure'), method: :post } + %span= button_to t('admin.instances.delivery.clear'), clear_delivery_errors_admin_instance_path(@instance), data: { confirm: t('admin.accounts.are_you_sure') } unless @instance.exhausted_deliveries_days.empty? + %span= button_to t('admin.instances.delivery.stop'), stop_delivery_admin_instance_path(@instance), data: { confirm: t('admin.accounts.are_you_sure') } - if @instance.purgeable? %p= t('admin.instances.purge_description_html') diff --git a/app/views/admin/invites/index.html.haml b/app/views/admin/invites/index.html.haml index 964deaba8f..bbccca3147 100644 --- a/app/views/admin/invites/index.html.haml +++ b/app/views/admin/invites/index.html.haml @@ -34,4 +34,4 @@ = paginate @invites - if policy(:invite).deactivate_all? - = link_to t('admin.invites.deactivate_all'), deactivate_all_admin_invites_path, method: :post, data: { confirm: t('admin.accounts.are_you_sure') }, class: 'button' + = button_to t('admin.invites.deactivate_all'), deactivate_all_admin_invites_path, data: { confirm: t('admin.accounts.are_you_sure') }, class: :button diff --git a/app/views/admin/reports/_actions.html.haml b/app/views/admin/reports/_actions.html.haml index ef016e949b..c25f45e169 100644 --- a/app/views/admin/reports/_actions.html.haml +++ b/app/views/admin/reports/_actions.html.haml @@ -2,7 +2,7 @@ .report-actions .report-actions__item .report-actions__item__button - = link_to t('admin.reports.mark_as_resolved'), resolve_admin_report_path(report), method: :post, class: 'button' + = button_to t('admin.reports.mark_as_resolved'), resolve_admin_report_path(report), class: :button .report-actions__item__description = t('admin.reports.actions.resolve_description_html') - if statuses.any? { |status| (status.with_media? || status.with_preview_card?) && !status.discarded? } diff --git a/app/views/admin/reports/show.html.haml b/app/views/admin/reports/show.html.haml index 69e9c02921..32b6b3be8d 100644 --- a/app/views/admin/reports/show.html.haml +++ b/app/views/admin/reports/show.html.haml @@ -3,9 +3,9 @@ - content_for :heading_actions do - if @report.unresolved? - = link_to t('admin.reports.mark_as_resolved'), resolve_admin_report_path(@report), method: :post, class: 'button' + = button_to t('admin.reports.mark_as_resolved'), resolve_admin_report_path(@report), class: :button - else - = link_to t('admin.reports.mark_as_unresolved'), reopen_admin_report_path(@report), method: :post, class: 'button' + = button_to t('admin.reports.mark_as_unresolved'), reopen_admin_report_path(@report), class: :button - unless @report.account.local? || @report.target_account.local? .flash-message= t('admin.reports.forwarded_replies_explanation') diff --git a/app/views/disputes/strikes/show.html.haml b/app/views/disputes/strikes/show.html.haml index 150dc06759..1d71e0ddd1 100644 --- a/app/views/disputes/strikes/show.html.haml +++ b/app/views/disputes/strikes/show.html.haml @@ -3,8 +3,8 @@ - content_for :heading_actions do - if @appeal.persisted? - = link_to t('disputes.strikes.approve_appeal'), approve_admin_disputes_appeal_path(@appeal), method: :post, class: 'button' if can?(:approve, @appeal) - = link_to t('disputes.strikes.reject_appeal'), reject_admin_disputes_appeal_path(@appeal), method: :post, class: 'button button--destructive' if can?(:reject, @appeal) + = button_to t('disputes.strikes.approve_appeal'), approve_admin_disputes_appeal_path(@appeal), class: :button if can?(:approve, @appeal) + = button_to t('disputes.strikes.reject_appeal'), reject_admin_disputes_appeal_path(@appeal), class: 'button button--destructive' if can?(:reject, @appeal) - if @strike.overruled? %p.hint diff --git a/app/views/settings/exports/show.html.haml b/app/views/settings/exports/show.html.haml index 273c5a4ba6..61d55350c2 100644 --- a/app/views/settings/exports/show.html.haml +++ b/app/views/settings/exports/show.html.haml @@ -46,7 +46,7 @@ %p.muted-hint= t('exports.archive_takeout.hint_html') - if policy(:backup).create? - %p= link_to t('exports.archive_takeout.request'), settings_export_path, class: 'button', method: :post + %p= button_to t('exports.archive_takeout.request'), settings_export_path, class: :button - unless @backups.empty? %hr.spacer/ diff --git a/app/views/settings/two_factor_authentication/otp_authentication/show.html.haml b/app/views/settings/two_factor_authentication/otp_authentication/show.html.haml index d069ba12a9..01f385dbea 100644 --- a/app/views/settings/two_factor_authentication/otp_authentication/show.html.haml +++ b/app/views/settings/two_factor_authentication/otp_authentication/show.html.haml @@ -6,4 +6,4 @@ %hr.spacer/ - = link_to t('otp_authentication.setup'), settings_otp_authentication_path, data: { method: :post }, class: 'block-button' + = button_to t('otp_authentication.setup'), settings_otp_authentication_path, class: 'block-button' diff --git a/app/views/settings/two_factor_authentication_methods/index.html.haml b/app/views/settings/two_factor_authentication_methods/index.html.haml index 8b670283b9..e3a211a3d7 100644 --- a/app/views/settings/two_factor_authentication_methods/index.html.haml +++ b/app/views/settings/two_factor_authentication_methods/index.html.haml @@ -2,7 +2,7 @@ = t('settings.two_factor_authentication') - content_for :heading_actions do - = link_to t('two_factor_authentication.disable'), disable_settings_two_factor_authentication_methods_path, class: 'button button--destructive', method: :post + = button_to t('two_factor_authentication.disable'), disable_settings_two_factor_authentication_methods_path, class: 'button button--destructive' %p.hint %span.positive-hint @@ -38,4 +38,4 @@ %hr.spacer/ .simple_form - = link_to t('two_factor_authentication.generate_recovery_codes'), settings_two_factor_authentication_recovery_codes_path, data: { method: :post }, class: 'block-button' + = button_to t('two_factor_authentication.generate_recovery_codes'), settings_two_factor_authentication_recovery_codes_path, class: 'block-button'