-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Profile image on user posts (redwood.master) #746
base: open-release/redwood.master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,4 @@ USER_INFO_COOKIE_NAME='' | |
SUPPORT_URL='' | ||
LEARNER_FEEDBACK_URL='' | ||
STAFF_FEEDBACK_URL='' | ||
ENABLE_PROFILE_IMAGE='' |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,14 +33,11 @@ import { ContentSelectors } from './constants'; | |
import { | ||
selectAreThreadsFiltered, | ||
selectEnableInContext, | ||
selectIsCourseAdmin, | ||
selectIsCourseStaff, | ||
selectIsPostingEnabled, | ||
selectIsUserLearner, | ||
selectPostThreadCount, | ||
selectUserHasModerationPrivileges, | ||
selectUserIsGroupTa, | ||
selectUserIsStaff, | ||
} from './selectors'; | ||
import fetchCourseConfig from './thunks'; | ||
|
||
|
@@ -220,12 +217,9 @@ export const useCurrentDiscussionTopic = () => { | |
|
||
export const useUserPostingEnabled = () => { | ||
const isPostingEnabled = useSelector(selectIsPostingEnabled); | ||
const isUserAdmin = useSelector(selectUserIsStaff); | ||
const userHasModerationPrivileges = useSelector(selectUserHasModerationPrivileges); | ||
const isUserGroupTA = useSelector(selectUserIsGroupTa); | ||
const isCourseAdmin = useSelector(selectIsCourseAdmin); | ||
const isCourseStaff = useSelector(selectIsCourseStaff); | ||
const isPrivileged = isUserAdmin || userHasModerationPrivileges || isUserGroupTA || isCourseAdmin || isCourseStaff; | ||
const isPrivileged = userHasModerationPrivileges || isUserGroupTA; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did we need to change it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any update on it? |
||
|
||
return (isPostingEnabled || isPrivileged); | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,11 +19,11 @@ const courseConfigApiUrl = getCourseConfigApiUrl(); | |
let store; | ||
let axiosMock; | ||
|
||
const generateApiResponse = (isPostingEnabled, isCourseAdmin = false) => ({ | ||
const generateApiResponse = (isPostingEnabled, hasModerationPrivileges = false) => ({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there any reason to change it? |
||
isPostingEnabled, | ||
hasModerationPrivileges: false, | ||
hasModerationPrivileges, | ||
isGroupTa: false, | ||
isCourseAdmin, | ||
isCourseAdmin: false, | ||
isCourseStaff: false, | ||
isUserAdmin: false, | ||
}); | ||
|
@@ -160,7 +160,7 @@ describe('Hooks', () => { | |
expect(queryByText('false')).toBeInTheDocument(); | ||
}); | ||
|
||
test('when posting is not disabled and Role is not Learner return true', async () => { | ||
test('when posting is disabled and Role is not Learner return true', async () => { | ||
axiosMock.onGet(`${courseConfigApiUrl}${courseId}/`) | ||
.reply(200, generateApiResponse(false, true)); | ||
await executeThunk(fetchCourseConfig(courseId), store.dispatch, store.getState); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ import PropTypes from 'prop-types'; | |
import { Avatar } from '@openedx/paragon'; | ||
import classNames from 'classnames'; | ||
|
||
import { getConfig } from '@edx/frontend-platform'; | ||
|
||
import { AvatarOutlineAndLabelColors } from '../../../../data/constants'; | ||
import { AuthorLabel } from '../../../common'; | ||
import { useAlertBannerVisible } from '../../../data/hooks'; | ||
|
@@ -15,6 +17,7 @@ const CommentHeader = ({ | |
closed, | ||
createdAt, | ||
lastEdit, | ||
postUsers, | ||
}) => { | ||
const colorClass = AvatarOutlineAndLabelColors[authorLabel]; | ||
const hasAnyAlert = useAlertBannerVisible({ | ||
|
@@ -24,6 +27,8 @@ const CommentHeader = ({ | |
closed, | ||
}); | ||
|
||
const profileImage = getConfig().ENABLE_PROFILE_IMAGE === 'true' && postUsers && Object.values(postUsers)[0].profile.image; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we simplify it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it’s better to leave it as is because it’s a more secure check. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think about this refactored option? const profileImage = getConfig()?.ENABLE_PROFILE_IMAGE === 'true' |
||
|
||
return ( | ||
<div className={classNames('d-flex flex-row justify-content-between', { | ||
'mt-2': hasAnyAlert, | ||
|
@@ -33,6 +38,7 @@ const CommentHeader = ({ | |
<Avatar | ||
className={`border-0 ml-0.5 mr-2.5 ${colorClass ? `outline-${colorClass}` : 'outline-anonymous'}`} | ||
alt={author} | ||
src={profileImage?.hasImage ? profileImage?.imageUrlSmall : undefined} | ||
style={{ | ||
width: '32px', | ||
height: '32px', | ||
|
@@ -61,6 +67,7 @@ CommentHeader.propTypes = { | |
editorUsername: PropTypes.string, | ||
reason: PropTypes.string, | ||
}), | ||
postUsers: PropTypes.shape({}).isRequired, | ||
}; | ||
|
||
CommentHeader.defaultProps = { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change it into empty string