Compare commits

...

4 Commits

Author SHA1 Message Date
sundasnoreen12
2c6a75e7d9 refactor: added AlertBar component to avoid duplicate code 2023-04-18 11:28:51 +05:00
sundasnoreen12
eb43b7139a refactor: added left margin for endorsed time 2023-04-17 15:57:16 +05:00
sundasnoreen12
5aa090950e fix: added role for editedby and closedby user 2023-04-17 15:33:13 +05:00
sundasnoreen12
fd37d3441c fix: changed the title of new edx provider 2023-04-17 15:33:13 +05:00
2 changed files with 78 additions and 33 deletions

View File

@@ -8,13 +8,14 @@ import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import { Alert } from '@edx/paragon';
import { Report } from '@edx/paragon/icons';
import { AvatarOutlineAndLabelColors } from '../../data/constants';
import {
selectModerationSettings, selectUserHasModerationPrivileges, selectUserIsGroupTa, selectUserIsStaff,
} from '../data/selectors';
import { commentShape } from '../post-comments/comments/comment/proptypes';
import messages from '../post-comments/messages';
import { postShape } from '../posts/post/proptypes';
import AuthorLabel from './AuthorLabel';
import AlertBar from './AlertBar';
function AlertBanner({
intl,
@@ -29,6 +30,8 @@ function AlertBanner({
const canSeeLastEditOrClosedAlert = (userHasModerationPrivileges || userIsGroupTa
|| userIsGlobalStaff || userIsContentAuthor
);
const editByLabelColor = AvatarOutlineAndLabelColors[content.editByLabel];
const closedByLabelColor = AvatarOutlineAndLabelColors[content.closedByLabel];
return (
<>
@@ -40,40 +43,22 @@ function AlertBanner({
{reasonCodesEnabled && canSeeLastEditOrClosedAlert && (
<>
{content.lastEdit?.reason && (
<Alert variant="info" className="px-3 shadow-none mb-1 py-10px bg-light-200">
<div className="d-flex align-items-center flex-wrap text-gray-700 font-style">
{intl.formatMessage(messages.editedBy)}
<span className="ml-1 mr-3">
<AuthorLabel author={content.lastEdit.editorUsername} linkToProfile postOrComment />
</span>
<span
className="mx-1.5 font-size-8 font-style text-light-700"
style={{ lineHeight: '15px' }}
>
{intl.formatMessage(messages.fullStop)}
</span>
{intl.formatMessage(messages.reason)}:&nbsp;{content.lastEdit.reason}
</div>
</Alert>
<AlertBar
message={messages.editedBy}
author={content.lastEdit.editorUsername}
authorLabel={content.editByLabel}
labelColor={editByLabelColor && `text-${editByLabelColor}`}
reason={content.lastEdit.reason}
/>
)}
{content.closed && (
<Alert variant="info" className="px-3 shadow-none mb-1 py-10px bg-light-200">
<div className="d-flex align-items-center flex-wrap text-gray-700 font-style">
{intl.formatMessage(messages.closedBy)}
<span className="ml-1 ">
<AuthorLabel author={content.closedBy} linkToProfile postOrComment />
</span>
<span
className="mx-1.5 font-size-8 font-style text-light-700"
style={{ lineHeight: '15px' }}
>
{intl.formatMessage(messages.fullStop)}
</span>
{content.closeReason && (`${intl.formatMessage(messages.reason)}: ${content.closeReason}`)}
</div>
</Alert>
<AlertBar
message={messages.closedBy}
author={content.closedBy}
authorLabel={content.closedByLabel}
labelColor={closedByLabelColor && `text-${closedByLabelColor}`}
reason={content.closeReason}
/>
)}
</>
)}

View File

@@ -0,0 +1,60 @@
import React from 'react';
import PropTypes from 'prop-types';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import { Alert } from '@edx/paragon';
import messages from '../post-comments/messages';
import AuthorLabel from './AuthorLabel';
function AlertBar({
intl,
message,
author,
authorLabel,
labelColor,
reason,
}) {
return (
<Alert variant="info" className="px-3 shadow-none mb-1 py-10px bg-light-200">
<div className="d-flex align-items-center flex-wrap text-gray-700 font-style">
{intl.formatMessage(message)}
<span className="ml-1">
<AuthorLabel
author={author}
authorLabel={authorLabel}
labelColor={labelColor}
linkToProfile
postOrComment
/>
</span>
<span
className="mr-1.5 font-size-8 font-style text-light-700"
style={{ lineHeight: '15px' }}
>
{intl.formatMessage(messages.fullStop)}
</span>
{reason && (`${intl.formatMessage(messages.reason)}: ${reason}`)}
</div>
</Alert>
);
}
AlertBar.propTypes = {
intl: intlShape.isRequired,
message: PropTypes.string,
author: PropTypes.string,
authorLabel: PropTypes.string,
labelColor: PropTypes.string,
reason: PropTypes.string,
};
AlertBar.defaultProps = {
message: '',
author: '',
authorLabel: '',
labelColor: '',
reason: '',
};
export default injectIntl(AlertBar);