Adding more for advanced actions on comments and posts.

- Fixes #561
This commit is contained in:
Dessalines 2020-02-29 22:06:42 -05:00
parent a5bfc837ea
commit 8390744391
3 changed files with 452 additions and 386 deletions

View file

@ -48,6 +48,7 @@ interface CommentNodeState {
showConfirmAppointAsAdmin: boolean; showConfirmAppointAsAdmin: boolean;
collapsed: boolean; collapsed: boolean;
viewSource: boolean; viewSource: boolean;
showAdvanced: boolean;
my_vote: number; my_vote: number;
score: number; score: number;
upvotes: number; upvotes: number;
@ -81,6 +82,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
banType: BanType.Community, banType: BanType.Community,
collapsed: false, collapsed: false,
viewSource: false, viewSource: false,
showAdvanced: false,
showConfirmTransferSite: false, showConfirmTransferSite: false,
showConfirmTransferCommunity: false, showConfirmTransferCommunity: false,
showConfirmAppointAsMod: false, showConfirmAppointAsMod: false,
@ -300,6 +302,17 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
</Link> </Link>
</li> </li>
)} )}
{!this.state.showAdvanced ? (
<li className="list-inline-item">
<span
className="pointer"
onClick={linkEvent(this, this.handleShowAdvanced)}
>
{i18n.t('more')}
</span>
</li>
) : (
<>
<li className="list-inline-item"></li> <li className="list-inline-item"></li>
<li className="list-inline-item"> <li className="list-inline-item">
<span <span
@ -418,7 +431,8 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
</> </>
)} )}
{/* Community creators and admins can transfer community to another mod */} {/* Community creators and admins can transfer community to another mod */}
{(this.amCommunityCreator || this.canAdmin) && this.isMod && ( {(this.amCommunityCreator || this.canAdmin) &&
this.isMod && (
<li className="list-inline-item"> <li className="list-inline-item">
{!this.state.showConfirmTransferCommunity ? ( {!this.state.showConfirmTransferCommunity ? (
<span <span
@ -448,7 +462,8 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
class="pointer d-inline-block" class="pointer d-inline-block"
onClick={linkEvent( onClick={linkEvent(
this, this,
this.handleCancelShowConfirmTransferCommunity this
.handleCancelShowConfirmTransferCommunity
)} )}
> >
{i18n.t('no')} {i18n.t('no')}
@ -465,7 +480,10 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
{!node.comment.banned ? ( {!node.comment.banned ? (
<span <span
class="pointer" class="pointer"
onClick={linkEvent(this, this.handleModBanShow)} onClick={linkEvent(
this,
this.handleModBanShow
)}
> >
{i18n.t('ban_from_site')} {i18n.t('ban_from_site')}
</span> </span>
@ -503,7 +521,10 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
</span> </span>
<span <span
class="pointer d-inline-block mr-1" class="pointer d-inline-block mr-1"
onClick={linkEvent(this, this.handleAddAdmin)} onClick={linkEvent(
this,
this.handleAddAdmin
)}
> >
{i18n.t('yes')} {i18n.t('yes')}
</span> </span>
@ -542,7 +563,10 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
</span> </span>
<span <span
class="pointer d-inline-block mr-1" class="pointer d-inline-block mr-1"
onClick={linkEvent(this, this.handleTransferSite)} onClick={linkEvent(
this,
this.handleTransferSite
)}
> >
{i18n.t('yes')} {i18n.t('yes')}
</span> </span>
@ -561,6 +585,8 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
)} )}
</> </>
)} )}
</>
)}
</ul> </ul>
</div> </div>
)} )}
@ -1016,4 +1042,9 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
i.state.viewSource = !i.state.viewSource; i.state.viewSource = !i.state.viewSource;
i.setState(i.state); i.setState(i.state);
} }
handleShowAdvanced(i: CommentNode) {
i.state.showAdvanced = !i.state.showAdvanced;
i.setState(i.state);
}
} }

View file

