Skip to content

Commit 94ab43c

Browse files
committed
fix issue #4249
1 parent e8aab36 commit 94ab43c

File tree

5 files changed

+37
-19
lines changed

5 files changed

+37
-19
lines changed

src/config/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const LOAD_USER_SUCCESS = 'LOAD_USER_SUCCESS'
88
export const LOAD_USER_FAILURE = 'LOAD_USER_FAILURE'
99

1010
export const LOAD_USER_CREDENTIAL = 'LOAD_USER_CREDENTIAL'
11+
export const LOAD_USER_CREDENTIAL_PENDING = 'LOAD_USER_CREDENTIAL_PENDING'
1112
export const LOAD_USER_CREDENTIAL_SUCCESS = 'LOAD_USER_CREDENTIAL_SUCCESS'
1213
export const LOAD_USER_CREDENTIAL_FAILURE = 'LOAD_USER_CREDENTIAL_FAILURE'
1314

src/reducers/loadUser.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import _ from 'lodash'
22
import {
33
LOAD_USER_SUCCESS,
44
LOAD_USER_FAILURE,
5+
LOAD_USER_CREDENTIAL_PENDING,
56
LOAD_USER_CREDENTIAL_SUCCESS,
7+
LOAD_USER_CREDENTIAL_FAILURE,
68
LOAD_ORG_CONFIG_SUCCESS,
79
LOAD_ORG_CONFIG_FAILURE,
810
SAVE_PROFILE_PHOTO_SUCCESS,
@@ -19,10 +21,19 @@ export const initialState = {
1921
export default function(state = initialState, action) {
2022
switch (action.type) {
2123

24+
case LOAD_USER_CREDENTIAL_PENDING:
25+
return Object.assign({}, state, {
26+
isLoadingCredential: true,
27+
})
2228
case LOAD_USER_CREDENTIAL_SUCCESS:
2329
return Object.assign({}, state, {
30+
isLoadingCredential: false,
2431
credential: action.payload.credential
2532
})
33+
case LOAD_USER_CREDENTIAL_FAILURE:
34+
return Object.assign({}, state, {
35+
isLoadingCredential: false,
36+
})
2637
case LOAD_USER_SUCCESS:
2738
return Object.assign({}, state, {
2839
isLoading : false,

src/routes/settings/routes/system/components/ChangeEmailForm.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class ChangeEmailForm extends React.Component {
9898
}
9999

100100
render() {
101-
const {disabled, settings, checkingEmail, checkedEmail, isEmailAvailable, isEmailChanging, emailSubmitted} = this.props
101+
const {usingSsoService, settings, checkingEmail, checkedEmail, isEmailAvailable, isEmailChanging, emailSubmitted} = this.props
102102
const { currentEmail, isValid, isFocused } = this.state
103103
const currentEmailAvailable = checkedEmail === currentEmail && isEmailAvailable
104104
const isCheckingCurrentEmail = checkingEmail === currentEmail
@@ -140,7 +140,7 @@ class ChangeEmailForm extends React.Component {
140140
validationErrors={{
141141
isEmail: 'Provide a correct email'
142142
}}
143-
disabled={disabled ||isEmailChanging || !hasPermission(PERMISSIONS.UPDATE_USER_EMAIL)}
143+
disabled={usingSsoService || isEmailChanging || !hasPermission(PERMISSIONS.UPDATE_USER_EMAIL)}
144144
ref={(ref) => this.emailRef = ref}
145145
/>
146146
{ isFocused && isCheckingCurrentEmail && (
@@ -174,7 +174,7 @@ class ChangeEmailForm extends React.Component {
174174

175175
ChangeEmailForm.propTypes = {
176176
email: PropTypes.string,
177-
disabled: PropTypes.bool,
177+
usingSsoService: PropTypes.bool,
178178
onSubmit: PropTypes.func.isRequired,
179179
checkingEmail: PropTypes.string,
180180
checkedEmail: PropTypes.string,

src/routes/settings/routes/system/components/SystemSettingsForm.jsx

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,28 +40,33 @@ class SystemSettingsForm extends Component {
4040
checkEmailAvailability={checkEmailAvailability}
4141
onSubmit={(email) => changeEmail(email)}
4242
{...systemSettings}
43-
disabled={usingSsoService? true: systemSettings.disabled === true}
43+
usingSsoService={usingSsoService}
4444
/>
4545

46-
{usingSsoService ? <div styleName="error-message">
47-
Since you joined Topcoder using your &lt;SSO Service&gt; account,
48-
any email updates will need to be handled by logging in to
49-
your &lt;SSO Service&gt; account.
50-
</div>: null}
46+
{usingSsoService && (
47+
<div styleName="error-message">
48+
Since you joined Topcoder using your &lt;SSO Service&gt; account,
49+
any email updates will need to be handled by logging in to
50+
your &lt;SSO Service&gt; account.
51+
</div>
52+
)}
5153
</div>
5254

53-
{!usingSsoService ?
55+
{!usingSsoService&& (
5456
<div styleName="section-heading">
5557
Retrieve or change your password
56-
</div>: null}
58+
</div>
59+
)}
5760

58-
{!usingSsoService ? <div className="form">
59-
<ChangePasswordForm
60-
onSubmit={(data) => changePassword(data)}
61-
onReset={() => resetPassword()}
62-
{...systemSettings}
63-
/>
64-
</div>: null}
61+
{!usingSsoService && (
62+
<div className="form">
63+
<ChangePasswordForm
64+
onSubmit={(data) => changePassword(data)}
65+
onReset={() => resetPassword()}
66+
{...systemSettings}
67+
/>
68+
</div>
69+
)}
6570
</div>
6671
)
6772
}

src/routes/settings/routes/system/containers/SystemSettingsContainer.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { requiresAuthentication } from '../../../../../components/AuthenticatedC
1212
import SystemSettingsForm from '../components/SystemSettingsForm'
1313
import './SystemSettingsContainer.scss'
1414

15-
const enhance = spinnerWhileLoading(props => !props.systemSettings.isLoading)
15+
const enhance = spinnerWhileLoading(props => !props.systemSettings.isLoading && !props.isLoadingCredential)
1616
const FormEnhanced = enhance(SystemSettingsForm)
1717

1818
class SystemSettingsContainer extends Component {
@@ -49,6 +49,7 @@ const SystemSettingsContainerWithAuth = requiresAuthentication(SystemSettingsCon
4949
const mapStateToProps = ({ settings, loadUser }) => ({
5050
systemSettings: settings.system,
5151
user: loadUser.user,
52+
isLoadingCredential: loadUser.isLoadingCredential,
5253
usingSsoService: _.get(loadUser, 'credential.hasPassword', false) === false,
5354
})
5455

0 commit comments

Comments
 (0)