diff options
author | Dessalines <tyhou13@gmx.com> | 2019-12-11 12:21:47 -0800 |
---|---|---|
committer | Dessalines <tyhou13@gmx.com> | 2019-12-11 12:21:47 -0800 |
commit | fca8e6a0a9308340e88ad291c89c40e7d17f27be (patch) | |
tree | 7b5cdfa2323499d4f477645962baee2948f482ec /ui/src/components/site-form.tsx | |
parent | e9f476566378b6745ecb82808c0943550285c3fd (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/src/components/site-form.tsx')
-rw-r--r-- | ui/src/components/site-form.tsx | 69 |
1 files changed, 69 insertions, 0 deletions
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(); } |