summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2019-12-11 12:21:47 -0800
committerDessalines <tyhou13@gmx.com>2019-12-11 12:21:47 -0800
commitfca8e6a0a9308340e88ad291c89c40e7d17f27be (patch)
tree7b5cdfa2323499d4f477645962baee2948f482ec /ui
parente9f476566378b6745ecb82808c0943550285c3fd (diff)
Adding some site oriented settings.
- Adding option to close registration. Fixes #350 - Adding option to disable showing NSFW buttons. Fixes #364 - Adding option to disable downvotes. Fixes #239
Diffstat (limited to 'ui')
-rw-r--r--ui/src/components/comment-node.tsx22
-rw-r--r--ui/src/components/community-form.tsx29
-rw-r--r--ui/src/components/login.tsx28
-rw-r--r--ui/src/components/post-form.tsx28
-rw-r--r--ui/src/components/post-listing.tsx22
-rw-r--r--ui/src/components/site-form.tsx69
-rw-r--r--ui/src/components/user.tsx34
-rw-r--r--ui/src/interfaces.ts9
-rw-r--r--ui/src/translations/en.ts5
9 files changed, 168 insertions, 78 deletions
diff --git a/ui/src/components/comment-node.tsx b/ui/src/components/comment-node.tsx
index e3d82196..f408ef27 100644
--- a/ui/src/components/comment-node.tsx
+++ b/ui/src/components/comment-node.tsx
@@ -102,16 +102,18 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
<div class={`font-weight-bold text-muted`}>
{node.comment.score}
</div>
- <button
- className={`btn p-0 ${
- node.comment.my_vote == -1 ? 'text-danger' : 'text-muted'
- }`}
- onClick={linkEvent(node, this.handleCommentDisLike)}
- >
- <svg class="icon downvote">
- <use xlinkHref="#icon-arrow-down"></use>
- </svg>
- </button>
+ {WebSocketService.Instance.site.enable_downvotes && (
+ <button
+ className={`btn p-0 ${
+ node.comment.my_vote == -1 ? 'text-danger' : 'text-muted'
+ }`}
+ onClick={linkEvent(node, this.handleCommentDisLike)}
+ >
+ <svg class="icon downvote">
+ <use xlinkHref="#icon-arrow-down"></use>
+ </svg>
+ </button>
+ )}
</div>
)}
<div
diff --git a/ui/src/components/community-form.tsx b/ui/src/components/community-form.tsx
index e6c8ef09..d5efb432 100644
--- a/ui/src/components/community-form.tsx
+++ b/ui/src/components/community-form.tsx
@@ -156,21 +156,24 @@ export class CommunityForm extends Component<
</select>
</div>
</div>
- <div class="form-group row">
- <div class="col-12">
- <div class="form-check">
- <input
- class="form-check-input"
- type="checkbox"
- checked={this.state.communityForm.nsfw}
- onChange={linkEvent(this, this.handleCommunityNsfwChange)}
- />
- <label class="form-check-label">
- <T i18nKey="nsfw">#</T>
- </label>
+
+ {WebSocketService.Instance.site.enable_nsfw && (
+ <div class="form-group row">
+ <div class="col-12">
+ <div class="form-check">
+ <input
+ class="form-check-input"
+ type="checkbox"
+ checked={this.state.communityForm.nsfw}
+ onChange={linkEvent(this, this.handleCommunityNsfwChange)}
+ />
+ <label class="form-check-label">
+ <T i18nKey="nsfw">#</T>
+ </label>
+ </div>
</div>
</div>
- </div>
+ )}
<div class="form-group row">
<div class="col-12">
<button type="submit" class="btn btn-secondary mr-2">
diff --git a/ui/src/components/login.tsx b/ui/src/components/login.tsx
index 8d0df3e3..9a3cf3e3 100644
--- a/ui/src/components/login.tsx
+++ b/ui/src/components/login.tsx
@@ -205,21 +205,23 @@ export class Login extends Component<any, State> {
/>
</div>
</div>
- <div class="form-group row">
- <div class="col-sm-10">
- <div class="form-check">
- <input
- class="form-check-input"
- type="checkbox"
- checked={this.state.registerForm.show_nsfw}
- onChange={linkEvent(this, this.handleRegisterShowNsfwChange)}
- />
- <label class="form-check-label">
- <T i18nKey="show_nsfw">#</T>
- </label>
+ {WebSocketService.Instance.site.enable_nsfw && (
+ <div class="form-group row">
+ <div class="col-sm-10">
+ <div class="form-check">
+ <input
+ class="form-check-input"
+ type="checkbox"
+ checked={this.state.registerForm.show_nsfw}
+ onChange={linkEvent(this, this.handleRegisterShowNsfwChange)}
+ />
+ <label class="form-check-label">
+ <T i18nKey="show_nsfw">#</T>
+ </label>
+ </div>
</div>
</div>
- </div>
+ )}
<div class="form-group row">
<div class="col-sm-10">
<button type="submit" class="btn btn-secondary">
diff --git a/ui/src/components/post-form.tsx b/ui/src/components/post-form.tsx
index a3ea8fa3..12fb42c5 100644
--- a/ui/src/components/post-form.tsx
+++ b/ui/src/components/post-form.tsx
@@ -280,21 +280,23 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
</div>
</div>
)}
- <div class="form-group row">
- <div class="col-sm-10">
- <div class="form-check">
- <input
- class="form-check-input"
- type="checkbox"
- checked={this.state.postForm.nsfw}
- onChange={linkEvent(this, this.handlePostNsfwChange)}
- />
- <label class="form-check-label">
- <T i18nKey="nsfw">#</T>
- </label>
+ {WebSocketService.Instance.site.enable_nsfw && (
+ <div class="form-group row">
+ <div class="col-sm-10">
+ <div class="form-check">
+ <input
+ class="form-check-input"
+ type="checkbox"
+ checked={this.state.postForm.nsfw}
+ onChange={linkEvent(this, this.handlePostNsfwChange)}
+ />
+ <label class="form-check-label">
+ <T i18nKey="nsfw">#</T>
+ </label>
+ </div>
</div>
</div>
- </div>
+ )}
<div class="form-group row">
<div class="col-sm-10">
<button type="submit" class="btn btn-secondary mr-2">
diff --git a/ui/src/components/post-listing.tsx b/ui/src/components/post-listing.tsx
index 94cd4d54..61a4c865 100644
--- a/ui/src/components/post-listing.tsx
+++ b/ui/src/components/post-listing.tsx
@@ -114,16 +114,18 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
</svg>
</button>
<div class={`font-weight-bold text-muted`}>{post.score}</div>
- <button
- className={`btn p-0 ${
- post.my_vote == -1 ? 'text-danger' : 'text-muted'
- }`}
- onClick={linkEvent(this, this.handlePostDisLike)}
- >
- <svg class="icon downvote">
- <use xlinkHref="#icon-arrow-down"></use>
- </svg>
- </button>
+ {WebSocketService.Instance.site.enable_downvotes && (
+ <button
+ className={`btn p-0 ${
+ post.my_vote == -1 ? 'text-danger' : 'text-muted'
+ }`}
+ onClick={linkEvent(this, this.handlePostDisLike)}
+ >
+ <svg class="icon downvote">
+ <use xlinkHref="#icon-arrow-down"></use>
+ </svg>
+ </button>
+ )}
</div>
{post.url && isImage(post.url) && !post.nsfw && !post.community_nsfw && (
<span
diff --git a/ui/src/components/site-form.tsx b/ui/src/components/site-form.tsx
index 7f8c229d..283a87d2 100644
--- a/ui/src/components/site-form.tsx
+++ b/ui/src/components/site-form.tsx
@@ -19,6 +19,9 @@ interface SiteFormState {
export class SiteForm extends Component<SiteFormProps, SiteFormState> {
private emptyState: SiteFormState = {
siteForm: {
+ enable_downvotes: true,
+ open_registration: true,
+ enable_nsfw: true,
name: null,
},
loading: false,
@@ -31,6 +34,9 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
this.state.siteForm = {
name: this.props.site.name,
description: this.props.site.description,
+ enable_downvotes: this.props.site.enable_downvotes,
+ open_registration: this.props.site.open_registration,
+ enable_nsfw: this.props.site.enable_nsfw,
};
}
}
@@ -79,6 +85,54 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
</div>
<div class="form-group row">
<div class="col-12">
+ <div class="form-check">
+ <input
+ class="form-check-input"
+ type="checkbox"
+ checked={this.state.siteForm.enable_downvotes}
+ onChange={linkEvent(this, this.handleSiteEnableDownvotesChange)}
+ />
+ <label class="form-check-label">
+ <T i18nKey="enable_downvotes">#</T>
+ </label>
+ </div>
+ </div>
+ </div>
+ <div class="form-group row">
+ <div class="col-12">
+ <div class="form-check">
+ <input
+ class="form-check-input"
+ type="checkbox"
+ checked={this.state.siteForm.enable_nsfw}
+ onChange={linkEvent(this, this.handleSiteEnableNsfwChange)}
+ />
+ <label class="form-check-label">
+ <T i18nKey="enable_nsfw">#</T>
+ </label>
+ </div>
+ </div>
+ </div>
+ <div class="form-group row">
+ <div class="col-12">
+ <div class="form-check">
+ <input
+ class="form-check-input"
+ type="checkbox"
+ checked={this.state.siteForm.open_registration}
+ onChange={linkEvent(
+ this,
+ this.handleSiteOpenRegistrationChange
+ )}
+ />
+ <label class="form-check-label">
+ <T i18nKey="open_registration">#</T>
+ </label>
+ </div>
+ </div>
+ </div>
+ <div class="form-group row">
+ <div class="col-12">
<button type="submit" class="btn btn-secondary mr-2">
{this.state.loading ? (
<svg class="icon icon-spinner spin">
@@ -126,6 +180,21 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
i.setState(i.state);
}
+ handleSiteEnableNsfwChange(i: SiteForm, event: any) {
+ i.state.siteForm.enable_nsfw = event.target.checked;
+ i.setState(i.state);
+ }
+
+ handleSiteOpenRegistrationChange(i: SiteForm, event: any) {
+ i.state.siteForm.open_registration = event.target.checked;
+ i.setState(i.state);
+ }
+
+ handleSiteEnableDownvotesChange(i: SiteForm, event: any) {
+ i.state.siteForm.enable_downvotes = event.target.checked;
+ i.setState(i.state);
+ }
+
handleCancel(i: SiteForm) {
i.props.onCancel();
}
diff --git a/ui/src/components/user.tsx b/ui/src/components/user.tsx
index bf77d4b7..2624a966 100644
--- a/ui/src/components/user.tsx
+++ b/ui/src/components/user.tsx
@@ -496,24 +496,26 @@ export class User extends Component<any, UserState> {
/>
</div>
</form>
- <div class="form-group">
- <div class="col-12">
- <div class="form-check">
- <input
- class="form-check-input"
- type="checkbox"
- checked={this.state.userSettingsForm.show_nsfw}
- onChange={linkEvent(
- this,
- this.handleUserSettingsShowNsfwChange
- )}
- />
- <label class="form-check-label">
- <T i18nKey="show_nsfw">#</T>
- </label>
+ {WebSocketService.Instance.site.enable_nsfw && (
+ <div class="form-group">
+ <div class="col-12">
+ <div class="form-check">
+ <input
+ class="form-check-input"
+ type="checkbox"
+ checked={this.state.userSettingsForm.show_nsfw}
+ onChange={linkEvent(
+ this,
+ this.handleUserSettingsShowNsfwChange
+ )}
+ />
+ <label class="form-check-label">
+ <T i18nKey="show_nsfw">#</T>
+ </label>
+ </div>
</div>
</div>
- </div>
+ )}
<div class="form-group">
<div class="col-12">
<button
diff --git a/ui/src/interfaces.ts b/ui/src/interfaces.ts
index f327202a..8b860887 100644
--- a/ui/src/interfaces.ts
+++ b/ui/src/interfaces.ts
@@ -199,6 +199,9 @@ export interface Site {
number_of_posts: number;
number_of_comments: number;
number_of_communities: number;
+ enable_downvotes: boolean;
+ open_registration: boolean;
+ enable_nsfw: boolean;
}
export enum BanType {
@@ -625,9 +628,9 @@ export interface CreatePostLikeResponse {
export interface SiteForm {
name: string;
description?: string;
- removed?: boolean;
- reason?: string;
- expires?: number;
+ enable_downvotes: boolean;
+ open_registration: boolean;
+ enable_nsfw: boolean;
auth?: string;
}
diff --git a/ui/src/translations/en.ts b/ui/src/translations/en.ts
index ce5fcdcc..60a73a30 100644
--- a/ui/src/translations/en.ts
+++ b/ui/src/translations/en.ts
@@ -127,6 +127,11 @@ export const en = {
expires: 'Expires',
language: 'Language',
browser_default: 'Browser Default',
+ downvotes_disabled: 'Downvotes disabled',
+ enable_downvotes: 'Enable Downvotes',
+ open_registration: 'Open Registration',
+ registration_closed: 'Registration closed',
+ enable_nsfw: 'Enable NSFW',
url: 'URL',
body: 'Body',
copy_suggested_title: 'copy suggested title: {{title}}',