cfd67b1c8d
## Ticket 223 Add ability for delegated moderators to delete comments ## Changes - Refactored doCommentAbandon's signature so we don't end up converting between "uri" and "Claim" several times and needing to lookup redux when the client can already provide us the exact values that we need. - Pass the new moderator fields to the API. - Remove the need to call 'makeSelectChannelPermUrlForClaimUri' since it's a simple field query when we already have the claim.
68 lines
1.8 KiB
JavaScript
68 lines
1.8 KiB
JavaScript
// @flow
|
|
import React from 'react';
|
|
import { Modal } from 'modal/modal';
|
|
import Button from 'component/button';
|
|
import Card from 'component/common/card';
|
|
|
|
type Props = {
|
|
commentId: string, // sha256 digest identifying the comment
|
|
deleterClaim: Claim,
|
|
deleterIsModOrAdmin?: boolean,
|
|
creatorClaim?: Claim,
|
|
supportAmount?: any,
|
|
setQuickReply: (any) => void,
|
|
// --- redux ---
|
|
doHideModal: () => void,
|
|
doCommentAbandon: (string, Claim, ?boolean, ?Claim) => void,
|
|
};
|
|
|
|
function ModalRemoveComment(props: Props) {
|
|
const {
|
|
commentId,
|
|
deleterClaim,
|
|
deleterIsModOrAdmin,
|
|
creatorClaim,
|
|
supportAmount,
|
|
setQuickReply,
|
|
doHideModal,
|
|
doCommentAbandon,
|
|
} = props;
|
|
|
|
return (
|
|
<Modal isOpen contentLabel={__('Confirm Comment Deletion')} type="card" onAborted={doHideModal}>
|
|
<Card
|
|
title={__('Remove Comment')}
|
|
body={
|
|
<React.Fragment>
|
|
<p>{__('Are you sure you want to remove this comment?')}</p>
|
|
{Boolean(supportAmount) && (
|
|
<p className="help error__text">
|
|
{__('This comment has a tip associated with it which cannot be reverted.')}
|
|
</p>
|
|
)}
|
|
</React.Fragment>
|
|
}
|
|
actions={
|
|
<>
|
|
<div className="section__actions">
|
|
<Button
|
|
button="primary"
|
|
label={__('Remove')}
|
|
onClick={() => {
|
|
doHideModal();
|
|
doCommentAbandon(commentId, deleterClaim, deleterIsModOrAdmin, creatorClaim);
|
|
if (setQuickReply) {
|
|
setQuickReply(undefined);
|
|
}
|
|
}}
|
|
/>
|
|
<Button button="link" label={__('Cancel')} onClick={doHideModal} />
|
|
</div>
|
|
</>
|
|
}
|
|
/>
|
|
</Modal>
|
|
);
|
|
}
|
|
|
|
export default ModalRemoveComment;
|