From 61b68104668f1cb2d5ae0df314055402f1bd0a65 Mon Sep 17 00:00:00 2001 From: Dessalines <dessalines@users.noreply.github.com> Date: Wed, 21 Sep 2022 10:04:57 -0400 Subject: [PATCH] Show create post even if not subscribed. Fixes #768 (#789) --- src/shared/components/community/sidebar.tsx | 75 +++++++++++---------- 1 file changed, 41 insertions(+), 34 deletions(-) diff --git a/src/shared/components/community/sidebar.tsx b/src/shared/components/community/sidebar.tsx index 775fd636..84879d7b 100644 --- a/src/shared/components/community/sidebar.tsx +++ b/src/shared/components/community/sidebar.tsx @@ -97,6 +97,7 @@ export class Sidebar extends Component<SidebarProps, SidebarState> { {this.adminButtons()} {this.subscribe()} {this.canPost && this.createPost()} + {this.blockCommunity()} </div> </div> <div class="card border-secondary mb-3"> @@ -273,53 +274,59 @@ export class Sidebar extends Component<SidebarProps, SidebarState> { createPost() { let cv = this.props.community_view; return ( - cv.subscribed == SubscribedType.Subscribed && ( - <Link - className={`btn btn-secondary btn-block mb-2 ${ - cv.community.deleted || cv.community.removed ? "no-click" : "" - }`} - to={`/create_post?community_id=${cv.community.id}`} - > - {i18n.t("create_a_post")} - </Link> - ) + <Link + className={`btn btn-secondary btn-block mb-2 ${ + cv.community.deleted || cv.community.removed ? "no-click" : "" + }`} + to={`/create_post?community_id=${cv.community.id}`} + > + {i18n.t("create_a_post")} + </Link> ); } subscribe() { let community_view = this.props.community_view; - let blocked = this.props.community_view.blocked; return ( <div class="mb-2"> {community_view.subscribed == SubscribedType.NotSubscribed && ( - <> - <button - class="btn btn-secondary btn-block" - onClick={linkEvent(this, this.handleSubscribe)} - > - {i18n.t("subscribe")} - </button> - {blocked ? ( - <button - class="btn btn-danger btn-block" - onClick={linkEvent(this, this.handleUnblock)} - > - {i18n.t("unblock_community")} - </button> - ) : ( - <button - class="btn btn-danger btn-block" - onClick={linkEvent(this, this.handleBlock)} - > - {i18n.t("block_community")} - </button> - )} - </> + <button + class="btn btn-secondary btn-block" + onClick={linkEvent(this, this.handleSubscribe)} + > + {i18n.t("subscribe")} + </button> )} </div> ); } + blockCommunity() { + let community_view = this.props.community_view; + let blocked = this.props.community_view.blocked; + + return ( + <div class="mb-2"> + {community_view.subscribed == SubscribedType.NotSubscribed && + (blocked ? ( + <button + class="btn btn-danger btn-block" + onClick={linkEvent(this, this.handleUnblock)} + > + {i18n.t("unblock_community")} + </button> + ) : ( + <button + class="btn btn-danger btn-block" + onClick={linkEvent(this, this.handleBlock)} + > + {i18n.t("block_community")} + </button> + ))} + </div> + ); + } + description() { let description = this.props.community_view.community.description; return description.match({