FIX: Conditionally hide Add Alternate Email button based on site setting (#22525)

Hide button in UI if `max_allowed_secondary_emails` site setting is 0.
This commit is contained in:
Selase Krakani 2023-07-11 12:17:40 +00:00 committed by GitHub
parent 3136f6766b
commit 69e0c23f41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 1 deletions

View File

@ -140,6 +140,14 @@ export default Controller.extend(CanCheckEmails, {
return findAll().length > 0;
},
@discourseComputed(
"siteSettings.max_allowed_secondary_emails",
"model.can_edit_email"
)
canAddEmail(maxAllowedSecondaryEmails, canEditEmail) {
return maxAllowedSecondaryEmails > 0 && canEditEmail;
},
@action
resendConfirmationEmail(email, event) {
event?.preventDefault();

View File

@ -67,7 +67,7 @@
{{/each}}
</div>
{{#if this.model.can_edit_email}}
{{#if this.canAddEmail}}
<LinkTo
@route="preferences.email"
@query={{hash new=1}}

View File

@ -235,3 +235,15 @@ acceptance(
});
}
);
acceptance("User Preference - No Secondary Emails Allowed", function (needs) {
needs.user();
needs.pretender(preferencesPretender);
needs.settings({ max_allowed_secondary_emails: 0 });
test("Add Alternate Email Button is unvailable", async function (assert) {
await visit("/u/eviltrout/preferences");
assert.dom(".pref-email a").doesNotExist();
});
});

View File

@ -2019,6 +2019,7 @@ rate_limits:
max_allowed_secondary_emails:
default: 10
hidden: true
client: true
max_batch_presign_multipart_per_minute:
default: 20
hidden: true