From 8f3a13122f55eac240cf0b233ea2865ebfa2db71 Mon Sep 17 00:00:00 2001 From: Scott Bishel Date: Tue, 13 Aug 2024 07:53:34 -0600 Subject: [PATCH] MM-58793 Apply EnableUserCreation to signup.tsx (#27692) * update text, apply EnableUserCreation to ui * update text and add unit test * Update webapp/channels/src/components/admin_console/admin_definition.tsx Co-authored-by: Carrie Warner (Mattermost) <74422101+cwarnermm@users.noreply.github.com> * Update webapp/channels/src/components/admin_console/admin_definition.tsx Co-authored-by: Carrie Warner (Mattermost) <74422101+cwarnermm@users.noreply.github.com> * Update webapp/channels/src/i18n/en.json Co-authored-by: Carrie Warner (Mattermost) <74422101+cwarnermm@users.noreply.github.com> * Update webapp/channels/src/i18n/en.json Co-authored-by: Carrie Warner (Mattermost) <74422101+cwarnermm@users.noreply.github.com> --------- Co-authored-by: Mattermost Build Co-authored-by: Carrie Warner (Mattermost) <74422101+cwarnermm@users.noreply.github.com> --- .../admin_console/admin_definition.tsx | 4 +- .../channels/src/components/login/login.tsx | 4 +- .../signup/__snapshots__/signup.test.tsx.snap | 77 +++++++++++++++++++ .../src/components/signup/signup.test.tsx | 11 +++ .../channels/src/components/signup/signup.tsx | 14 ++-- webapp/channels/src/i18n/en.json | 4 +- 6 files changed, 103 insertions(+), 11 deletions(-) diff --git a/webapp/channels/src/components/admin_console/admin_definition.tsx b/webapp/channels/src/components/admin_console/admin_definition.tsx index 8c94880fcb..e868e4d625 100644 --- a/webapp/channels/src/components/admin_console/admin_definition.tsx +++ b/webapp/channels/src/components/admin_console/admin_definition.tsx @@ -3046,7 +3046,7 @@ const AdminDefinition: AdminDefinitionType = { type: 'bool', key: 'TeamSettings.EnableUserCreation', label: defineMessage({id: 'admin.team.userCreationTitle', defaultMessage: 'Enable Account Creation: '}), - help_text: defineMessage({id: 'admin.team.userCreationDescription', defaultMessage: 'When false, the ability to create accounts is disabled. The create account button displays error when pressed.'}), + help_text: defineMessage({id: 'admin.team.userCreationDescription', defaultMessage: 'When false, the ability to create accounts is disabled, and selecting Create Account displays an error. Applies to Email, OpenID Connect, and OAuth 2.0 user account authentication.'}), isDisabled: it.not(it.userHasWritePermissionOnResource(RESOURCE_KEYS.AUTHENTICATION.SIGNUP)), }, { @@ -3077,7 +3077,7 @@ const AdminDefinition: AdminDefinitionType = { type: 'bool', key: 'TeamSettings.EnableOpenServer', label: defineMessage({id: 'admin.team.openServerTitle', defaultMessage: 'Enable Open Server: '}), - help_text: defineMessage({id: 'admin.team.openServerDescription', defaultMessage: 'When true, anyone can signup for a user account on this server without the need to be invited.'}), + help_text: defineMessage({id: 'admin.team.openServerDescription', defaultMessage: 'When true, anyone can sign up for a user account on this server without the need to be invited. Applies to Email-based signups only.'}), isDisabled: it.not(it.userHasWritePermissionOnResource(RESOURCE_KEYS.AUTHENTICATION.SIGNUP)), }, { diff --git a/webapp/channels/src/components/login/login.tsx b/webapp/channels/src/components/login/login.tsx index 4820fb9e3c..042b1cab3d 100644 --- a/webapp/channels/src/components/login/login.tsx +++ b/webapp/channels/src/components/login/login.tsx @@ -87,6 +87,7 @@ const Login = ({onCustomizeHeader}: LoginProps) => { EnableSignUpWithGoogle, EnableSignUpWithOpenId, EnableOpenServer, + EnableUserCreation, LdapLoginFieldName, GitLabButtonText, GitLabButtonColor, @@ -125,10 +126,11 @@ const Login = ({onCustomizeHeader}: LoginProps) => { const enableCustomBrand = EnableCustomBrand === 'true'; const enableLdap = EnableLdap === 'true'; const enableOpenServer = EnableOpenServer === 'true'; + const enableUserCreation = EnableUserCreation === 'true'; const enableSaml = EnableSaml === 'true'; const enableSignInWithEmail = EnableSignInWithEmail === 'true'; const enableSignInWithUsername = EnableSignInWithUsername === 'true'; - const enableSignUpWithEmail = EnableSignUpWithEmail === 'true'; + const enableSignUpWithEmail = enableUserCreation && EnableSignUpWithEmail === 'true'; const enableSignUpWithGitLab = EnableSignUpWithGitLab === 'true'; const enableSignUpWithGoogle = EnableSignUpWithGoogle === 'true'; const enableSignUpWithOffice365 = EnableSignUpWithOffice365 === 'true'; diff --git a/webapp/channels/src/components/signup/__snapshots__/signup.test.tsx.snap b/webapp/channels/src/components/signup/__snapshots__/signup.test.tsx.snap index 103a6c19f3..2584917364 100644 --- a/webapp/channels/src/components/signup/__snapshots__/signup.test.tsx.snap +++ b/webapp/channels/src/components/signup/__snapshots__/signup.test.tsx.snap @@ -1,5 +1,82 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`components/signup/Signup should match snapshot for all signup options enabled with EnableUserCreaton disabled 1`] = ` +
+
+
+

+ Let’s get started +

+

+ Create your Mattermost account to start collaborating with your team +

+
+ +
+
+
+ +
+
+

+ Create your account with one of the following: +

+
+ } + id="ldap" + key="ldap" + label="AD/LDAP Credentials" + onClick={[Function]} + url="/login?extra=create_ldap" + /> + } + id="saml" + key="saml" + label="SAML" + onClick={[Function]} + url="/login/sso/saml?action=signup" + /> +
+
+
+
+
+
+`; + exports[`components/signup/Signup should match snapshot for all signup options enabled with isLicensed disabled 1`] = `
{ EnableSignUpWithGoogle: 'true', EnableSignUpWithOpenId: 'true', EnableOpenServer: 'true', + EnableUserCreation: 'true', LdapLoginFieldName: '', GitLabButtonText: '', GitLabButtonColor: '', @@ -189,6 +190,16 @@ describe('components/signup/Signup', () => { expect(wrapper).toMatchSnapshot(); }); + it('should match snapshot for all signup options enabled with EnableUserCreaton disabled', () => { + mockConfig.EnableUserCreation = 'false'; + + const wrapper = shallow( + , + ); + + expect(wrapper).toMatchSnapshot(); + }); + it('should create user, log in and redirect to invite teamname', async () => { mockLocation.search = 'd=%7B"name"%3A"teamName"%7D'; diff --git a/webapp/channels/src/components/signup/signup.tsx b/webapp/channels/src/components/signup/signup.tsx index f78336292b..7f90ed3b77 100644 --- a/webapp/channels/src/components/signup/signup.tsx +++ b/webapp/channels/src/components/signup/signup.tsx @@ -85,6 +85,7 @@ const Signup = ({onCustomizeHeader}: SignupProps) => { const config = useSelector(getConfig); const { EnableOpenServer, + EnableUserCreation, NoAccounts, EnableSignUpWithEmail, EnableSignUpWithGitLab, @@ -117,17 +118,18 @@ const Signup = ({onCustomizeHeader}: SignupProps) => { const isLicensed = IsLicensed === 'true'; const enableOpenServer = EnableOpenServer === 'true'; + const enableUserCreation = EnableUserCreation === 'true'; const noAccounts = NoAccounts === 'true'; - const enableSignUpWithEmail = EnableSignUpWithEmail === 'true'; - const enableSignUpWithGitLab = EnableSignUpWithGitLab === 'true'; - const enableSignUpWithGoogle = EnableSignUpWithGoogle === 'true'; - const enableSignUpWithOffice365 = EnableSignUpWithOffice365 === 'true'; - const enableSignUpWithOpenId = EnableSignUpWithOpenId === 'true'; + const enableSignUpWithEmail = enableUserCreation && EnableSignUpWithEmail === 'true'; + const enableSignUpWithGitLab = enableUserCreation && EnableSignUpWithGitLab === 'true'; + const enableSignUpWithGoogle = enableUserCreation && EnableSignUpWithGoogle === 'true'; + const enableSignUpWithOffice365 = enableUserCreation && EnableSignUpWithOffice365 === 'true'; + const enableSignUpWithOpenId = enableUserCreation && EnableSignUpWithOpenId === 'true'; const enableLDAP = EnableLdap === 'true'; const enableSAML = EnableSaml === 'true'; const enableCustomBrand = EnableCustomBrand === 'true'; - const noOpenServer = !inviteId && !token && !enableOpenServer && !noAccounts; + const noOpenServer = !inviteId && !token && !enableOpenServer && !noAccounts && !enableUserCreation; const [email, setEmail] = useState(parsedEmail ?? ''); const [name, setName] = useState(''); diff --git a/webapp/channels/src/i18n/en.json b/webapp/channels/src/i18n/en.json index 9ae773205d..aa2cb81dbc 100644 --- a/webapp/channels/src/i18n/en.json +++ b/webapp/channels/src/i18n/en.json @@ -2655,7 +2655,7 @@ "admin.team.maxUsersExample": "E.g.: \"25\"", "admin.team.maxUsersTitle": "Max Users Per Team:", "admin.team.noBrandImage": "No brand image uploaded", - "admin.team.openServerDescription": "When true, anyone can signup for a user account on this server without the need to be invited.", + "admin.team.openServerDescription": "When true, anyone can sign up for a user account on this server without the need to be invited. Applies to Email-based signups only.", "admin.team.openServerTitle": "Enable Open Server: ", "admin.team.refreshPostStatsRunTimeDescription": "Set the server time for updating the user post statistics, including each user's total post count and the timestamp of their most recent post. Must be a 24-hour time stamp in the form HH:MM based on the local time of the server.", "admin.team.refreshPostStatsRunTimeExample": "E.g.: \"00:00\"", @@ -2678,7 +2678,7 @@ "admin.team.teammateNameDisplay": "Teammate Name Display:", "admin.team.teammateNameDisplayDesc": "Set how to display users' names in posts and the Direct Messages list.", "admin.team.uploadDesc": "Customize your user experience by adding a custom image to your login screen. Recommended maximum image size is less than 2 MB.", - "admin.team.userCreationDescription": "When false, the ability to create accounts is disabled. The create account button displays error when pressed.", + "admin.team.userCreationDescription": "When false, the ability to create accounts is disabled, and selecting Create Account displays an error. Applies to Email, OpenID Connect, and OAuth 2.0 user account authentication.", "admin.team.userCreationTitle": "Enable Account Creation: ", "admin.trial_banner.trial-request.error": "Trial license could not be retrieved. Visit {trialInfoLink} to request a license.", "admin.true": "True",