Display an alert on locked posts, and allow mods to comment on locked posts. #90

Merged
DashEightMate merged 4 commits from EliteMasterEric/hexbear-frontend:feature/post-lock-alert into main 7 months ago

Resolves both #66 and #78.

Provides more intuitive communication to users that a post has been locked by completely hiding the comment box when a post is locked.

It displays at the top of the post where you would enter a top level reply, and additionally it will display on comments IF you click reply. This provides immediate feedback to the user that they have been disallowed from performing the action and why.

This message does not display for mods, sitemods, and admins, and additionally, the comment box has been unlocked for mods, sitemods, and admins, allowing them to comment on locked posts (when they previously couldn't).

Resolves both #66 and #78. Provides more intuitive communication to users that a post has been locked by completely hiding the comment box when a post is locked. It displays at the top of the post where you would enter a top level reply, and additionally it will display on comments IF you click reply. This provides immediate feedback to the user that they have been disallowed from performing the action and why. This message does not display for mods, sitemods, and admins, and additionally, the comment box has been unlocked for mods, sitemods, and admins, allowing them to comment on locked posts (when they previously couldn't).
EliteMasterEric added 2 commits 8 months ago

Note that isMod and isAdmin are used rather than canMod and canAdmin, because otherwise, moderators would only be able to comment on posts locked by the mods added after them.

Note that `isMod` and `isAdmin` are used rather than `canMod` and `canAdmin`, because otherwise, moderators would only be able to comment on posts locked by the mods added after them.
Poster
Owner

Seems like the build is failing:

src/components/post.tsx(305,35): error TS2339: Property 'isMod' does not exist on type 'Post'.
src/components/post.tsx(305,49): error TS2339: Property 'isSitemod' does not exist on type 'Post'.
src/components/post.tsx(305,67): error TS2339: Property 'isAdmin' does not exist on type 'Post'.
src/components/post.tsx(308,22): error TS2339: Property 'isMod' does not exist on type 'Post'.
src/components/post.tsx(308,34): error TS2339: Property 'isSitemod' does not exist on type 'Post'.
src/components/post.tsx(308,50): error TS2339: Property 'isAdmin' does not exist on type 'Post'.

Wouldnt those properties be on a user and not a post?

Seems like the build is failing: ``` src/components/post.tsx(305,35): error TS2339: Property 'isMod' does not exist on type 'Post'. src/components/post.tsx(305,49): error TS2339: Property 'isSitemod' does not exist on type 'Post'. src/components/post.tsx(305,67): error TS2339: Property 'isAdmin' does not exist on type 'Post'. src/components/post.tsx(308,22): error TS2339: Property 'isMod' does not exist on type 'Post'. src/components/post.tsx(308,34): error TS2339: Property 'isSitemod' does not exist on type 'Post'. src/components/post.tsx(308,50): error TS2339: Property 'isAdmin' does not exist on type 'Post'. ``` Wouldnt those properties be on a user and not a post?
ryexandrite approved these changes 8 months ago
Dismissed
ryexandrite left a comment

LGTM

ryexandrite requested review from eiknat 8 months ago
eiknat reviewed 8 months ago
Dismissed
src/components/comment-node.tsx Outdated
this.props.locked && !(this.isMod || this.isSitemod || this.isAdmin);
console.log(isLocked);
console.log(this.isMod, this.isSitemod, this.isAdmin);
Poster
Collaborator

remove console statements when you're done testing

remove console statements when you're done testing
EliteMasterEric marked this conversation as resolved
eiknat reviewed 8 months ago
Dismissed
src/components/post.tsx Outdated
this.props.locked && !(this.isMod || this.isSitemod || this.isAdmin);
console.log(isLocked);
console.log(this.isMod, this.isSitemod, this.isAdmin);
Poster
Collaborator

ditto

ditto
EliteMasterEric marked this conversation as resolved
DashEightMate requested changes 8 months ago
Dismissed
DashEightMate left a comment

I think after these changes we're good to go.

src/components/comment-node.tsx Outdated
// Lock comments if the post is locked, and the user is not privileged.
const isLocked =
this.props.locked && !(this.isMod || this.isSitemod || this.isAdmin);
Poster
Owner

These props are about the user who made the comment, not the user viewing it. You might want to look at UserService.Instance.user instead

These props are about the user who made the comment, not the user viewing it. You might want to look at `UserService.Instance.user` instead
EliteMasterEric marked this conversation as resolved
src/components/post.tsx Outdated
render(): JSX.Element {
// Lock comments if the post is locked, and the user is not privileged.
const isLocked =
this.props.locked && !(this.isMod || this.isSitemod || this.isAdmin);
Poster
Owner

isMod, isSitemod and isAdmin don't exist on the Post component. Same thing about UserService.Instance.user

isMod, isSitemod and isAdmin don't exist on the Post component. Same thing about `UserService.Instance.user`
EliteMasterEric marked this conversation as resolved

Seems like the build is failing:

src/components/post.tsx(305,35): error TS2339: Property 'isMod' does not exist on type 'Post'.
src/components/post.tsx(305,49): error TS2339: Property 'isSitemod' does not exist on type 'Post'.
src/components/post.tsx(305,67): error TS2339: Property 'isAdmin' does not exist on type 'Post'.
src/components/post.tsx(308,22): error TS2339: Property 'isMod' does not exist on type 'Post'.
src/components/post.tsx(308,34): error TS2339: Property 'isSitemod' does not exist on type 'Post'.
src/components/post.tsx(308,50): error TS2339: Property 'isAdmin' does not exist on type 'Post'.

Wouldnt those properties be on a user and not a post?

I have no clue why this worked on my instance then. I'll give the changes another pass.

> Seems like the build is failing: > ``` > src/components/post.tsx(305,35): error TS2339: Property 'isMod' does not exist on type 'Post'. > src/components/post.tsx(305,49): error TS2339: Property 'isSitemod' does not exist on type 'Post'. > src/components/post.tsx(305,67): error TS2339: Property 'isAdmin' does not exist on type 'Post'. > src/components/post.tsx(308,22): error TS2339: Property 'isMod' does not exist on type 'Post'. > src/components/post.tsx(308,34): error TS2339: Property 'isSitemod' does not exist on type 'Post'. > src/components/post.tsx(308,50): error TS2339: Property 'isAdmin' does not exist on type 'Post'. > ``` > > Wouldnt those properties be on a user and not a post? I have no clue why this worked on my instance then. I'll give the changes another pass.
eiknat refused to review 8 months ago
EliteMasterEric added 5 commits 8 months ago
EliteMasterEric added 1 commit 8 months ago
e1f1df76e0 Fixed bug with improper display of the lock status.

@DashEightMate @eiknat

Changes since last commit:

  • Changed isLocked calculation to use the current user's permissions rather than the post author's.
  • Removed console log commands.
@DashEightMate @eiknat Changes since last commit: - Changed isLocked calculation to use the current user's permissions rather than the post author's. - Removed console log commands.
EliteMasterEric force-pushed feature/post-lock-alert from e1f1df76e0 to 5f860cbb38 7 months ago
DashEightMate requested changes 7 months ago
Dismissed
DashEightMate left a comment

The perms check looks good now. There are still a couple console.logs but once that's done we can merge

EliteMasterEric added the
bug
label 7 months ago
EliteMasterEric force-pushed feature/post-lock-alert from 5f860cbb38 to 63c9aaa43a 7 months ago
EliteMasterEric added 1 commit 7 months ago
847e543317 Remove extraneous console.log calls.

@DashEightMate: Rebased and removed extraneous print calls (in comment-form.tsx and comment-node.tsx).

@DashEightMate: Rebased and removed extraneous print calls (in `comment-form.tsx` and `comment-node.tsx`).
Poster
Owner

Thanks! Merging.

Thanks! Merging.
DashEightMate merged commit bb4cde646e into main 7 months ago
continuous-integration/drone/pr Build is passing
The pull request has been merged as bb4cde646e.
Sign in to join this conversation.
Loading…
There is no content yet.