Adding only admins can create communities. Fixes #268
This commit is contained in:
parent
017121d0fb
commit
a93c7d93ee
5 changed files with 52 additions and 15 deletions
|
@ -247,15 +247,17 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
|
|||
{i18n.t("create_post")}
|
||||
</Link>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<Link
|
||||
className="nav-link"
|
||||
to="/create_community"
|
||||
title={i18n.t("create_community")}
|
||||
>
|
||||
{i18n.t("create_community")}
|
||||
</Link>
|
||||
</li>
|
||||
{this.canCreateCommunity && (
|
||||
<li class="nav-item">
|
||||
<Link
|
||||
className="nav-link"
|
||||
to="/create_community"
|
||||
title={i18n.t("create_community")}
|
||||
>
|
||||
{i18n.t("create_community")}
|
||||
</Link>
|
||||
</li>
|
||||
)}
|
||||
<li class="nav-item">
|
||||
<a
|
||||
className="nav-link"
|
||||
|
@ -524,6 +526,12 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
|
|||
);
|
||||
}
|
||||
|
||||
get canCreateCommunity(): boolean {
|
||||
let adminOnly = this.props.site_res.site_view.site
|
||||
.community_creation_admin_only;
|
||||
return !adminOnly || this.canAdmin;
|
||||
}
|
||||
|
||||
requestNotificationPermission() {
|
||||
if (UserService.Instance.localUserView) {
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
|
|
|
@ -58,6 +58,8 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
|||
enable_downvotes: this.props.site.enable_downvotes,
|
||||
open_registration: this.props.site.open_registration,
|
||||
enable_nsfw: this.props.site.enable_nsfw,
|
||||
community_creation_admin_only: this.props.site
|
||||
.community_creation_admin_only,
|
||||
icon: this.props.site.icon,
|
||||
banner: this.props.site.banner,
|
||||
auth: authField(),
|
||||
|
@ -231,6 +233,28 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="col-12">
|
||||
<div class="form-check">
|
||||
<input
|
||||
class="form-check-input"
|
||||
id="create-site-community-creation-admin-only"
|
||||
type="checkbox"
|
||||
checked={this.state.siteForm.community_creation_admin_only}
|
||||
onChange={linkEvent(
|
||||
this,
|
||||
this.handleSiteCommunityCreationAdminOnly
|
||||
)}
|
||||
/>
|
||||
<label
|
||||
class="form-check-label"
|
||||
htmlFor="create-site-community-creation-admin-only"
|
||||
>
|
||||
{i18n.t("community_creation_admin_only")}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="col-12">
|
||||
<button
|
||||
|
@ -302,6 +326,11 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
|||
i.setState(i.state);
|
||||
}
|
||||
|
||||
handleSiteCommunityCreationAdminOnly(i: SiteForm, event: any) {
|
||||
i.state.siteForm.community_creation_admin_only = event.target.checked;
|
||||
i.setState(i.state);
|
||||
}
|
||||
|
||||
handleSiteEnableDownvotesChange(i: SiteForm, event: any) {
|
||||
i.state.siteForm.enable_downvotes = event.target.checked;
|
||||
i.setState(i.state);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue