Merge commit '3389c41b5899c1da479bfc08e84588184e09902d' into glitch-soc/merge-upstream
Conflicts: - `app/javascript/packs/admin.tsx`: Changes applied to `app/javascript/core/admin.ts` instead.shrike
commit
f01605c665
|
@ -1,3 +1,4 @@
|
||||||
|
comment: false # Do not leave PR comments
|
||||||
coverage:
|
coverage:
|
||||||
status:
|
status:
|
||||||
project:
|
project:
|
||||||
|
@ -8,6 +9,3 @@ coverage:
|
||||||
default:
|
default:
|
||||||
# Github status check is not blocking
|
# Github status check is not blocking
|
||||||
informational: true
|
informational: true
|
||||||
comment:
|
|
||||||
# Only write a comment in PR if there are changes
|
|
||||||
require_changes: true
|
|
||||||
|
|
|
@ -150,7 +150,7 @@ Rails.delegate(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const onDomainBlockSeverityChange = (target: HTMLInputElement) => {
|
const onDomainBlockSeverityChange = (target: HTMLSelectElement) => {
|
||||||
const rejectMediaDiv = document.querySelector(
|
const rejectMediaDiv = document.querySelector(
|
||||||
'.input.with_label.domain_block_reject_media',
|
'.input.with_label.domain_block_reject_media',
|
||||||
);
|
);
|
||||||
|
@ -170,7 +170,7 @@ const onDomainBlockSeverityChange = (target: HTMLInputElement) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
Rails.delegate(document, '#domain_block_severity', 'change', ({ target }) => {
|
Rails.delegate(document, '#domain_block_severity', 'change', ({ target }) => {
|
||||||
if (target instanceof HTMLInputElement) onDomainBlockSeverityChange(target);
|
if (target instanceof HTMLSelectElement) onDomainBlockSeverityChange(target);
|
||||||
});
|
});
|
||||||
|
|
||||||
const onEnableBootstrapTimelineAccountsChange = (target: HTMLInputElement) => {
|
const onEnableBootstrapTimelineAccountsChange = (target: HTMLInputElement) => {
|
||||||
|
@ -207,7 +207,7 @@ Rails.delegate(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const onChangeRegistrationMode = (target: HTMLInputElement) => {
|
const onChangeRegistrationMode = (target: HTMLSelectElement) => {
|
||||||
const enabled = target.value === 'approved';
|
const enabled = target.value === 'approved';
|
||||||
|
|
||||||
document
|
document
|
||||||
|
@ -257,16 +257,16 @@ Rails.delegate(
|
||||||
'#form_admin_settings_registrations_mode',
|
'#form_admin_settings_registrations_mode',
|
||||||
'change',
|
'change',
|
||||||
({ target }) => {
|
({ target }) => {
|
||||||
if (target instanceof HTMLInputElement) onChangeRegistrationMode(target);
|
if (target instanceof HTMLSelectElement) onChangeRegistrationMode(target);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
ready(() => {
|
ready(() => {
|
||||||
const domainBlockSeverityInput = document.querySelector<HTMLInputElement>(
|
const domainBlockSeveritySelect = document.querySelector<HTMLSelectElement>(
|
||||||
'input#domain_block_severity',
|
'select#domain_block_severity',
|
||||||
);
|
);
|
||||||
if (domainBlockSeverityInput)
|
if (domainBlockSeveritySelect)
|
||||||
onDomainBlockSeverityChange(domainBlockSeverityInput);
|
onDomainBlockSeverityChange(domainBlockSeveritySelect);
|
||||||
|
|
||||||
const enableBootstrapTimelineAccounts =
|
const enableBootstrapTimelineAccounts =
|
||||||
document.querySelector<HTMLInputElement>(
|
document.querySelector<HTMLInputElement>(
|
||||||
|
@ -275,8 +275,8 @@ ready(() => {
|
||||||
if (enableBootstrapTimelineAccounts)
|
if (enableBootstrapTimelineAccounts)
|
||||||
onEnableBootstrapTimelineAccountsChange(enableBootstrapTimelineAccounts);
|
onEnableBootstrapTimelineAccountsChange(enableBootstrapTimelineAccounts);
|
||||||
|
|
||||||
const registrationMode = document.querySelector<HTMLInputElement>(
|
const registrationMode = document.querySelector<HTMLSelectElement>(
|
||||||
'input#form_admin_settings_registrations_mode',
|
'select#form_admin_settings_registrations_mode',
|
||||||
);
|
);
|
||||||
if (registrationMode) onChangeRegistrationMode(registrationMode);
|
if (registrationMode) onChangeRegistrationMode(registrationMode);
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ class UserRole < ApplicationRecord
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
EVERYONE_ROLE_ID = -99
|
EVERYONE_ROLE_ID = -99
|
||||||
|
NOBODY_POSITION = -1
|
||||||
|
|
||||||
module Flags
|
module Flags
|
||||||
NONE = 0
|
NONE = 0
|
||||||
|
@ -104,7 +105,7 @@ class UserRole < ApplicationRecord
|
||||||
has_many :users, inverse_of: :role, foreign_key: 'role_id', dependent: :nullify
|
has_many :users, inverse_of: :role, foreign_key: 'role_id', dependent: :nullify
|
||||||
|
|
||||||
def self.nobody
|
def self.nobody
|
||||||
@nobody ||= UserRole.new(permissions: Flags::NONE, position: -1)
|
@nobody ||= UserRole.new(permissions: Flags::NONE, position: NOBODY_POSITION)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.everyone
|
def self.everyone
|
||||||
|
@ -173,7 +174,7 @@ class UserRole < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_position
|
def set_position
|
||||||
self.position = -1 if everyone?
|
self.position = NOBODY_POSITION if everyone?
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_own_role_edition
|
def validate_own_role_edition
|
||||||
|
|
|
@ -139,7 +139,7 @@ RSpec.describe UserRole do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has negative position' do
|
it 'has negative position' do
|
||||||
expect(subject.position).to eq(-1)
|
expect(subject.position).to eq(described_class::NOBODY_POSITION)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ RSpec.describe UserRole do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has negative position' do
|
it 'has negative position' do
|
||||||
expect(subject.position).to eq(-1)
|
expect(subject.position).to eq(described_class::NOBODY_POSITION)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue