mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-29 07:41:13 +00:00
Hiding create community button. Fixes #754
This commit is contained in:
parent
65fe98659b
commit
a120357af8
3 changed files with 12 additions and 9 deletions
|
@ -21,6 +21,7 @@ import { UserService, WebSocketService } from "../../services";
|
|||
import {
|
||||
amAdmin,
|
||||
auth,
|
||||
canCreateCommunity,
|
||||
donateLemmyUrl,
|
||||
isBrowser,
|
||||
notifyComment,
|
||||
|
@ -270,7 +271,7 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
|
|||
{i18n.t("create_post")}
|
||||
</NavLink>
|
||||
</li>
|
||||
{this.canCreateCommunity && (
|
||||
{canCreateCommunity(this.props.siteRes) && (
|
||||
<li class="nav-item">
|
||||
<NavLink
|
||||
to="/create_community"
|
||||
|
@ -524,13 +525,6 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
|
|||
return amAdmin(Some(this.props.siteRes.admins));
|
||||
}
|
||||
|
||||
get canCreateCommunity(): boolean {
|
||||
let adminOnly = this.props.siteRes.site_view
|
||||
.map(s => s.site.community_creation_admin_only)
|
||||
.unwrapOr(false);
|
||||
return !adminOnly || this.amAdmin;
|
||||
}
|
||||
|
||||
handleToggleExpandNavbar(i: Navbar) {
|
||||
i.state.expanded = !i.state.expanded;
|
||||
i.setState(i.state);
|
||||
|
|
|
@ -38,6 +38,7 @@ import {
|
|||
import { UserService, WebSocketService } from "../../services";
|
||||
import {
|
||||
auth,
|
||||
canCreateCommunity,
|
||||
commentsToFlatNodes,
|
||||
createCommentLikeRes,
|
||||
createPostLikeFindRes,
|
||||
|
@ -426,7 +427,8 @@ export class Home extends Component<any, HomeState> {
|
|||
<div class="card border-secondary mb-3">
|
||||
<div class="card-body">
|
||||
{this.trendingCommunities()}
|
||||
{this.createCommunityButton()}
|
||||
{canCreateCommunity(this.state.siteRes) &&
|
||||
this.createCommunityButton()}
|
||||
{this.exploreCommunitiesButton()}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1483,3 +1483,10 @@ export function myFirstDiscussionLanguageId(
|
|||
.map(i => i.id)
|
||||
);
|
||||
}
|
||||
|
||||
export function canCreateCommunity(siteRes: GetSiteResponse): boolean {
|
||||
let adminOnly = siteRes.site_view
|
||||
.map(s => s.site.community_creation_admin_only)
|
||||
.unwrapOr(false);
|
||||
return !adminOnly || amAdmin(Some(siteRes.admins));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue