Add customizable user roles (#18641)
* Add customizable user roles * Various fixes and improvements * Add migration for old settings and fix tootctl role management
This commit is contained in:
parent
1b4054256f
commit
44b2ee3485
187 changed files with 1945 additions and 1032 deletions
|
@ -4,45 +4,36 @@
|
|||
- content_for :header_tags do
|
||||
= javascript_pack_tag 'admin', async: true, crossorigin: 'anonymous'
|
||||
|
||||
.filters
|
||||
.filter-subset
|
||||
%strong= t('admin.accounts.location.title')
|
||||
%ul
|
||||
%li= filter_link_to t('generic.all'), origin: nil
|
||||
%li= filter_link_to t('admin.accounts.location.local'), origin: 'local'
|
||||
%li= filter_link_to t('admin.accounts.location.remote'), origin: 'remote'
|
||||
.filter-subset
|
||||
%strong= t('admin.accounts.moderation.title')
|
||||
%ul
|
||||
%li= filter_link_to t('generic.all'), status: nil
|
||||
%li= filter_link_to t('admin.accounts.moderation.active'), status: 'active'
|
||||
%li= filter_link_to t('admin.accounts.moderation.suspended'), status: 'suspended'
|
||||
%li= filter_link_to safe_join([t('admin.accounts.moderation.pending'), "(#{number_with_delimiter(User.pending.count)})"], ' '), status: 'pending'
|
||||
.filter-subset
|
||||
%strong= t('admin.accounts.role')
|
||||
%ul
|
||||
%li= filter_link_to t('admin.accounts.moderation.all'), permissions: nil
|
||||
%li= filter_link_to t('admin.accounts.roles.staff'), permissions: 'staff'
|
||||
.filter-subset
|
||||
%strong= t 'generic.order_by'
|
||||
%ul
|
||||
%li= filter_link_to t('relationships.most_recent'), order: nil
|
||||
%li= filter_link_to t('relationships.last_active'), order: 'active'
|
||||
|
||||
= form_tag admin_accounts_url, method: 'GET', class: 'simple_form' do
|
||||
.fields-group
|
||||
- (AccountFilter::KEYS - %i(origin status permissions)).each do |key|
|
||||
- if params[key].present?
|
||||
= hidden_field_tag key, params[key]
|
||||
.filters
|
||||
.filter-subset.filter-subset--with-select
|
||||
%strong= t('admin.accounts.location.title')
|
||||
.input.select.optional
|
||||
= select_tag :origin, options_for_select([[t('admin.accounts.location.local'), 'local'], [t('admin.accounts.location.remote'), 'remote']], params[:origin]), prompt: I18n.t('generic.all')
|
||||
.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.suspended'), 'suspended'], [safe_join([t('admin.accounts.moderation.pending'), "(#{number_with_delimiter(User.pending.count)})"], ' '), 'pending']], params[:status]), prompt: I18n.t('generic.all')
|
||||
.filter-subset.filter-subset--with-select
|
||||
%strong= t('admin.accounts.role')
|
||||
.input.select.optional
|
||||
= select_tag :role_ids, options_from_collection_for_select(UserRole.assignable, :id, :name, params[:role_ids]), prompt: I18n.t('admin.accounts.moderation.all')
|
||||
.filter-subset.filter-subset--with-select
|
||||
%strong= t 'generic.order_by'
|
||||
.input.select
|
||||
= select_tag :order, options_for_select([[t('relationships.most_recent'), nil], [t('relationships.last_active'), 'active']], params[:order])
|
||||
|
||||
.fields-group
|
||||
- %i(username by_domain display_name email ip).each do |key|
|
||||
- unless key == :by_domain && params[:origin] != 'remote'
|
||||
.input.string.optional
|
||||
= text_field_tag key, params[key], class: 'string optional', placeholder: I18n.t("admin.accounts.#{key}")
|
||||
|
||||
.actions
|
||||
%button.button= t('admin.accounts.search')
|
||||
= link_to t('admin.accounts.reset'), admin_accounts_path, class: 'button negative'
|
||||
.actions
|
||||
%button.button= t('admin.accounts.search')
|
||||
= link_to t('admin.accounts.reset'), admin_accounts_path, class: 'button negative'
|
||||
|
||||
%hr.spacer/
|
||||
|
||||
= form_for(@form, url: batch_admin_accounts_path) do |f|
|
||||
= hidden_field_tag :page, params[:page] || 1
|
||||
|
|
|
@ -92,10 +92,13 @@
|
|||
|
||||
%tr
|
||||
%th= t('admin.accounts.role')
|
||||
%td= t("admin.accounts.roles.#{@account.user&.role}")
|
||||
%td
|
||||
= table_link_to 'angle-double-up', t('admin.accounts.promote'), promote_admin_account_role_path(@account.id), method: :post, data: { confirm: t('admin.accounts.are_you_sure') } if can?(:promote, @account.user)
|
||||
= table_link_to 'angle-double-down', t('admin.accounts.demote'), demote_admin_account_role_path(@account.id), method: :post, data: { confirm: t('admin.accounts.are_you_sure') } if can?(:demote, @account.user)
|
||||
- if @account.user_role&.everyone?
|
||||
= t('admin.accounts.no_role_assigned')
|
||||
- else
|
||||
= @account.user_role&.name
|
||||
%td
|
||||
= table_link_to 'vcard', t('admin.accounts.change_role.label'), admin_user_role_path(@account.user) if can?(:change_role, @account.user)
|
||||
|
||||
%tr
|
||||
%th{ rowspan: can?(:create, :email_domain_block) ? 3 : 2 }= t('admin.accounts.email')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue