Skip to content

feat: Profile image on user posts (quince.master) #575

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

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/discussions/post-comments/comments/comment/Comment.jsx
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ const Comment = ({
const {
id, parentId, childCount, abuseFlagged, endorsed, threadId, endorsedAt, endorsedBy, endorsedByLabel, renderedBody,
voted, following, voteCount, authorLabel, author, createdAt, lastEdit, rawBody, closed, closedBy, closeReason,
editByLabel, closedByLabel,
editByLabel, closedByLabel, users: postUsers,
} = comment;
const intl = useIntl();
const hasChildren = childCount > 0;
@@ -203,6 +203,7 @@ const Comment = ({
closed={closed}
createdAt={createdAt}
lastEdit={lastEdit}
postUsers={postUsers}
/>
{isEditing ? (
<CommentEditor
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ const CommentHeader = ({
closed,
createdAt,
lastEdit,
postUsers,
}) => {
const colorClass = AvatarOutlineAndLabelColors[authorLabel];
const hasAnyAlert = useAlertBannerVisible({
@@ -25,6 +26,8 @@ const CommentHeader = ({
closed,
});

const profileImage = postUsers && Object.values(postUsers)[0].profile.image;

return (
<div className={classNames('d-flex flex-row justify-content-between', {
'mt-2': hasAnyAlert,
@@ -34,6 +37,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',
@@ -62,6 +66,7 @@ CommentHeader.propTypes = {
editorUsername: PropTypes.string,
reason: PropTypes.string,
}),
postUsers: PropTypes.shape({}).isRequired,
};

CommentHeader.defaultProps = {
3 changes: 2 additions & 1 deletion src/discussions/posts/post/Post.jsx
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ const Post = ({ handleAddResponseButton }) => {
const {
topicId, abuseFlagged, closed, pinned, voted, hasEndorsed, following, closedBy, voteCount, groupId, groupName,
closeReason, authorLabel, type: postType, author, title, createdAt, renderedBody, lastEdit, editByLabel,
closedByLabel,
closedByLabel, users: postUsers,
} = useSelector(selectThread(postId));
const intl = useIntl();
const location = useLocation();
@@ -183,6 +183,7 @@ const Post = ({ handleAddResponseButton }) => {
lastEdit={lastEdit}
postType={postType}
title={title}
postUsers={postUsers}
/>
<div className="d-flex mt-14px text-break font-style text-primary-500">
<HTMLLoader htmlNode={renderedBody} componentId="post" cssClassName="html-loader" testId={postId} />
10 changes: 8 additions & 2 deletions src/discussions/posts/post/PostHeader.jsx
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ import { useAlertBannerVisible } from '../../data/hooks';
import messages from './messages';

export const PostAvatar = React.memo(({
author, postType, authorLabel, fromPostLink, read,
author, postType, authorLabel, fromPostLink, read, postUsers,
}) => {
const outlineColor = AvatarOutlineAndLabelColors[authorLabel];

@@ -37,6 +37,8 @@ export const PostAvatar = React.memo(({
return spacing;
}, [postType]);

const profileImage = postUsers && Object.values(postUsers)[0].profile.image;

return (
<div className={avatarSpacing}>
{postType === ThreadType.QUESTION && (
@@ -58,6 +60,7 @@ export const PostAvatar = React.memo(({
height: avatarSize,
width: avatarSize,
}}
src={profileImage?.hasImage ? profileImage?.imageUrlSmall : undefined}
alt={author}
/>
</div>
@@ -70,6 +73,7 @@ PostAvatar.propTypes = {
authorLabel: PropTypes.string,
fromPostLink: PropTypes.bool,
read: PropTypes.bool,
postUsers: PropTypes.shape({}).isRequired,
};

PostAvatar.defaultProps = {
@@ -89,6 +93,7 @@ const PostHeader = ({
title,
postType,
preview,
postUsers,
}) => {
const intl = useIntl();
const showAnsweredBadge = preview && hasEndorsed && postType === ThreadType.QUESTION;
@@ -100,7 +105,7 @@ const PostHeader = ({
return (
<div className={classNames('d-flex flex-fill mw-100', { 'mt-10px': hasAnyAlert && !preview })}>
<div className="flex-shrink-0">
<PostAvatar postType={postType} author={author} authorLabel={authorLabel} />
<PostAvatar postType={postType} author={author} authorLabel={authorLabel} postUsers={postUsers} />
</div>
<div className="align-items-center d-flex flex-row">
<div className="d-flex flex-column justify-content-start mw-100">
@@ -150,6 +155,7 @@ PostHeader.propTypes = {
reason: PropTypes.string,
}),
closed: PropTypes.bool,
postUsers: PropTypes.shape({}).isRequired,
};

PostHeader.defaultProps = {
2 changes: 2 additions & 0 deletions src/discussions/posts/post/PostLink.jsx
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@ const PostLink = ({
const {
topicId, hasEndorsed, type, author, authorLabel, abuseFlagged, abuseFlaggedCount, read, commentCount,
unreadCommentCount, id, pinned, previewBody, title, voted, voteCount, following, groupId, groupName, createdAt,
users: postUsers,
} = useSelector(selectThread(postId));
const linkUrl = discussionsPath(Routes.COMMENTS.PAGES[page], {
0: enableInContextSidebar ? 'in-context' : undefined,
@@ -84,6 +85,7 @@ const PostLink = ({
authorLabel={authorLabel}
fromPostLink
read={isPostRead}
postUsers={postUsers}
/>
<div className="d-flex flex-column flex-fill" style={{ minWidth: 0 }}>
<div className="d-flex flex-column justify-content-start mw-100 flex-fill" style={{ marginBottom: '-3px' }}>