refactor: changed deleteconfirm and reportconfirm rename to comfirmAction and made it required
This commit is contained in:
@@ -13,6 +13,15 @@ export const ThreadType = {
|
||||
DISCUSSION: 'discussion',
|
||||
};
|
||||
|
||||
/**
|
||||
* Enum for report Confirmation.
|
||||
* @readonly
|
||||
* @enum {string}
|
||||
*/
|
||||
export const ReportConfirmation = {
|
||||
Report: 'Report inappropriate content?',
|
||||
};
|
||||
|
||||
/**
|
||||
* Enum to map between endorsement status and friendly name.
|
||||
* @readonly
|
||||
|
||||
@@ -76,7 +76,7 @@ function Comment({
|
||||
title={intl.formatMessage(messages.deleteResponseTitle)}
|
||||
description={intl.formatMessage(messages.deleteResponseDescription)}
|
||||
onClose={hideDeleteConfirmation}
|
||||
onDelete={() => {
|
||||
comfirmAction={() => {
|
||||
dispatch(removeComment(comment.id));
|
||||
hideDeleteConfirmation();
|
||||
}}
|
||||
@@ -87,7 +87,7 @@ function Comment({
|
||||
title={intl.formatMessage(messages.reportResponseTitle)}
|
||||
description={intl.formatMessage(messages.reportResponseDescription)}
|
||||
onClose={hideReportConfirmation}
|
||||
onReport={() => {
|
||||
comfirmAction={() => {
|
||||
dispatch(editComment(comment.id, { flagged: !comment.abuseFlagged }));
|
||||
hideReportConfirmation();
|
||||
}}
|
||||
|
||||
@@ -57,7 +57,7 @@ function Reply({
|
||||
title={intl.formatMessage(messages.deleteCommentTitle)}
|
||||
description={intl.formatMessage(messages.deleteCommentDescription)}
|
||||
onClose={hideDeleteConfirmation}
|
||||
onDelete={() => {
|
||||
comfirmAction={() => {
|
||||
dispatch(removeComment(reply.id));
|
||||
hideDeleteConfirmation();
|
||||
}}
|
||||
@@ -68,7 +68,7 @@ function Reply({
|
||||
title={intl.formatMessage(messages.reportCommentTitle)}
|
||||
description={intl.formatMessage(messages.reportCommentDescription)}
|
||||
onClose={hideReportConfirmation}
|
||||
onReport={() => {
|
||||
comfirmAction={() => {
|
||||
dispatch(editComment(reply.id, { flagged: !reply.abuseFlagged }));
|
||||
hideReportConfirmation();
|
||||
}}
|
||||
|
||||
@@ -4,6 +4,7 @@ import PropTypes from 'prop-types';
|
||||
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
|
||||
import { ActionRow, Button, ModalDialog } from '@edx/paragon';
|
||||
|
||||
import { ReportConfirmation } from '../../data/constants';
|
||||
import messages from '../messages';
|
||||
|
||||
function Confirmation({
|
||||
@@ -12,9 +13,10 @@ function Confirmation({
|
||||
title,
|
||||
description,
|
||||
onClose,
|
||||
onDelete,
|
||||
onReport,
|
||||
comfirmAction,
|
||||
}) {
|
||||
const ifDeleteConfirmation = title === ReportConfirmation.Report || false;
|
||||
|
||||
return (
|
||||
<ModalDialog title={title} isOpen={isOpen} hasCloseButton={false} onClose={onClose} zIndex={5000}>
|
||||
<ModalDialog.Header>
|
||||
@@ -27,11 +29,11 @@ function Confirmation({
|
||||
</ModalDialog.Body>
|
||||
<ModalDialog.Footer>
|
||||
<ActionRow>
|
||||
<ModalDialog.CloseButton variant={onDelete ? 'tertiary' : 'default'}>
|
||||
<ModalDialog.CloseButton variant={!ifDeleteConfirmation ? 'tertiary' : 'default'}>
|
||||
{intl.formatMessage(messages.deleteConfirmationCancel)}
|
||||
</ModalDialog.CloseButton>
|
||||
<Button variant={onDelete ? 'primary' : 'danger'} onClick={onDelete || onReport}>
|
||||
{onDelete
|
||||
<Button variant={!ifDeleteConfirmation ? 'primary' : 'danger'} onClick={comfirmAction}>
|
||||
{!ifDeleteConfirmation
|
||||
? intl.formatMessage(messages.deleteConfirmationDelete)
|
||||
: intl.formatMessage(messages.reportConfirmationConfirm) }
|
||||
</Button>
|
||||
@@ -45,14 +47,9 @@ Confirmation.propTypes = {
|
||||
intl: intlShape.isRequired,
|
||||
isOpen: PropTypes.bool.isRequired,
|
||||
onClose: PropTypes.func.isRequired,
|
||||
onDelete: PropTypes.func,
|
||||
onReport: PropTypes.func,
|
||||
comfirmAction: PropTypes.func.isRequired,
|
||||
title: PropTypes.string.isRequired,
|
||||
description: PropTypes.string.isRequired,
|
||||
};
|
||||
Confirmation.defaultProps = {
|
||||
onDelete: undefined,
|
||||
onReport: undefined,
|
||||
};
|
||||
|
||||
export default injectIntl(Confirmation);
|
||||
|
||||
@@ -73,7 +73,7 @@ function Post({
|
||||
title={intl.formatMessage(messages.deletePostTitle)}
|
||||
description={intl.formatMessage(messages.deletePostDescription)}
|
||||
onClose={hideDeleteConfirmation}
|
||||
onDelete={() => {
|
||||
comfirmAction={() => {
|
||||
dispatch(removeThread(post.id));
|
||||
history.push('.');
|
||||
hideDeleteConfirmation();
|
||||
@@ -85,7 +85,7 @@ function Post({
|
||||
title={intl.formatMessage(messages.reportPostTitle)}
|
||||
description={intl.formatMessage(messages.reportPostDescription)}
|
||||
onClose={hideReportConfirmation}
|
||||
onReport={() => {
|
||||
comfirmAction={() => {
|
||||
dispatch(updateExistingThread(post.id, { flagged: !post.abuseFlagged }));
|
||||
hideReportConfirmation();
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user