-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #152 from edx/dsheraz/PROD-2506
feat: add user summary v2
- Loading branch information
Showing
10 changed files
with
399 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import TogglePasswordStatus from './TogglePasswordStatus'; | ||
import ResetPassword from './ResetPassword'; | ||
import PasswordHistory from './PasswordHistory'; | ||
|
||
export default function AccountActions({ userData, changeHandler }) { | ||
return ( | ||
<> | ||
<h3 className="w-100">Account Actions</h3> | ||
<TogglePasswordStatus | ||
username={userData.username} | ||
passwordStatus={userData.passwordStatus} | ||
changeHandler={changeHandler} | ||
/> | ||
<ResetPassword | ||
email={userData.email} | ||
changeHandler={changeHandler} | ||
/> | ||
<PasswordHistory | ||
passwordStatus={userData.passwordStatus} | ||
/> | ||
</> | ||
); | ||
} | ||
|
||
AccountActions.propTypes = { | ||
userData: PropTypes.shape({ | ||
username: PropTypes.string, | ||
email: PropTypes.string, | ||
passwordStatus: PropTypes.shape({ | ||
status: PropTypes.string, | ||
passwordToggleHistory: PropTypes.arrayOf(PropTypes.shape( | ||
{ | ||
created: PropTypes.string.isRequired, | ||
comment: PropTypes.string.isRequired, | ||
disabled: PropTypes.bool.isRequired, | ||
createdBy: PropTypes.string.isRequired, | ||
}, | ||
)), | ||
}), | ||
}).isRequired, | ||
changeHandler: PropTypes.func.isRequired, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { mount } from 'enzyme'; | ||
import React from 'react'; | ||
|
||
import AccountActions from './AccountActions'; | ||
import UserSummaryData from '../data/test/userSummary'; | ||
|
||
describe('Account Actions Component Tests', () => { | ||
let wrapper; | ||
|
||
beforeEach(() => { | ||
wrapper = mount(<AccountActions {...UserSummaryData} />); | ||
}); | ||
|
||
afterEach(() => { | ||
wrapper.unmount(); | ||
}); | ||
|
||
it('Action Buttons rendered', () => { | ||
const passwordHistoryButton = wrapper.find('button#toggle-password-history'); | ||
const toggleUserStatusButton = wrapper.find('button#toggle-password'); | ||
const passwordResetEmailButton = wrapper.find('button#reset-password'); | ||
|
||
expect(passwordHistoryButton.text()).toEqual('Show History'); | ||
expect(passwordHistoryButton.disabled).toBeFalsy(); | ||
|
||
expect(toggleUserStatusButton.text()).toEqual('Disable User'); | ||
expect(toggleUserStatusButton.disabled).toBeFalsy(); | ||
|
||
expect(passwordResetEmailButton.text()).toEqual('Reset Password'); | ||
expect(passwordResetEmailButton.disabled).toBeFalsy(); | ||
|
||
expect(wrapper.find('h3').text()).toEqual('Account Actions'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { formatDate } from '../../utils'; | ||
import { getAccountActivationUrl } from '../data/urls'; | ||
import IdentityVerificationStatus from '../IdentityVerificationStatus'; | ||
import OnboardingStatus from '../OnboardingStatus'; | ||
import AccountActions from '../account-actions/AccountActions'; | ||
|
||
export default function UserSummary({ | ||
userData, | ||
changeHandler, | ||
}) { | ||
return ( | ||
<section className="mb-3"> | ||
<div className="d-flex flex-row flex-wrap"> | ||
<div className="col-sm-6"> | ||
|
||
<div id="account-table" className="flex-column pr-4 m-3 card account-info"> | ||
<h3>Account Details</h3> | ||
<table> | ||
<tbody> | ||
|
||
<tr> | ||
<th>Full Name</th> | ||
<td>{userData.name}</td> | ||
</tr> | ||
|
||
<tr> | ||
<th>Username</th> | ||
<td>{userData.username}</td> | ||
</tr> | ||
|
||
<tr> | ||
<th>LMS User ID</th> | ||
<td>{userData.id}</td> | ||
</tr> | ||
|
||
<tr> | ||
<th>Email</th> | ||
<td>{userData.email}</td> | ||
</tr> | ||
|
||
<tr> | ||
<th>{!userData.isActive ? 'Activation Key/Link' : 'Active'}</th> | ||
<td> | ||
{ | ||
// eslint-disable-next-line no-nested-ternary | ||
userData.isActive | ||
? 'yes' | ||
: ( | ||
userData.activationKey !== null | ||
? <a href={getAccountActivationUrl(userData.activationKey)} rel="noopener noreferrer" target="_blank" className="word_break">{userData.activationKey}</a> | ||
: 'N/A' | ||
) | ||
} | ||
</td> | ||
</tr> | ||
|
||
<tr> | ||
<th>Country</th> | ||
<td>{userData.country}</td> | ||
</tr> | ||
|
||
<tr> | ||
<th>Join Date/Time</th> | ||
<td>{formatDate(userData.dateJoined)}</td> | ||
</tr> | ||
|
||
<tr> | ||
<th>Last Login</th> | ||
<td>{formatDate(userData.lastLogin)}</td> | ||
</tr> | ||
|
||
<tr> | ||
<th>Password Status</th> | ||
<td>{userData.passwordStatus.status}</td> | ||
</tr> | ||
|
||
</tbody> | ||
|
||
</table> | ||
</div> | ||
</div> | ||
<div className="col-sm-6"> | ||
<div className="row p-4 m-3 account-actions" id="account-actions"> | ||
<AccountActions userData={userData} changeHandler={changeHandler} /> | ||
</div> | ||
<div className="flex-column"> | ||
<IdentityVerificationStatus username={userData.username} /> | ||
<OnboardingStatus username={userData.username} /> | ||
</div> | ||
</div> | ||
</div> | ||
</section> | ||
); | ||
} | ||
|
||
UserSummary.propTypes = { | ||
userData: PropTypes.shape({ | ||
name: PropTypes.string, | ||
username: PropTypes.string, | ||
id: PropTypes.number, | ||
email: PropTypes.string, | ||
activationKey: PropTypes.string, | ||
isActive: PropTypes.bool, | ||
country: PropTypes.string, | ||
dateJoined: PropTypes.string, | ||
lastLogin: PropTypes.string, | ||
passwordStatus: PropTypes.shape({ | ||
status: PropTypes.string, | ||
passwordToggleHistory: PropTypes.arrayOf(PropTypes.shape( | ||
{ | ||
created: PropTypes.string.isRequired, | ||
comment: PropTypes.string.isRequired, | ||
disabled: PropTypes.bool.isRequired, | ||
createdBy: PropTypes.string.isRequired, | ||
}, | ||
)), | ||
}), | ||
}).isRequired, | ||
changeHandler: PropTypes.func.isRequired, | ||
}; |
Oops, something went wrong.