diff --git a/src/login/LoginPage.jsx b/src/login/LoginPage.jsx
index e3fdd29f2f..0f4a4604e8 100644
--- a/src/login/LoginPage.jsx
+++ b/src/login/LoginPage.jsx
@@ -166,6 +166,7 @@ class LoginPage extends React.Component {
const isInstitutionAuthActive = !!secondaryProviders.length && !currentProvider;
const isSocialAuthActive = !!providers.length && !currentProvider;
const isEnterpriseLoginDisabled = getConfig().DISABLE_ENTERPRISE_LOGIN;
+ const ThirdPartyAuthPreloader = isSocialAuthActive || (isEnterpriseLoginDisabled && isInstitutionAuthActive);
return (
<>
@@ -183,7 +184,7 @@ class LoginPage extends React.Component {
)}
- {thirdPartyAuthApiStatus === PENDING_STATE ? (
+ {thirdPartyAuthApiStatus === PENDING_STATE && ThirdPartyAuthPreloader ? (
) : (
<>
diff --git a/src/register/components/ThirdPartyAuth.jsx b/src/register/components/ThirdPartyAuth.jsx
index 3a8682488c..52283d89dc 100644
--- a/src/register/components/ThirdPartyAuth.jsx
+++ b/src/register/components/ThirdPartyAuth.jsx
@@ -25,6 +25,7 @@ const ThirdPartyAuth = (props) => {
const isInstitutionAuthActive = !!secondaryProviders.length && !currentProvider;
const isSocialAuthActive = !!providers.length && !currentProvider;
const isEnterpriseLoginDisabled = getConfig().DISABLE_ENTERPRISE_LOGIN;
+ const ThirdPartyAuthPreloader = isSocialAuthActive || (isEnterpriseLoginDisabled && isInstitutionAuthActive);
return (
<>
@@ -34,7 +35,7 @@ const ThirdPartyAuth = (props) => {
)}
- {thirdPartyAuthApiStatus === PENDING_STATE ? (
+ {thirdPartyAuthApiStatus === PENDING_STATE && ThirdPartyAuthPreloader ? (
) : (
<>
diff --git a/src/register/registrationFields/UsernameField.jsx b/src/register/registrationFields/UsernameField.jsx
new file mode 100644
index 0000000000..52aa7d0d5c
--- /dev/null
+++ b/src/register/registrationFields/UsernameField.jsx
@@ -0,0 +1,74 @@
+import React from 'react';
+
+import { injectIntl } from '@edx/frontend-platform/i18n';
+import { Button, Icon, IconButton } from '@edx/paragon';
+import { Close } from '@edx/paragon/icons';
+import PropTypes, { string } from 'prop-types';
+
+import { FormGroup } from '../../common-components';
+import messages from '../messages';
+
+const UsernameField = (props) => {
+ const {
+ intl, handleSuggestionClick, handleUsernameSuggestionClose, usernameSuggestions, errorMessage,
+ } = props;
+ let className = 'suggested-usernames-wrapper';
+ let suggestedUsernameDiv = <>>;
+ let iconButton = <>>;
+ const suggestedUsernames = () => (
+
+
{intl.formatMessage(messages['registration.username.suggestion.label'])}
+
+ {usernameSuggestions.map((username, index) => (
+
+ ))}
+
+ {iconButton}
+
+ );
+ if (usernameSuggestions.length > 0 && errorMessage && props.value === ' ') {
+ className = 'suggested-username-with-error';
+ iconButton = handleUsernameSuggestionClose()} variant="black" size="sm" className="suggested-username-close-button" />;
+ suggestedUsernameDiv = suggestedUsernames();
+ } else if (usernameSuggestions.length > 0 && props.value === ' ') {
+ className = 'suggested-username';
+ iconButton = handleUsernameSuggestionClose()} variant="black" size="sm" className="suggested-username-close-button" />;
+ suggestedUsernameDiv = suggestedUsernames();
+ } else if (usernameSuggestions.length > 0 && errorMessage) {
+ suggestedUsernameDiv = suggestedUsernames();
+ }
+ return (
+
+ {suggestedUsernameDiv}
+
+ );
+};
+
+UsernameField.defaultProps = {
+ usernameSuggestions: [],
+ errorMessage: '',
+ autoComplete: null,
+};
+
+UsernameField.propTypes = {
+ usernameSuggestions: PropTypes.arrayOf(string),
+ handleSuggestionClick: PropTypes.func.isRequired,
+ handleUsernameSuggestionClose: PropTypes.func.isRequired,
+ errorMessage: PropTypes.string,
+ intl: PropTypes.objectOf(PropTypes.object).isRequired,
+ name: PropTypes.string.isRequired,
+ value: PropTypes.string.isRequired,
+ autoComplete: PropTypes.string,
+};
+
+export default injectIntl(UsernameField);