From b9940eb9778d9bf26b3bfea002424f1731c34383 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 29 Feb 2024 18:25:04 -0500 Subject: [PATCH 1/3] Disable codecov comments on PRs (#29464) --- .github/codecov.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/codecov.yml b/.github/codecov.yml index 5532c49618..9d6413a106 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -1,3 +1,4 @@ +comment: false # Do not leave PR comments coverage: status: project: @@ -8,6 +9,3 @@ coverage: default: # Github status check is not blocking informational: true -comment: - # Only write a comment in PR if there are changes - require_changes: true From ec953bf378ac6ae9b7dab5db053dca947f3c869b Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 1 Mar 2024 11:16:35 +0100 Subject: [PATCH 2/3] Fix regression in handling `select` elements in `packs/admin.tsx` (#29469) --- app/javascript/packs/admin.tsx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/javascript/packs/admin.tsx b/app/javascript/packs/admin.tsx index 25e0889cd9..9fee560565 100644 --- a/app/javascript/packs/admin.tsx +++ b/app/javascript/packs/admin.tsx @@ -149,7 +149,7 @@ Rails.delegate( }, ); -const onDomainBlockSeverityChange = (target: HTMLInputElement) => { +const onDomainBlockSeverityChange = (target: HTMLSelectElement) => { const rejectMediaDiv = document.querySelector( '.input.with_label.domain_block_reject_media', ); @@ -169,7 +169,7 @@ const onDomainBlockSeverityChange = (target: HTMLInputElement) => { }; Rails.delegate(document, '#domain_block_severity', 'change', ({ target }) => { - if (target instanceof HTMLInputElement) onDomainBlockSeverityChange(target); + if (target instanceof HTMLSelectElement) onDomainBlockSeverityChange(target); }); const onEnableBootstrapTimelineAccountsChange = (target: HTMLInputElement) => { @@ -206,7 +206,7 @@ Rails.delegate( }, ); -const onChangeRegistrationMode = (target: HTMLInputElement) => { +const onChangeRegistrationMode = (target: HTMLSelectElement) => { const enabled = target.value === 'approved'; document @@ -256,7 +256,7 @@ Rails.delegate( '#form_admin_settings_registrations_mode', 'change', ({ target }) => { - if (target instanceof HTMLInputElement) onChangeRegistrationMode(target); + if (target instanceof HTMLSelectElement) onChangeRegistrationMode(target); }, ); @@ -286,11 +286,11 @@ async function mountReactComponent(element: Element) { } ready(() => { - const domainBlockSeverityInput = document.querySelector( - 'input#domain_block_severity', + const domainBlockSeveritySelect = document.querySelector( + 'select#domain_block_severity', ); - if (domainBlockSeverityInput) - onDomainBlockSeverityChange(domainBlockSeverityInput); + if (domainBlockSeveritySelect) + onDomainBlockSeverityChange(domainBlockSeveritySelect); const enableBootstrapTimelineAccounts = document.querySelector( @@ -299,8 +299,8 @@ ready(() => { if (enableBootstrapTimelineAccounts) onEnableBootstrapTimelineAccountsChange(enableBootstrapTimelineAccounts); - const registrationMode = document.querySelector( - 'input#form_admin_settings_registrations_mode', + const registrationMode = document.querySelector( + 'select#form_admin_settings_registrations_mode', ); if (registrationMode) onChangeRegistrationMode(registrationMode); From 3389c41b5899c1da479bfc08e84588184e09902d Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Fri, 1 Mar 2024 06:05:24 -0500 Subject: [PATCH 3/3] Move `nobody` position in `UserRole` magic number to constant (#29465) --- app/models/user_role.rb | 5 +++-- spec/models/user_role_spec.rb | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/models/user_role.rb b/app/models/user_role.rb index 9115d91c24..23cc28b9b7 100644 --- a/app/models/user_role.rb +++ b/app/models/user_role.rb @@ -39,6 +39,7 @@ class UserRole < ApplicationRecord }.freeze EVERYONE_ROLE_ID = -99 + NOBODY_POSITION = -1 module Flags NONE = 0 @@ -104,7 +105,7 @@ class UserRole < ApplicationRecord has_many :users, inverse_of: :role, foreign_key: 'role_id', dependent: :nullify def self.nobody - @nobody ||= UserRole.new(permissions: Flags::NONE, position: -1) + @nobody ||= UserRole.new(permissions: Flags::NONE, position: NOBODY_POSITION) end def self.everyone @@ -173,7 +174,7 @@ class UserRole < ApplicationRecord end def set_position - self.position = -1 if everyone? + self.position = NOBODY_POSITION if everyone? end def validate_own_role_edition diff --git a/spec/models/user_role_spec.rb b/spec/models/user_role_spec.rb index 9dd04a8172..96d12263ae 100644 --- a/spec/models/user_role_spec.rb +++ b/spec/models/user_role_spec.rb @@ -139,7 +139,7 @@ RSpec.describe UserRole do end it 'has negative position' do - expect(subject.position).to eq(-1) + expect(subject.position).to eq(described_class::NOBODY_POSITION) end end @@ -159,7 +159,7 @@ RSpec.describe UserRole do end it 'has negative position' do - expect(subject.position).to eq(-1) + expect(subject.position).to eq(described_class::NOBODY_POSITION) end end