"eslint-plugin-prettier": "^4.0.0",
"husky": "^7.0.4",
"import-sort-style-module": "^6.0.0",
- "lemmy-js-client": "0.17.0-rc.5",
+ "lemmy-js-client": "0.16.4-rc.2",
"lint-staged": "^12.4.1",
"mini-css-extract-plugin": "^2.6.0",
"node-fetch": "^2.6.1",
authField,
capitalizeFirstLetter,
randomStr,
- toast,
wsClient,
wsJsonToRes,
wsSubscribe,
nsfw: false,
icon: null,
banner: null,
+ posting_restricted_to_mods: false,
auth: authField(false),
},
loading: false,
nsfw: cv.community.nsfw,
icon: cv.community.icon,
banner: cv.community.banner,
+ posting_restricted_to_mods: cv.community.posting_restricted_to_mods,
auth: authField(),
};
}
</div>
</div>
)}
+ <div class="form-group row">
+ <legend class="col-form-label col-6 pt-0">
+ {i18n.t("only_mods_can_post_in_community")}
+ </legend>
+ <div class="col-6">
+ <div class="form-check">
+ <input
+ class="form-check-input position-static"
+ id="community-only-mods-can-post"
+ type="checkbox"
+ checked={this.state.communityForm.posting_restricted_to_mods}
+ onChange={linkEvent(
+ this,
+ this.handleCommunityPostingRestrictedToMods
+ )}
+ />
+ </div>
+ </div>
+ </div>
<div class="form-group row">
<div class="col-12">
<button
i.setState(i.state);
}
+ handleCommunityPostingRestrictedToMods(i: CommunityForm, event: any) {
+ i.state.communityForm.posting_restricted_to_mods = event.target.checked;
+ i.setState(i.state);
+ }
+
handleCancel(i: CommunityForm) {
i.props.onCancel();
}
let op = wsUserOp(msg);
console.log(msg);
if (msg.error) {
- toast(i18n.t(msg.error), "danger");
+ // Errors handled by top level pages
+ // toast(i18n.t(msg.error), "danger");
this.state.loading = false;
this.setState(this.state);
return;
parseMessage(msg: any) {
if (msg.error) {
- // Toast errors are already handled by community-form
- return;
+ toast(i18n.t(msg.error), "danger");
}
}
}
{this.communityTitle()}
{this.adminButtons()}
{this.subscribe()}
- {this.createPost()}
+ {this.canPost && this.createPost()}
</div>
</div>
<div class="card border-secondary mb-3">
}
createPost() {
- let community_view = this.props.community_view;
+ let cv = this.props.community_view;
return (
- community_view.subscribed && (
+ cv.subscribed && (
<Link
className={`btn btn-secondary btn-block mb-2 ${
- community_view.community.deleted || community_view.community.removed
- ? "no-click"
- : ""
+ cv.community.deleted || cv.community.removed ? "no-click" : ""
}`}
- to={`/create_post?community_id=${community_view.community.id}`}
+ to={`/create_post?community_id=${cv.community.id}`}
>
{i18n.t("create_a_post")}
</Link>
);
}
+ get canPost(): boolean {
+ return (
+ !this.props.community_view.community.posting_restricted_to_mods ||
+ this.canMod ||
+ this.canAdmin
+ );
+ }
+
handleModRemoveShow(i: Sidebar) {
i.state.showRemoveDialog = true;
i.setState(i.state);
let op = wsUserOp(msg);
console.log(msg);
if (msg.error) {
- toast(i18n.t(msg.error), "danger");
+ // Errors handled by top level pages
+ // toast(i18n.t(msg.error), "danger");
this.state.loading = false;
this.setState(this.state);
return;
dependencies:
invert-kv "^1.0.0"
-lemmy-js-client@0.17.0-rc.5:
- version "0.17.0-rc.5"
- resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.17.0-rc.5.tgz#8065ddca68acfbccc7a693ae0f31d6ab66dce972"
- integrity sha512-IuSYaK4//KVFg+s4Av/PaxMM2tQpP3sL6G3zXfzbrZfCEtBp9ZlOEMFAu/neRgNumVh+R/koIwf8iLh4UdYCdg==
+lemmy-js-client@0.16.4-rc.2:
+ version "0.16.4-rc.2"
+ resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.16.4-rc.2.tgz#849b054ff37668c242db0202070bdb35f357f069"
+ integrity sha512-7ftHxpecqhHddfTJJC02eMB6N0jrtUBZVjt6CGC74J06kplBrsBQVETBqm33G1h1/SPHRHU1mqQ+f03PwsL+Ng==
levn@^0.4.1:
version "0.4.1"