~cytrogen/masto-fe

89a17878ef7c6e1b5fae847ee293a7dcfc43c305 — Matt Jankowski 2 years ago f9eefb2
Fix haml-lint `InstanceVariables` rule for admin/roles/_form (#26063)

M .haml-lint_todo.yml => .haml-lint_todo.yml +3 -4
@@ 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'

M app/views/admin/roles/_form.html.haml => app/views/admin/roles/_form.html.haml +24 -28
@@ 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
    .fields-group
      = f.input :name, wrapper: :with_label

    - unless current_user.role.id == @role.id
      .fields-group
        = f.input :position, wrapper: :with_label, input_html: { max: current_user.role.position - 1 }
- 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 :color, wrapper: :with_label, input_html: { placeholder: '#000000', type: 'color' }
      = form.input :position, wrapper: :with_label, input_html: { max: current_user.role.position - 1 }

    %hr.spacer/
  .fields-group
    = form.input :color, wrapper: :with_label, input_html: { placeholder: '#000000', type: 'color' }

    .fields-group
      = f.input :highlighted, wrapper: :with_label
  %hr.spacer/

    %hr.spacer/
  .fields-group
    = form.input :highlighted, wrapper: :with_label

  - unless current_user.role.id == @role.id
  %hr.spacer/

    .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')
- unless current_user.role == form.object

      - (@role.everyone? ? UserRole::Flags::CATEGORIES.slice(:invites) : UserRole::Flags::CATEGORIES).each do |category, permissions|
        %h4= t(category, scope: 'admin.roles.categories')
  .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')

        = 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 }
    - (form.object.everyone? ? UserRole::Flags::CATEGORIES.slice(:invites) : UserRole::Flags::CATEGORIES).each do |category, permissions|
      %h4= t(category, scope: 'admin.roles.categories')

    %hr.spacer/
      = 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 }

  .actions
    = f.button :button, @role.new_record? ? t('admin.roles.add_new') : t('generic.save_changes'), type: :submit
  %hr.spacer/

M app/views/admin/roles/edit.html.haml => app/views/admin/roles/edit.html.haml +4 -1
@@ 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

M app/views/admin/roles/new.html.haml => app/views/admin/roles/new.html.haml +4 -1
@@ 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