diff options
author | Dessalines <happydooby@gmail.com> | 2019-08-11 20:55:09 -0700 |
---|---|---|
committer | Dessalines <happydooby@gmail.com> | 2019-08-11 20:55:09 -0700 |
commit | 3246d5d670d0d5e10310a90c6fd81a7dc9e97e54 (patch) | |
tree | 60bdf51e980fa9abe6fe9f1bae39373452afb155 /ui | |
parent | c2cb36bfa4bd8e55fbdbde51bd9fbfd2554ccfa4 (diff) |
nsfw mostly done, except for settings page.
Diffstat (limited to 'ui')
-rw-r--r-- | ui/src/components/community-form.tsx | 17 | ||||
-rw-r--r-- | ui/src/components/community.tsx | 4 | ||||
-rw-r--r-- | ui/src/components/login.tsx | 15 | ||||
-rw-r--r-- | ui/src/components/post-form.tsx | 15 | ||||
-rw-r--r-- | ui/src/components/post-listing.tsx | 6 | ||||
-rw-r--r-- | ui/src/interfaces.ts | 8 | ||||
-rw-r--r-- | ui/src/translations/en.ts | 2 |
7 files changed, 65 insertions, 2 deletions
diff --git a/ui/src/components/community-form.tsx b/ui/src/components/community-form.tsx index b039fb4d..833d8a3f 100644 --- a/ui/src/components/community-form.tsx +++ b/ui/src/components/community-form.tsx @@ -30,7 +30,8 @@ export class CommunityForm extends Component<CommunityFormProps, CommunityFormSt communityForm: { name: null, title: null, - category_id: null + category_id: null, + nsfw: false, }, categories: [], loading: false @@ -48,6 +49,7 @@ export class CommunityForm extends Component<CommunityFormProps, CommunityFormSt category_id: this.props.community.category_id, description: this.props.community.description, edit_id: this.props.community.id, + nsfw: this.props.community.nsfw, auth: null } } @@ -105,6 +107,14 @@ export class CommunityForm extends Component<CommunityFormProps, CommunityFormSt </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> + </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"><use xlinkHref="#icon-spinner"></use></svg> : @@ -147,6 +157,11 @@ export class CommunityForm extends Component<CommunityFormProps, CommunityFormSt i.setState(i.state); } + handleCommunityNsfwChange(i: CommunityForm, event: any) { + i.state.communityForm.nsfw = event.target.checked; + i.setState(i.state); + } + handleCancel(i: CommunityForm) { i.props.onCancel(); } diff --git a/ui/src/components/community.tsx b/ui/src/components/community.tsx index 480b909e..b9f9c8b2 100644 --- a/ui/src/components/community.tsx +++ b/ui/src/components/community.tsx @@ -37,6 +37,7 @@ export class Community extends Component<any, State> { number_of_comments: null, published: null, removed: null, + nsfw: false, deleted: null, }, moderators: [], @@ -105,6 +106,9 @@ export class Community extends Component<any, State> { {this.state.community.removed && <small className="ml-2 text-muted font-italic"><T i18nKey="removed">#</T></small> } + {this.state.community.nsfw && + <small className="ml-2 text-muted font-italic"><T i18nKey="nsfw">#</T></small> + } </h5> {this.selects()} <PostListings posts={this.state.posts} /> diff --git a/ui/src/components/login.tsx b/ui/src/components/login.tsx index e7af89ca..66962acc 100644 --- a/ui/src/components/login.tsx +++ b/ui/src/components/login.tsx @@ -28,6 +28,7 @@ export class Login extends Component<any, State> { password: undefined, password_verify: undefined, admin: false, + show_nsfw: false, }, loginLoading: false, registerLoading: false, @@ -127,9 +128,16 @@ export class Login extends Component<any, State> { </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> + </div> + </div> + </div> + <div class="form-group row"> + <div class="col-sm-10"> <button type="submit" class="btn btn-secondary">{this.state.registerLoading ? <svg class="icon icon-spinner spin"><use xlinkHref="#icon-spinner"></use></svg> : i18n.t('sign_up')}</button> - </div> </div> </form> @@ -181,6 +189,11 @@ export class Login extends Component<any, State> { i.setState(i.state); } + handleRegisterShowNsfwChange(i: Login, event: any) { + i.state.registerForm.show_nsfw = event.target.checked; + i.setState(i.state); + } + parseMessage(msg: any) { let op: UserOperation = msgOp(msg); if (msg.error) { diff --git a/ui/src/components/post-form.tsx b/ui/src/components/post-form.tsx index 79d37b42..704b1cdd 100644 --- a/ui/src/components/post-form.tsx +++ b/ui/src/components/post-form.tsx @@ -31,6 +31,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> { private emptyState: PostFormState = { postForm: { name: null, + nsfw: false, auth: null, community_id: null, creator_id: (UserService.Instance.user) ? UserService.Instance.user.id : null, @@ -54,6 +55,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> { edit_id: this.props.post.id, creator_id: this.props.post.creator_id, url: this.props.post.url, + nsfw: this.props.post.nsfw, auth: null } } @@ -128,6 +130,14 @@ export class PostForm extends Component<PostFormProps, PostFormState> { } <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 class="form-group row"> + <div class="col-sm-10"> <button type="submit" class="btn btn-secondary mr-2"> {this.state.loading ? <svg class="icon icon-spinner spin"><use xlinkHref="#icon-spinner"></use></svg> : @@ -196,6 +206,11 @@ export class PostForm extends Component<PostFormProps, PostFormState> { i.setState(i.state); } + handlePostNsfwChange(i: PostForm, event: any) { + i.state.postForm.nsfw = event.target.checked; + i.setState(i.state); + } + handleCancel(i: PostForm) { i.props.onCancel(); } diff --git a/ui/src/components/post-listing.tsx b/ui/src/components/post-listing.tsx index ff70783c..ca03b980 100644 --- a/ui/src/components/post-listing.tsx +++ b/ui/src/components/post-listing.tsx @@ -93,6 +93,9 @@ export class PostListing extends Component<PostListingProps, PostListingState> { {post.locked && <small className="ml-2 text-muted font-italic"><T i18nKey="locked">#</T></small> } + {post.nsfw && + <small className="ml-2 text-muted font-italic"><T i18nKey="nsfw">#</T></small> + } { post.url && isImage(post.url) && <> { !this.state.imageExpanded @@ -251,6 +254,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> { edit_id: i.props.post.id, creator_id: i.props.post.creator_id, deleted: !i.props.post.deleted, + nsfw: i.props.post.nsfw, auth: null }; WebSocketService.Instance.editPost(deleteForm); @@ -285,6 +289,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> { creator_id: i.props.post.creator_id, removed: !i.props.post.removed, reason: i.state.removeReason, + nsfw: i.props.post.nsfw, auth: null, }; WebSocketService.Instance.editPost(form); @@ -299,6 +304,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> { community_id: i.props.post.community_id, edit_id: i.props.post.id, creator_id: i.props.post.creator_id, + nsfw: i.props.post.nsfw, locked: !i.props.post.locked, auth: null, }; diff --git a/ui/src/interfaces.ts b/ui/src/interfaces.ts index 59f4ba1c..7078ccac 100644 --- a/ui/src/interfaces.ts +++ b/ui/src/interfaces.ts @@ -22,6 +22,7 @@ export interface User { id: number; iss: string; username: string; + show_nsfw: boolean; } export interface UserView { @@ -53,6 +54,7 @@ export interface Community { creator_id: number; removed: boolean; deleted: boolean; + nsfw: boolean; published: string; updated?: string; creator_name: string; @@ -74,11 +76,14 @@ export interface Post { removed: boolean; deleted: boolean; locked: boolean; + nsfw: boolean; published: string; updated?: string; creator_name: string; community_name: string; community_removed: boolean; + community_deleted: boolean; + community_nsfw: boolean; number_of_comments: number; score: number; upvotes: number; @@ -334,6 +339,7 @@ export interface RegisterForm { password: string; password_verify: string; admin: boolean; + show_nsfw: boolean; } export interface LoginResponse { @@ -351,6 +357,7 @@ export interface CommunityForm { edit_id?: number; removed?: boolean; deleted?: boolean; + nsfw: boolean; reason?: string; expires?: number; auth?: string; @@ -396,6 +403,7 @@ export interface PostForm { creator_id: number; removed?: boolean; deleted?: boolean; + nsfw: boolean; locked?: boolean; reason?: string; auth: string; diff --git a/ui/src/translations/en.ts b/ui/src/translations/en.ts index 7c2b184f..a8726b79 100644 --- a/ui/src/translations/en.ts +++ b/ui/src/translations/en.ts @@ -112,6 +112,8 @@ export const en = { setup_admin: 'Set Up Site Administrator', your_site: 'your site', modified: 'modified', + nsfw: 'NSFW', + show_nsfw: 'Show NSFW content', sponsors: 'Sponsors', sponsors_of_lemmy: 'Sponsors of Lemmy', sponsor_message: 'Lemmy is free, <1>open-source</1> software, meaning no advertising, monetizing, or venture capital, ever. Your donations directly support full-time development of the project. Thank you to the following people:', |