From 3187606d3402003437c2ccd6121a26f874939228 Mon Sep 17 00:00:00 2001 From: Osama Sayegh Date: Mon, 30 Dec 2024 22:26:20 +0300 Subject: [PATCH] FEATURE: Add option to hide full name input at signup (#30471) This commit replaces the `full_name_required` setting with a new `full_name_requirement` setting to allow more flexibility with the name field in the signup form. The new setting has 2 options, "Required at signup" and "Optional at signup", which are equivalent to the true/false possibilities of the old setting, and a third option "Hidden at signup" that hides the name field from the signup form, making it effectively optional too. New sites will have the "Hidden at signup" option as the default option, and existing site will continue to use the option that maps to their current configuration. Internal topic: t/136746. --- .../app/components/fullname-input.gjs | 8 +-- .../app/components/modal/create-account.hbs | 2 +- .../app/components/modal/create-account.js | 6 +- .../discourse/app/controllers/invites-show.js | 6 +- .../app/controllers/preferences/account.js | 2 +- .../discourse/app/controllers/signup.js | 6 +- .../discourse/app/mixins/name-validation.js | 4 +- .../discourse/app/templates/invites/show.hbs | 2 +- .../discourse/app/templates/signup.hbs | 2 +- .../tests/acceptance/create-account-test.js | 71 ++++++++++++++++++- .../tests/acceptance/invite-accept-test.js | 37 ++++++++-- .../discourse/tests/fixtures/site-fixtures.js | 2 + app/models/full_name_requirement.rb | 21 ++++++ app/serializers/site_serializer.rb | 10 +++ app/services/user_anonymizer.rb | 2 +- config/locales/client.en.yml | 4 ++ config/locales/server.en.yml | 2 +- config/site_settings.yml | 7 +- ...91732_change_full_name_required_setting.rb | 33 +++++++++ lib/discourse_dev/config.rb | 3 +- lib/tasks/admin.rake | 3 +- lib/validators/user_full_name_validator.rb | 4 +- .../user_full_name_validator_spec.rb | 4 +- .../api/schemas/json/site_response.json | 10 ++- .../services/anonymous_shadow_creator_spec.rb | 2 +- spec/services/user_anonymizer_spec.rb | 4 +- spec/system/social_authentication_spec.rb | 2 + 27 files changed, 217 insertions(+), 42 deletions(-) create mode 100644 app/models/full_name_requirement.rb create mode 100644 db/migrate/20241224191732_change_full_name_required_setting.rb diff --git a/app/assets/javascripts/discourse/app/components/fullname-input.gjs b/app/assets/javascripts/discourse/app/components/fullname-input.gjs index acf8a1c0bf4..6c41c9b1aa8 100644 --- a/app/assets/javascripts/discourse/app/components/fullname-input.gjs +++ b/app/assets/javascripts/discourse/app/components/fullname-input.gjs @@ -6,15 +6,9 @@ import TextField from "discourse/components/text-field"; import valueEntered from "discourse/helpers/value-entered"; import { i18n } from "discourse-i18n"; -export default class SidebarEditNavigationMenuTagsModal extends Component { +export default class FullnameInput extends Component { @service siteSettings; - get showFullname() { - return ( - this.siteSettings.full_name_required || this.siteSettings.enable_names - ); - } - get showFullnameInstructions() { return ( this.siteSettings.show_signup_form_full_name_instructions && diff --git a/app/assets/javascripts/discourse/app/components/modal/create-account.hbs b/app/assets/javascripts/discourse/app/components/modal/create-account.hbs index 7666fa6b341..4d52dfeea30 100644 --- a/app/assets/javascripts/discourse/app/components/modal/create-account.hbs +++ b/app/assets/javascripts/discourse/app/components/modal/create-account.hbs @@ -99,7 +99,7 @@ {{/if}} - {{#if this.fullnameRequired}} + {{#if (and this.showFullname this.fullnameRequired)}} - {{#if this.fullnameRequired}} + {{#if (and this.showFullname this.fullnameRequired)}} - {{#if this.fullnameRequired}} + {{#if (and this.showFullname this.fullnameRequired)}}