mirror of
https://github.com/glitch-soc/mastodon.git
synced 2024-11-23 16:44:04 -05:00
Extract helper methods for form label in admin/ area views (#27575)
This commit is contained in:
parent
9b47c5d53c
commit
72b7cd349c
12
app/helpers/admin/account_actions_helper.rb
Normal file
12
app/helpers/admin/account_actions_helper.rb
Normal file
@ -0,0 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin::AccountActionsHelper
|
||||
def account_action_type_label(type)
|
||||
safe_join(
|
||||
[
|
||||
I18n.t("simple_form.labels.admin_account_action.types.#{type}"),
|
||||
content_tag(:span, I18n.t("simple_form.hints.admin_account_action.types.#{type}"), class: 'hint'),
|
||||
]
|
||||
)
|
||||
end
|
||||
end
|
19
app/helpers/admin/accounts_helper.rb
Normal file
19
app/helpers/admin/accounts_helper.rb
Normal file
@ -0,0 +1,19 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin::AccountsHelper
|
||||
def admin_accounts_moderation_options
|
||||
[
|
||||
[t('admin.accounts.moderation.active'), 'active'],
|
||||
[t('admin.accounts.moderation.silenced'), 'silenced'],
|
||||
[t('admin.accounts.moderation.disabled'), 'disabled'],
|
||||
[t('admin.accounts.moderation.suspended'), 'suspended'],
|
||||
[safe_join([t('admin.accounts.moderation.pending'), "(#{pending_user_count_label})"], ' '), 'pending'],
|
||||
]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def pending_user_count_label
|
||||
number_with_delimiter User.pending.count
|
||||
end
|
||||
end
|
12
app/helpers/admin/ip_blocks_helper.rb
Normal file
12
app/helpers/admin/ip_blocks_helper.rb
Normal file
@ -0,0 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin::IpBlocksHelper
|
||||
def ip_blocks_severity_label(severity)
|
||||
safe_join(
|
||||
[
|
||||
I18n.t("simple_form.labels.ip_block.severities.#{severity}"),
|
||||
content_tag(:span, I18n.t("simple_form.hints.ip_block.severities.#{severity}"), class: 'hint'),
|
||||
]
|
||||
)
|
||||
end
|
||||
end
|
15
app/helpers/admin/settings/discovery_helper.rb
Normal file
15
app/helpers/admin/settings/discovery_helper.rb
Normal file
@ -0,0 +1,15 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin::Settings::DiscoveryHelper
|
||||
def discovery_warning_hint_text
|
||||
authorized_fetch_overridden? ? t('admin.settings.security.authorized_fetch_overridden_hint') : nil
|
||||
end
|
||||
|
||||
def discovery_hint_text
|
||||
t('admin.settings.security.authorized_fetch_hint')
|
||||
end
|
||||
|
||||
def discovery_recommended_value
|
||||
authorized_fetch_overridden? ? :overridden : nil
|
||||
end
|
||||
end
|
@ -5,7 +5,7 @@
|
||||
= f.input :report_id, as: :hidden
|
||||
|
||||
.fields-group
|
||||
= f.input :type, as: :radio_buttons, collection: Admin::AccountAction.types_for_account(@account), include_blank: false, wrapper: :with_block_label, label_method: ->(type) { safe_join([I18n.t("simple_form.labels.admin_account_action.types.#{type}"), content_tag(:span, I18n.t("simple_form.hints.admin_account_action.types.#{type}"), class: 'hint')]) }, hint: t('simple_form.hints.admin_account_action.type_html', acct: @account.pretty_acct)
|
||||
= f.input :type, as: :radio_buttons, collection: Admin::AccountAction.types_for_account(@account), include_blank: false, wrapper: :with_block_label, label_method: ->(type) { account_action_type_label(type) }, hint: t('simple_form.hints.admin_account_action.type_html', acct: @account.pretty_acct)
|
||||
|
||||
- if @account.local?
|
||||
%hr.spacer/
|
||||
|
@ -10,7 +10,7 @@
|
||||
.filter-subset.filter-subset--with-select
|
||||
%strong= t('admin.accounts.moderation.title')
|
||||
.input.select.optional
|
||||
= select_tag :status, options_for_select([[t('admin.accounts.moderation.active'), 'active'], [t('admin.accounts.moderation.silenced'), 'silenced'], [t('admin.accounts.moderation.disabled'), 'disabled'], [t('admin.accounts.moderation.suspended'), 'suspended'], [safe_join([t('admin.accounts.moderation.pending'), "(#{number_with_delimiter(User.pending.count)})"], ' '), 'pending']], params[:status]), prompt: I18n.t('generic.all')
|
||||
= select_tag :status, options_for_select(admin_accounts_moderation_options, params[:status]), prompt: I18n.t('generic.all')
|
||||
.filter-subset.filter-subset--with-select
|
||||
%strong= t('admin.accounts.role')
|
||||
.input.select.optional
|
||||
|
@ -11,7 +11,7 @@
|
||||
= f.input :expires_in, wrapper: :with_block_label, collection: [1.day, 2.weeks, 1.month, 6.months, 1.year, 3.years].map(&:to_i), label_method: ->(i) { I18n.t("admin.ip_blocks.expires_in.#{i}") }, prompt: I18n.t('invites.expires_in_prompt')
|
||||
|
||||
.fields-group
|
||||
= f.input :severity, as: :radio_buttons, collection: IpBlock.severities.keys, include_blank: false, wrapper: :with_block_label, label_method: ->(severity) { safe_join([I18n.t("simple_form.labels.ip_block.severities.#{severity}"), content_tag(:span, I18n.t("simple_form.hints.ip_block.severities.#{severity}"), class: 'hint')]) }
|
||||
= f.input :severity, as: :radio_buttons, collection: IpBlock.severities.keys, include_blank: false, wrapper: :with_block_label, label_method: ->(severity) { ip_blocks_severity_label(severity) }
|
||||
|
||||
.fields-group
|
||||
= f.input :comment, as: :string, wrapper: :with_block_label
|
||||
|
@ -42,7 +42,7 @@
|
||||
%h4= t('admin.settings.security.federation_authentication')
|
||||
|
||||
.fields-group
|
||||
= f.input :authorized_fetch, as: :boolean, wrapper: :with_label, label: t('admin.settings.security.authorized_fetch'), warning_hint: authorized_fetch_overridden? ? t('admin.settings.security.authorized_fetch_overridden_hint') : nil, hint: t('admin.settings.security.authorized_fetch_hint'), disabled: authorized_fetch_overridden?, recommended: authorized_fetch_overridden? ? :overridden : nil
|
||||
= f.input :authorized_fetch, as: :boolean, wrapper: :with_label, label: t('admin.settings.security.authorized_fetch'), warning_hint: discovery_warning_hint_text, hint: discovery_hint_text, disabled: authorized_fetch_overridden?, recommended: discovery_recommended_value
|
||||
|
||||
%h4= t('admin.settings.discovery.follow_recommendations')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user