* chore: configure WDYR for react profiling * perf: reduced post content re-rendering * perf: post content view and it child optimization * perf: add memoization in post editor * perf: add memoization in postCommnetsView * perf: improved endorsed comment view rendering * perf: improved re-rendering in reply component * fix: uncomment questionType commentsView * fix: removed console errors in postContent area * perf: reduced postType and postId dependancy * perf: improved re-rendering in discussionHome * perf: improved re-rendering of postsList and its child components * perf: improved re-rendering of legacyTopic and learner sidebar * fix: postFilterBar filter was not updating * fix: resolve duplicate comment posts issue * fix: memory leaking issue in comments view * fix: duplicate topic posts in inContext sidebar * perf: add lazy loading * chore: remove WDYR configuration * fix: alert banner padding * chore: update package-lock file * fix: bind tour API call with buttons
74 lines
1.7 KiB
JavaScript
74 lines
1.7 KiB
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
|
|
import classNames from 'classnames';
|
|
|
|
import { Avatar } from '@edx/paragon';
|
|
|
|
import { AvatarOutlineAndLabelColors } from '../../../../data/constants';
|
|
import { AuthorLabel } from '../../../common';
|
|
import { useAlertBannerVisible } from '../../../data/hooks';
|
|
|
|
const CommentHeader = ({
|
|
author,
|
|
authorLabel,
|
|
abuseFlagged,
|
|
closed,
|
|
createdAt,
|
|
lastEdit,
|
|
}) => {
|
|
const colorClass = AvatarOutlineAndLabelColors[authorLabel];
|
|
const hasAnyAlert = useAlertBannerVisible({
|
|
author,
|
|
abuseFlagged,
|
|
lastEdit,
|
|
closed,
|
|
});
|
|
|
|
return (
|
|
<div className={classNames('d-flex flex-row justify-content-between', {
|
|
'mt-2': hasAnyAlert,
|
|
})}
|
|
>
|
|
<div className="align-items-center d-flex flex-row">
|
|
<Avatar
|
|
className={`border-0 ml-0.5 mr-2.5 ${colorClass ? `outline-${colorClass}` : 'outline-anonymous'}`}
|
|
alt={author}
|
|
style={{
|
|
width: '32px',
|
|
height: '32px',
|
|
}}
|
|
/>
|
|
<AuthorLabel
|
|
author={author}
|
|
authorLabel={authorLabel}
|
|
labelColor={colorClass && `text-${colorClass}`}
|
|
linkToProfile
|
|
postCreatedAt={createdAt}
|
|
postOrComment
|
|
/>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
CommentHeader.propTypes = {
|
|
author: PropTypes.string.isRequired,
|
|
authorLabel: PropTypes.string,
|
|
abuseFlagged: PropTypes.bool.isRequired,
|
|
closed: PropTypes.bool,
|
|
createdAt: PropTypes.string.isRequired,
|
|
lastEdit: PropTypes.shape({
|
|
editorUsername: PropTypes.string,
|
|
reason: PropTypes.string,
|
|
}),
|
|
};
|
|
|
|
CommentHeader.defaultProps = {
|
|
authorLabel: null,
|
|
closed: undefined,
|
|
lastEdit: null,
|
|
};
|
|
|
|
export default React.memo(CommentHeader);
|