Fix haml-lint InstanceVariables rule for admin/roles/_form (#26063)

This commit is contained in:
Matt Jankowski 2023-09-28 10:36:24 -04:00 committed by GitHub
parent f9eefb2785
commit 89a17878ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 35 deletions

View file

@ -1,13 +1,13 @@
# This configuration was generated by
# `haml-lint --auto-gen-config`
# on 2023-09-28 10:03:39 -0400 using Haml-Lint version 0.50.0.
# on 2023-09-28 10:26:23 -0400 using Haml-Lint version 0.50.0.
# The point is for the user to remove these configuration records
# one by one as the lints are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of Haml-Lint, may require this file to be generated again.
linters:
# Offense count: 946
# Offense count: 944
LineLength:
enabled: false
@ -26,11 +26,10 @@ linters:
- 'app/views/admin/reports/show.html.haml'
- 'app/views/disputes/strikes/show.html.haml'
# Offense count: 25
# Offense count: 18
InstanceVariables:
exclude:
- 'app/views/admin/reports/_actions.html.haml'
- 'app/views/admin/roles/_form.html.haml'
- 'app/views/auth/registrations/_status.html.haml'
- 'app/views/auth/sessions/two_factor/_otp_authentication_form.html.haml'
- 'app/views/relationships/_account.html.haml'

View file

@ -1,40 +1,36 @@
= simple_form_for @role, url: @role.new_record? ? admin_roles_path : admin_role_path(@role) do |f|
= render 'shared/error_messages', object: @role
= render 'shared/error_messages', object: form.object
- if @role.everyone?
.flash-message.info
= t('admin.roles.everyone_full_description_html')
- else
- if form.object.everyone?
.flash-message.info
= t('admin.roles.everyone_full_description_html')
- else
.fields-group
= form.input :name, wrapper: :with_label
- unless current_user.role == form.object
.fields-group
= f.input :name, wrapper: :with_label
= form.input :position, wrapper: :with_label, input_html: { max: current_user.role.position - 1 }
- unless current_user.role.id == @role.id
.fields-group
= f.input :position, wrapper: :with_label, input_html: { max: current_user.role.position - 1 }
.fields-group
= form.input :color, wrapper: :with_label, input_html: { placeholder: '#000000', type: 'color' }
.fields-group
= f.input :color, wrapper: :with_label, input_html: { placeholder: '#000000', type: 'color' }
%hr.spacer/
%hr.spacer/
.fields-group
= form.input :highlighted, wrapper: :with_label
.fields-group
= f.input :highlighted, wrapper: :with_label
%hr.spacer/
%hr.spacer/
- unless current_user.role == form.object
- unless current_user.role.id == @role.id
.field-group
.input.with_block_label
%label= t('simple_form.labels.user_role.permissions_as_keys')
%span.hint= t('simple_form.hints.user_role.permissions_as_keys')
.field-group
.input.with_block_label
%label= t('simple_form.labels.user_role.permissions_as_keys')
%span.hint= t('simple_form.hints.user_role.permissions_as_keys')
- (form.object.everyone? ? UserRole::Flags::CATEGORIES.slice(:invites) : UserRole::Flags::CATEGORIES).each do |category, permissions|
%h4= t(category, scope: 'admin.roles.categories')
- (@role.everyone? ? UserRole::Flags::CATEGORIES.slice(:invites) : UserRole::Flags::CATEGORIES).each do |category, permissions|
%h4= t(category, scope: 'admin.roles.categories')
= form.input :permissions_as_keys, collection: permissions, wrapper: :with_block_label, include_blank: false, label_method: ->(privilege) { safe_join([t("admin.roles.privileges.#{privilege}"), content_tag(:span, t("admin.roles.privileges.#{privilege}_description"), class: 'hint')]) }, required: false, as: :check_boxes, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li', label: false, hint: false, disabled: permissions.filter { |privilege| UserRole::FLAGS[privilege] & current_user.role.computed_permissions == 0 }
= f.input :permissions_as_keys, collection: permissions, wrapper: :with_block_label, include_blank: false, label_method: ->(privilege) { safe_join([t("admin.roles.privileges.#{privilege}"), content_tag(:span, t("admin.roles.privileges.#{privilege}_description"), class: 'hint')]) }, required: false, as: :check_boxes, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li', label: false, hint: false, disabled: permissions.filter { |privilege| UserRole::FLAGS[privilege] & current_user.role.computed_permissions == 0 }
%hr.spacer/
.actions
= f.button :button, @role.new_record? ? t('admin.roles.add_new') : t('generic.save_changes'), type: :submit
%hr.spacer/

View file

@ -4,4 +4,7 @@
- content_for :heading_actions do
= link_to t('admin.roles.delete'), admin_role_path(@role), method: :delete, data: { confirm: t('admin.accounts.are_you_sure') }, class: 'button button--destructive' if can?(:destroy, @role)
= render partial: 'form'
= simple_form_for @role, url: admin_role_path(@role) do |form|
= render partial: 'form', object: form
.actions
= form.button :button, t('generic.save_changes'), type: :submit

View file

@ -1,4 +1,7 @@
- content_for :page_title do
= t('admin.roles.add_new')
= render partial: 'form'
= simple_form_for @role, url: admin_roles_path do |form|
= render partial: 'form', object: form
.actions
= form.button :button, t('admin.roles.add_new'), type: :submit