Skip to content

Commit

Permalink
Revert "feat: hide username from profile page"
Browse files Browse the repository at this point in the history
  • Loading branch information
attiyaIshaque authored Apr 8, 2024
1 parent d06b6d7 commit ca13000
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 910 deletions.
8 changes: 1 addition & 7 deletions src/profile/ProfilePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import UsernameDescription from './UsernameDescription';
import PageLoading from './PageLoading';
import Banner from './Banner';
import LearningGoal from './forms/LearningGoal';
import { getFirstAndLastNameInitial } from './utils';

// Selectors
import { profilePageSelector } from './data/selectors';
Expand Down Expand Up @@ -125,12 +124,9 @@ class ProfilePage extends React.Component {
renderHeadingLockup() {
const { dateJoined } = this.props;

const autoGeneratedUsernameEnabled = !!this.props.autoGeneratedUsernameEnabled;
return (
<span data-hj-suppress>
<h1 className="h2 mb-0 font-weight-bold text-truncate">
{!autoGeneratedUsernameEnabled ? this.props.params.username : getFirstAndLastNameInitial(this.props.name)}
</h1>
<h1 className="h2 mb-0 font-weight-bold text-truncate">{this.props.params.username}</h1>
<DateJoined date={dateJoined} />
{this.isYOBDisabled() && <UsernameDescription />}
<hr className="d-none d-md-block" />
Expand Down Expand Up @@ -335,7 +331,6 @@ ProfilePage.propTypes = {
// Account data
requiresParentalConsent: PropTypes.bool,
dateJoined: PropTypes.string,
autoGeneratedUsernameEnabled: PropTypes.bool,

// Bio form data
bio: PropTypes.string,
Expand Down Expand Up @@ -428,7 +423,6 @@ ProfilePage.defaultProps = {
courseCertificates: null,
requiresParentalConsent: null,
dateJoined: null,
autoGeneratedUsernameEnabled: false,
};

export default connect(
Expand Down
21 changes: 0 additions & 21 deletions src/profile/ProfilePage.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,27 +113,6 @@ describe('<ProfilePage />', () => {
expect(tree).toMatchSnapshot();
});

it('renders the component without the username field and displays the full name when hide_username is true', () => {
const storeData = JSON.parse(JSON.stringify(storeMocks.viewOwnProfile));
storeData.profilePage.account.autoGeneratedUsernameEnabled = true;
storeData.profilePage.account.name = 'Test User';

const contextValue = {
authenticatedUser: { userId: 123, username: 'staff', administrator: true },
config: getConfig(),
};

const component = (
<ProfilePageWrapper
contextValue={contextValue}
store={mockStore(storeData)}
/>
);

const { container: tree } = render(component);
expect(tree).toMatchSnapshot();
});

it('viewing other profile with all fields', () => {
const contextValue = {
authenticatedUser: { userId: 123, username: 'staff', administrator: true },
Expand Down
Loading

0 comments on commit ca13000

Please sign in to comment.