Change “Posting defaults” settings page to enforce nobody quote policy for private default visibility (#36040)
This commit is contained in:
@@ -145,6 +145,10 @@ function loaded() {
|
||||
);
|
||||
});
|
||||
|
||||
updateDefaultQuotePrivacyFromPrivacy(
|
||||
document.querySelector('#user_settings_attributes_default_privacy'),
|
||||
);
|
||||
|
||||
const reactComponents = document.querySelectorAll('[data-component]');
|
||||
|
||||
if (reactComponents.length > 0) {
|
||||
@@ -364,6 +368,34 @@ Rails.delegate(
|
||||
},
|
||||
);
|
||||
|
||||
const updateDefaultQuotePrivacyFromPrivacy = (
|
||||
privacySelect: EventTarget | null,
|
||||
) => {
|
||||
if (!(privacySelect instanceof HTMLSelectElement) || !privacySelect.form)
|
||||
return;
|
||||
|
||||
const select = privacySelect.form.querySelector<HTMLSelectElement>(
|
||||
'select#user_settings_attributes_default_quote_policy',
|
||||
);
|
||||
if (!select) return;
|
||||
|
||||
if (privacySelect.value === 'private') {
|
||||
select.value = 'nobody';
|
||||
setInputDisabled(select, true);
|
||||
} else {
|
||||
setInputDisabled(select, false);
|
||||
}
|
||||
};
|
||||
|
||||
Rails.delegate(
|
||||
document,
|
||||
'#user_settings_attributes_default_privacy',
|
||||
'change',
|
||||
({ target }) => {
|
||||
updateDefaultQuotePrivacyFromPrivacy(target);
|
||||
},
|
||||
);
|
||||
|
||||
// Empty the honeypot fields in JS in case something like an extension
|
||||
// automatically filled them.
|
||||
Rails.delegate(document, '#registration_new_user,#new_user', 'submit', () => {
|
||||
|
||||
Reference in New Issue
Block a user