Skip to content

Commit

Permalink
SUCCESS - Merge pull request #60 from 5-Bits-in-a-Byte/rolesRefactor
Browse files Browse the repository at this point in the history
Roles refactor merge with main
  • Loading branch information
Sephta authored Jul 20, 2021
2 parents 65b1b0b + 4d2ed94 commit cc923b9
Show file tree
Hide file tree
Showing 24 changed files with 797 additions and 341 deletions.
38 changes: 21 additions & 17 deletions client/src/components/comments/Comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const Comment = ({ comment, isDraft, callback }) => {
const generateDropdownOptions = () => {
if (userRole) {
let deleteOption =
userRole.delete.postComment &&
userRole.delete.comment &&
(comment.postedBy._id == user._id ||
comment.postedBy._id == user.anonymousId)
? {
Expand All @@ -180,7 +180,7 @@ const Comment = ({ comment, isDraft, callback }) => {
}
: null;
let editOption =
userRole.edit.postComment &&
userRole.edit.comment &&
(comment.postedBy._id == user._id ||
comment.postedBy._id == user.anonymousId)
? { onClick: handleEdit, label: "Edit Comment" }
Expand Down Expand Up @@ -277,21 +277,25 @@ const Comment = ({ comment, isDraft, callback }) => {
</>
) : (
<>
<Reaction
reactions={comment.reactions}
type="comment"
id={comment._id}
postid={postid}
/>

<ReplyBtn
style={{ marginRight: 10, marginLeft: 20 }}
onClick={() => {
toggleReply(true);
}}
>
Reply
</ReplyBtn>
{userRole.participation.reactions && (
<Reaction
reactions={comment.reactions}
type="comment"
id={comment._id}
postid={postid}
/>
)}

{userRole.publish.reply && (
<ReplyBtn
style={{ marginRight: 10, marginLeft: 20 }}
onClick={() => {
toggleReply(true);
}}
>
Reply
</ReplyBtn>
)}
</>
)}
</MetaIconWrapper>
Expand Down
14 changes: 8 additions & 6 deletions client/src/components/comments/CommentReply.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,14 @@ const CommentReply = ({
</>
) : (
<>
<Reaction
reactions={reply.reactions}
type="reply"
id={reply._id}
postid={postid}
/>
{userRole.participation.reactions && (
<Reaction
reactions={reply.reactions}
type="reply"
id={reply._id}
postid={postid}
/>
)}
</>
)}
</MetaIconWrapper>
Expand Down
8 changes: 4 additions & 4 deletions client/src/components/comments/CommentView.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const CommentView = ({ classroomName }) => {

// const setUserRole = useContext(UserRoleDispatchContext);
const userRole = useContext(UserRoleContext);
// console.log("Comment View Role Object: ", userRole);
console.log("Comment View Role Object: ", userRole);

const handleVote = (voteAnswer) => {
var pa = pollAns;
Expand Down Expand Up @@ -233,13 +233,13 @@ const CommentView = ({ classroomName }) => {
>
<Button secondary>Back to all Posts</Button>
</Link>
{postExists && (
{postExists && userRole.publish.comment && (
<Button onClick={draftNewComment} secondary>
Reply to Post
Comment on Post
</Button>
)}
</OptionsContainer>
{postid === "newQorA" && <Draft />}
{postid === "newQorA" && <Draft userRole={userRole} />}
{/* {postid === "newPoll" && <DraftPoll />} */}
{postid === "newPoll" && <PollConfig />}
{postExists &&
Expand Down
Loading

0 comments on commit cc923b9

Please sign in to comment.