@ -45,6 +45,7 @@ interface PostListingState {
showConfirmTransferCommunity: boolean; showConfirmTransferCommunity: boolean;
imageExpanded: boolean; imageExpanded: boolean;
viewSource: boolean; viewSource: boolean;
showAdvanced: boolean;
my_vote: number; my_vote: number;
score: number; score: number;
upvotes: number; upvotes: number;
@ -75,6 +76,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
showConfirmTransferCommunity: false, showConfirmTransferCommunity: false,
imageExpanded: false, imageExpanded: false,
viewSource: false, viewSource: false,
showAdvanced: false,
my_vote: this.props.post.my_vote, my_vote: this.props.post.my_vote,
score: this.props.post.score, score: this.props.post.score,
upvotes: this.props.post.upvotes, upvotes: this.props.post.upvotes,
@ -511,6 +513,18 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
</li> </li>
</> </>
)} )}
{!this.state.showAdvanced && this.props.showBody ? (
<li className="list-inline-item">
<span
className="pointer"
onClick={linkEvent(this, this.handleShowAdvanced)}
>
{i18n.t('more')}
</span>
</li>
) : (
<>
{this.canModOnSelf && ( {this.canModOnSelf && (
<> <>
<li className="list-inline-item"> <li className="list-inline-item">
@ -518,7 +532,9 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
class="pointer" class="pointer"
onClick={linkEvent(this, this.handleModLock)} onClick={linkEvent(this, this.handleModLock)}
> >
{post.locked ? i18n.t('unlock') : i18n.t('lock')} {post.locked
? i18n.t('unlock')
: i18n.t('lock')}
</span> </span>
</li> </li>
<li className="list-inline-item"> <li className="list-inline-item">
@ -539,7 +555,10 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
{!post.removed ? ( {!post.removed ? (
<span <span
class="pointer" class="pointer"
onClick={linkEvent(this, this.handleModRemoveShow)} onClick={linkEvent(
this,
this.handleModRemoveShow
)}
> >
{i18n.t('remove')} {i18n.t('remove')}
</span> </span>
@ -601,7 +620,8 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
</> </>
)} )}
{/* Community creators and admins can transfer community to another mod */} {/* Community creators and admins can transfer community to another mod */}
{(this.amCommunityCreator || this.canAdmin) && this.isMod && ( {(this.amCommunityCreator || this.canAdmin) &&
this.isMod && (
<li className="list-inline-item"> <li className="list-inline-item">
{!this.state.showConfirmTransferCommunity ? ( {!this.state.showConfirmTransferCommunity ? (
<span <span
@ -631,7 +651,8 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
class="pointer d-inline-block" class="pointer d-inline-block"
onClick={linkEvent( onClick={linkEvent(
this, this,
this.handleCancelShowConfirmTransferCommunity this
.handleCancelShowConfirmTransferCommunity
)} )}
> >
{i18n.t('no')} {i18n.t('no')}
@ -648,7 +669,10 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
{!post.banned ? ( {!post.banned ? (
<span <span
class="pointer" class="pointer"
onClick={linkEvent(this, this.handleModBanShow)} onClick={linkEvent(
this,
this.handleModBanShow
)}
> >
{i18n.t('ban_from_site')} {i18n.t('ban_from_site')}
</span> </span>
@ -699,7 +723,10 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
</span> </span>
<span <span
class="pointer d-inline-block mr-1" class="pointer d-inline-block mr-1"
onClick={linkEvent(this, this.handleTransferSite)} onClick={linkEvent(
this,
this.handleTransferSite
)}
> >
{i18n.t('yes')} {i18n.t('yes')}
</span> </span>
@ -718,6 +745,8 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
)} )}
</> </>
)} )}
</>
)}
{this.props.showBody && post.body && ( {this.props.showBody && post.body && (
<li className="list-inline-item"> <li className="list-inline-item">
<span <span
@ -1201,4 +1230,9 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
i.state.viewSource = !i.state.viewSource; i.state.viewSource = !i.state.viewSource;
i.setState(i.state); i.setState(i.state);
} }
handleShowAdvanced(i: PostListing) {
i.state.showAdvanced = !i.state.showAdvanced;
i.setState(i.state);
}
} }

View file

@ -29,6 +29,7 @@
"message": "Message", "message": "Message",
"edit": "edit", "edit": "edit",
"reply": "reply", "reply": "reply",
"more": "more",
"cancel": "Cancel", "cancel": "Cancel",
"preview": "Preview", "preview": "Preview",
"upload_image": "upload image", "upload_image": "upload image",