1 import { Component, InfernoMouseEvent, linkEvent } from "inferno";
2 import { Prompt } from "inferno-router";
6 GetFederatedInstancesResponse,
9 } from "lemmy-js-client";
10 import { i18n } from "../../i18next";
11 import { WebSocketService } from "../../services";
13 capitalizeFirstLetter,
18 import { Spinner } from "../common/icon";
19 import { ImageUploadForm } from "../common/image-upload-form";
20 import { LanguageSelect } from "../common/language-select";
21 import { ListingTypeSelect } from "../common/listing-type-select";
22 import { MarkdownTextArea } from "../common/markdown-textarea";
24 interface SiteFormProps {
25 siteRes: GetSiteResponse;
26 instancesRes?: GetFederatedInstancesResponse;
30 interface SiteFormState {
36 export class SiteForm extends Component<SiteFormProps, SiteFormState> {
37 state: SiteFormState = {
44 constructor(props: any, context: any) {
45 super(props, context);
47 this.handleSiteSidebarChange = this.handleSiteSidebarChange.bind(this);
48 this.handleSiteLegalInfoChange = this.handleSiteLegalInfoChange.bind(this);
49 this.handleSiteApplicationQuestionChange =
50 this.handleSiteApplicationQuestionChange.bind(this);
52 this.handleIconUpload = this.handleIconUpload.bind(this);
53 this.handleIconRemove = this.handleIconRemove.bind(this);
55 this.handleBannerUpload = this.handleBannerUpload.bind(this);
56 this.handleBannerRemove = this.handleBannerRemove.bind(this);
58 this.handleDefaultPostListingTypeChange =
59 this.handleDefaultPostListingTypeChange.bind(this);
61 this.handleDiscussionLanguageChange =
62 this.handleDiscussionLanguageChange.bind(this);
64 let site = this.props.siteRes.site_view.site;
65 let ls = this.props.siteRes.site_view.local_site;
66 let lsrl = this.props.siteRes.site_view.local_site_rate_limit;
71 sidebar: site.sidebar,
72 description: site.description,
73 enable_downvotes: ls.enable_downvotes,
74 registration_mode: ls.registration_mode,
75 enable_nsfw: ls.enable_nsfw,
76 community_creation_admin_only: ls.community_creation_admin_only,
79 require_email_verification: ls.require_email_verification,
80 application_question: ls.application_question,
81 private_instance: ls.private_instance,
82 default_theme: ls.default_theme,
83 default_post_listing_type: ls.default_post_listing_type,
84 legal_information: ls.legal_information,
85 application_email_admins: ls.application_email_admins,
86 reports_email_admins: ls.reports_email_admins,
87 hide_modlog_mod_names: ls.hide_modlog_mod_names,
88 discussion_languages: this.props.siteRes.discussion_languages,
89 slur_filter_regex: ls.slur_filter_regex,
90 actor_name_max_length: ls.actor_name_max_length,
91 rate_limit_message: lsrl.message,
92 rate_limit_message_per_second: lsrl.message_per_second,
93 rate_limit_comment: lsrl.comment,
94 rate_limit_comment_per_second: lsrl.comment_per_second,
95 rate_limit_image: lsrl.image,
96 rate_limit_image_per_second: lsrl.image_per_second,
97 rate_limit_post: lsrl.post,
98 rate_limit_post_per_second: lsrl.post_per_second,
99 rate_limit_register: lsrl.register,
100 rate_limit_register_per_second: lsrl.register_per_second,
101 rate_limit_search: lsrl.search,
102 rate_limit_search_per_second: lsrl.search_per_second,
103 federation_enabled: ls.federation_enabled,
104 federation_debug: ls.federation_debug,
105 federation_worker_count: ls.federation_worker_count,
106 captcha_enabled: ls.captcha_enabled,
107 captcha_difficulty: ls.captcha_difficulty,
109 this.props.instancesRes?.federated_instances?.allowed.map(
113 this.props.instancesRes?.federated_instances?.blocked.map(
121 async componentDidMount() {
122 this.setState({ themeList: await fetchThemeList() });
125 // Necessary to stop the loading
126 componentWillReceiveProps() {
127 this.setState({ loading: false });
130 componentDidUpdate() {
132 !this.state.loading &&
133 !this.props.siteRes.site_view.local_site.site_setup &&
134 (this.state.siteForm.name ||
135 this.state.siteForm.sidebar ||
136 this.state.siteForm.application_question ||
137 this.state.siteForm.description)
139 window.onbeforeunload = () => true;
141 window.onbeforeunload = null;
145 componentWillUnmount() {
146 window.onbeforeunload = null;
150 let siteSetup = this.props.siteRes.site_view.local_site.site_setup;
155 !this.state.loading &&
157 (this.state.siteForm.name ||
158 this.state.siteForm.sidebar ||
159 this.state.siteForm.application_question ||
160 this.state.siteForm.description)
162 message={i18n.t("block_leaving")}
164 <form onSubmit={linkEvent(this, this.handleCreateSiteSubmit)}>
167 ? capitalizeFirstLetter(i18n.t("save"))
168 : capitalizeFirstLetter(i18n.t("name"))
169 } ${i18n.t("your_site")}`}</h5>
170 <div className="form-group row">
171 <label className="col-12 col-form-label" htmlFor="create-site-name">
174 <div className="col-12">
177 id="create-site-name"
178 className="form-control"
179 value={this.state.siteForm.name}
180 onInput={linkEvent(this, this.handleSiteNameChange)}
187 <div className="form-group">
188 <label>{i18n.t("icon")}</label>
190 uploadTitle={i18n.t("upload_icon")}
191 imageSrc={this.state.siteForm.icon}
192 onUpload={this.handleIconUpload}
193 onRemove={this.handleIconRemove}
197 <div className="form-group">
198 <label>{i18n.t("banner")}</label>
200 uploadTitle={i18n.t("upload_banner")}
201 imageSrc={this.state.siteForm.banner}
202 onUpload={this.handleBannerUpload}
203 onRemove={this.handleBannerRemove}
206 <div className="form-group row">
207 <label className="col-12 col-form-label" htmlFor="site-desc">
208 {i18n.t("description")}
210 <div className="col-12">
213 className="form-control"
215 value={this.state.siteForm.description}
216 onInput={linkEvent(this, this.handleSiteDescChange)}
221 <div className="form-group row">
222 <label className="col-12 col-form-label">{i18n.t("sidebar")}</label>
223 <div className="col-12">
225 initialContent={this.state.siteForm.sidebar}
226 onContentChange={this.handleSiteSidebarChange}
227 hideNavigationWarnings
233 <div className="form-group row">
234 <label className="col-12 col-form-label">
235 {i18n.t("legal_information")}
237 <div className="col-12">
239 initialContent={this.state.siteForm.legal_information}
240 onContentChange={this.handleSiteLegalInfoChange}
241 hideNavigationWarnings
247 <div className="form-group row">
248 <div className="col-12">
249 <div className="form-check">
251 className="form-check-input"
252 id="create-site-downvotes"
254 checked={this.state.siteForm.enable_downvotes}
257 this.handleSiteEnableDownvotesChange
261 className="form-check-label"
262 htmlFor="create-site-downvotes"
264 {i18n.t("enable_downvotes")}
269 <div className="form-group row">
270 <div className="col-12">
271 <div className="form-check">
273 className="form-check-input"
274 id="create-site-enable-nsfw"
276 checked={this.state.siteForm.enable_nsfw}
277 onChange={linkEvent(this, this.handleSiteEnableNsfwChange)}
280 className="form-check-label"
281 htmlFor="create-site-enable-nsfw"
283 {i18n.t("enable_nsfw")}
288 <div className="form-group row">
289 <div className="col-12">
291 className="form-check-label mr-2"
292 htmlFor="create-site-registration-mode"
294 {i18n.t("registration_mode")}
297 id="create-site-registration-mode"
298 value={this.state.siteForm.registration_mode}
301 this.handleSiteRegistrationModeChange
303 className="custom-select w-auto"
305 <option value={"RequireApplication"}>
306 {i18n.t("require_registration_application")}
308 <option value={"Open"}>{i18n.t("open_registration")}</option>
309 <option value={"Closed"}>{i18n.t("close_registration")}</option>
313 {this.state.siteForm.registration_mode == "RequireApplication" && (
314 <div className="form-group row">
315 <label className="col-12 col-form-label">
316 {i18n.t("application_questionnaire")}
318 <div className="col-12">
320 initialContent={this.state.siteForm.application_question}
321 onContentChange={this.handleSiteApplicationQuestionChange}
322 hideNavigationWarnings
329 <div className="form-group row">
330 <div className="col-12">
331 <div className="form-check">
333 className="form-check-input"
334 id="create-site-community-creation-admin-only"
336 checked={this.state.siteForm.community_creation_admin_only}
339 this.handleSiteCommunityCreationAdminOnly
343 className="form-check-label"
344 htmlFor="create-site-community-creation-admin-only"
346 {i18n.t("community_creation_admin_only")}
351 <div className="form-group row">
352 <div className="col-12">
353 <div className="form-check">
355 className="form-check-input"
356 id="create-site-require-email-verification"
358 checked={this.state.siteForm.require_email_verification}
361 this.handleSiteRequireEmailVerification
365 className="form-check-label"
366 htmlFor="create-site-require-email-verification"
368 {i18n.t("require_email_verification")}
373 <div className="form-group row">
374 <div className="col-12">
375 <div className="form-check">
377 className="form-check-input"
378 id="create-site-application-email-admins"
380 checked={this.state.siteForm.application_email_admins}
383 this.handleSiteApplicationEmailAdmins
387 className="form-check-label"
388 htmlFor="create-site-email-admins"
390 {i18n.t("application_email_admins")}
395 <div className="form-group row">
396 <div className="col-12">
397 <div className="form-check">
399 className="form-check-input"
400 id="create-site-reports-email-admins"
402 checked={this.state.siteForm.reports_email_admins}
403 onChange={linkEvent(this, this.handleSiteReportsEmailAdmins)}
406 className="form-check-label"
407 htmlFor="create-site-reports-email-admins"
409 {i18n.t("reports_email_admins")}
414 <div className="form-group row">
415 <div className="col-12">
417 className="form-check-label mr-2"
418 htmlFor="create-site-default-theme"
423 id="create-site-default-theme"
424 value={this.state.siteForm.default_theme}
425 onChange={linkEvent(this, this.handleSiteDefaultTheme)}
426 className="custom-select w-auto"
428 <option value="browser">{i18n.t("browser_default")}</option>
429 {this.state.themeList?.map(theme => (
430 <option key={theme} value={theme}>
437 {this.props.showLocal && (
438 <form className="form-group row">
439 <label className="col-sm-3">{i18n.t("listing_type")}</label>
440 <div className="col-sm-9">
443 this.state.siteForm.default_post_listing_type ?? "Local"
446 showSubscribed={false}
447 onChange={this.handleDefaultPostListingTypeChange}
452 <div className="form-group row">
453 <div className="col-12">
454 <div className="form-check">
456 className="form-check-input"
457 id="create-site-private-instance"
459 checked={this.state.siteForm.private_instance}
460 onChange={linkEvent(this, this.handleSitePrivateInstance)}
463 className="form-check-label"
464 htmlFor="create-site-private-instance"
466 {i18n.t("private_instance")}
471 <div className="form-group row">
472 <div className="col-12">
473 <div className="form-check">
475 className="form-check-input"
476 id="create-site-hide-modlog-mod-names"
478 checked={this.state.siteForm.hide_modlog_mod_names}
479 onChange={linkEvent(this, this.handleSiteHideModlogModNames)}
482 className="form-check-label"
483 htmlFor="create-site-hide-modlog-mod-names"
485 {i18n.t("hide_modlog_mod_names")}
490 <div className="form-group row">
492 className="col-12 col-form-label"
493 htmlFor="create-site-slur-filter-regex"
495 {i18n.t("slur_filter_regex")}
497 <div className="col-12">
500 id="create-site-slur-filter-regex"
501 placeholder="(word1|word2)"
502 className="form-control"
503 value={this.state.siteForm.slur_filter_regex}
504 onInput={linkEvent(this, this.handleSiteSlurFilterRegex)}
510 allLanguages={this.props.siteRes.all_languages}
511 siteLanguages={this.props.siteRes.discussion_languages}
512 selectedLanguageIds={this.state.siteForm.discussion_languages}
514 onChange={this.handleDiscussionLanguageChange}
517 <div className="form-group row">
519 className="col-12 col-form-label"
520 htmlFor="create-site-actor-name"
522 {i18n.t("actor_name_max_length")}
524 <div className="col-12">
527 id="create-site-actor-name"
528 className="form-control"
530 value={this.state.siteForm.actor_name_max_length}
531 onInput={linkEvent(this, this.handleSiteActorNameMaxLength)}
535 <div className="form-group row">
536 <div className="col-12">
537 <div className="form-check">
539 className="form-check-input"
540 id="create-site-federation-enabled"
542 checked={this.state.siteForm.federation_enabled}
543 onChange={linkEvent(this, this.handleSiteFederationEnabled)}
546 className="form-check-label"
547 htmlFor="create-site-federation-enabled"
549 {i18n.t("federation_enabled")}
554 {this.state.siteForm.federation_enabled && (
556 <div className="form-group row">
558 className="col-12 col-form-label"
559 htmlFor="create-site-allowed-instances"
561 {i18n.t("allowed_instances")}
563 <div className="col-12">
566 placeholder="instance1.tld,instance2.tld"
567 id="create-site-allowed-instances"
568 className="form-control"
569 value={this.instancesToString(
570 this.state.siteForm.allowed_instances
572 onInput={linkEvent(this, this.handleSiteAllowedInstances)}
576 <div className="form-group row">
578 className="col-12 col-form-label"
579 htmlFor="create-site-blocked-instances"
581 {i18n.t("blocked_instances")}
583 <div className="col-12">
586 placeholder="instance1.tld,instance2.tld"
587 id="create-site-blocked-instances"
588 className="form-control"
589 value={this.instancesToString(
590 this.state.siteForm.blocked_instances
592 onInput={linkEvent(this, this.handleSiteBlockedInstances)}
596 <div className="form-group row">
597 <div className="col-12">
598 <div className="form-check">
600 className="form-check-input"
601 id="create-site-federation-debug"
603 checked={this.state.siteForm.federation_debug}
604 onChange={linkEvent(this, this.handleSiteFederationDebug)}
607 className="form-check-label"
608 htmlFor="create-site-federation-debug"
610 {i18n.t("federation_debug")}
615 <div className="form-group row">
617 className="col-12 col-form-label"
618 htmlFor="create-site-federation-worker-count"
620 {i18n.t("federation_worker_count")}
622 <div className="col-12">
625 id="create-site-federation-worker-count"
626 className="form-control"
628 value={this.state.siteForm.federation_worker_count}
631 this.handleSiteFederationWorkerCount
638 <div className="form-group row">
639 <div className="col-12">
640 <div className="form-check">
642 className="form-check-input"
643 id="create-site-captcha-enabled"
645 checked={this.state.siteForm.captcha_enabled}
646 onChange={linkEvent(this, this.handleSiteCaptchaEnabled)}
649 className="form-check-label"
650 htmlFor="create-site-captcha-enabled"
652 {i18n.t("captcha_enabled")}
657 {this.state.siteForm.captcha_enabled && (
658 <div className="form-group row">
659 <div className="col-12">
661 className="form-check-label mr-2"
662 htmlFor="create-site-captcha-difficulty"
664 {i18n.t("captcha_difficulty")}
667 id="create-site-captcha-difficulty"
668 value={this.state.siteForm.captcha_difficulty}
669 onChange={linkEvent(this, this.handleSiteCaptchaDifficulty)}
670 className="custom-select w-auto"
672 <option value="easy">{i18n.t("easy")}</option>
673 <option value="medium">{i18n.t("medium")}</option>
674 <option value="hard">{i18n.t("hard")}</option>
679 <div className="form-group row">
681 className="col-12 col-form-label"
682 htmlFor="create-site-rate-limit-message"
684 {i18n.t("rate_limit_message")}
686 <div className="col-12">
689 id="create-site-rate-limit-message"
690 className="form-control"
692 value={this.state.siteForm.rate_limit_message}
693 onInput={linkEvent(this, this.handleSiteRateLimitMessage)}
697 <div className="form-group row">
699 className="col-12 col-form-label"
700 htmlFor="create-site-rate-limit-message-per-second"
702 {i18n.t("per_second")}
704 <div className="col-12">
707 id="create-site-rate-limit-message-per-second"
708 className="form-control"
710 value={this.state.siteForm.rate_limit_message_per_second}
713 this.handleSiteRateLimitMessagePerSecond
718 <div className="form-group row">
720 className="col-12 col-form-label"
721 htmlFor="create-site-rate-limit-post"
723 {i18n.t("rate_limit_post")}
725 <div className="col-12">
728 id="create-site-rate-limit-post"
729 className="form-control"
731 value={this.state.siteForm.rate_limit_post}
732 onInput={linkEvent(this, this.handleSiteRateLimitPost)}
736 <div className="form-group row">
738 className="col-12 col-form-label"
739 htmlFor="create-site-rate-limit-post-per-second"
741 {i18n.t("per_second")}
743 <div className="col-12">
746 id="create-site-rate-limit-post-per-second"
747 className="form-control"
749 value={this.state.siteForm.rate_limit_post_per_second}
750 onInput={linkEvent(this, this.handleSiteRateLimitPostPerSecond)}
754 <div className="form-group row">
756 className="col-12 col-form-label"
757 htmlFor="create-site-rate-limit-register"
759 {i18n.t("rate_limit_register")}
761 <div className="col-12">
764 id="create-site-rate-limit-register"
765 className="form-control"
767 value={this.state.siteForm.rate_limit_register}
768 onInput={linkEvent(this, this.handleSiteRateLimitRegister)}
772 <div className="form-group row">
774 className="col-12 col-form-label"
775 htmlFor="create-site-rate-limit-register-per-second"
777 {i18n.t("per_second")}
779 <div className="col-12">
782 id="create-site-rate-limit-register-per-second"
783 className="form-control"
785 value={this.state.siteForm.rate_limit_register_per_second}
788 this.handleSiteRateLimitRegisterPerSecond
793 <div className="form-group row">
795 className="col-12 col-form-label"
796 htmlFor="create-site-rate-limit-image"
798 {i18n.t("rate_limit_image")}
800 <div className="col-12">
803 id="create-site-rate-limit-image"
804 className="form-control"
806 value={this.state.siteForm.rate_limit_image}
807 onInput={linkEvent(this, this.handleSiteRateLimitImage)}
811 <div className="form-group row">
813 className="col-12 col-form-label"
814 htmlFor="create-site-rate-limit-image-per-second"
816 {i18n.t("per_second")}
818 <div className="col-12">
821 id="create-site-rate-limit-image-per-second"
822 className="form-control"
824 value={this.state.siteForm.rate_limit_image_per_second}
827 this.handleSiteRateLimitImagePerSecond
832 <div className="form-group row">
834 className="col-12 col-form-label"
835 htmlFor="create-site-rate-limit-comment"
837 {i18n.t("rate_limit_comment")}
839 <div className="col-12">
842 id="create-site-rate-limit-comment"
843 className="form-control"
845 value={this.state.siteForm.rate_limit_comment}
846 onInput={linkEvent(this, this.handleSiteRateLimitComment)}
850 <div className="form-group row">
852 className="col-12 col-form-label"
853 htmlFor="create-site-rate-limit-comment-per-second"
855 {i18n.t("per_second")}
857 <div className="col-12">
860 id="create-site-rate-limit-comment-per-second"
861 className="form-control"
863 value={this.state.siteForm.rate_limit_comment_per_second}
866 this.handleSiteRateLimitCommentPerSecond
871 <div className="form-group row">
873 className="col-12 col-form-label"
874 htmlFor="create-site-rate-limit-search"
876 {i18n.t("rate_limit_search")}
878 <div className="col-12">
881 id="create-site-rate-limit-search"
882 className="form-control"
884 value={this.state.siteForm.rate_limit_search}
885 onInput={linkEvent(this, this.handleSiteRateLimitSearch)}
889 <div className="form-group row">
891 className="col-12 col-form-label"
892 htmlFor="create-site-rate-limit-search-per-second"
894 {i18n.t("per_second")}
896 <div className="col-12">
899 id="create-site-rate-limit-search-per-second"
900 className="form-control"
902 value={this.state.siteForm.rate_limit_search_per_second}
905 this.handleSiteRateLimitSearchPerSecond
911 <div className="form-group row">
912 <div className="col-12">
915 className="btn btn-secondary mr-2"
916 disabled={this.state.loading}
918 {this.state.loading ? (
921 capitalizeFirstLetter(i18n.t("save"))
923 capitalizeFirstLetter(i18n.t("create"))
933 handleCreateSiteSubmit(i: SiteForm, event: any) {
934 event.preventDefault();
935 i.setState({ loading: true });
936 let auth = myAuth() ?? "TODO";
937 i.setState(s => ((s.siteForm.auth = auth), s));
938 if (i.props.siteRes.site_view.local_site.site_setup) {
939 WebSocketService.Instance.send(wsClient.editSite(i.state.siteForm));
941 let sForm = i.state.siteForm;
942 let form: CreateSite = {
943 name: sForm.name ?? "My site",
944 sidebar: sForm.sidebar,
945 description: sForm.description,
947 banner: sForm.banner,
948 community_creation_admin_only: sForm.community_creation_admin_only,
949 enable_nsfw: sForm.enable_nsfw,
950 enable_downvotes: sForm.enable_downvotes,
951 application_question: sForm.application_question,
952 registration_mode: sForm.registration_mode,
953 require_email_verification: sForm.require_email_verification,
954 private_instance: sForm.private_instance,
955 default_theme: sForm.default_theme,
956 default_post_listing_type: sForm.default_post_listing_type,
957 application_email_admins: sForm.application_email_admins,
958 hide_modlog_mod_names: sForm.hide_modlog_mod_names,
959 legal_information: sForm.legal_information,
960 slur_filter_regex: sForm.slur_filter_regex,
961 actor_name_max_length: sForm.actor_name_max_length,
962 rate_limit_message: sForm.rate_limit_message,
963 rate_limit_message_per_second: sForm.rate_limit_message_per_second,
964 rate_limit_comment: sForm.rate_limit_comment,
965 rate_limit_comment_per_second: sForm.rate_limit_comment_per_second,
966 rate_limit_image: sForm.rate_limit_image,
967 rate_limit_image_per_second: sForm.rate_limit_image_per_second,
968 rate_limit_post: sForm.rate_limit_post,
969 rate_limit_post_per_second: sForm.rate_limit_post_per_second,
970 rate_limit_register: sForm.rate_limit_register,
971 rate_limit_register_per_second: sForm.rate_limit_register_per_second,
972 rate_limit_search: sForm.rate_limit_search,
973 rate_limit_search_per_second: sForm.rate_limit_search_per_second,
974 federation_enabled: sForm.federation_enabled,
975 federation_debug: sForm.federation_debug,
976 federation_worker_count: sForm.federation_worker_count,
977 captcha_enabled: sForm.captcha_enabled,
978 captcha_difficulty: sForm.captcha_difficulty,
979 allowed_instances: sForm.allowed_instances,
980 blocked_instances: sForm.blocked_instances,
981 discussion_languages: sForm.discussion_languages,
984 WebSocketService.Instance.send(wsClient.createSite(form));
989 instancesToString(opt?: string[]): string {
990 return opt ? opt.join(",") : "";
993 handleSiteAllowedInstances(i: SiteForm, event: any) {
994 let list = splitToList(event.target.value);
995 i.setState(s => ((s.siteForm.allowed_instances = list), s));
998 handleSiteBlockedInstances(i: SiteForm, event: any) {
999 let list = splitToList(event.target.value);
1000 i.setState(s => ((s.siteForm.blocked_instances = list), s));
1003 handleSiteNameChange(i: SiteForm, event: any) {
1004 i.state.siteForm.name = event.target.value;
1005 i.setState(i.state);
1008 handleSiteSidebarChange(val: string) {
1009 this.setState(s => ((s.siteForm.sidebar = val), s));
1012 handleSiteLegalInfoChange(val: string) {
1013 this.setState(s => ((s.siteForm.legal_information = val), s));
1016 handleTaglineChange(i: SiteForm, index: number, val: string) {
1017 let taglines = i.state.siteForm.taglines;
1019 taglines[index] = val;
1020 i.setState(i.state);
1024 handleDeleteTaglineClick(
1027 event: InfernoMouseEvent<HTMLButtonElement>
1029 event.preventDefault();
1030 let taglines = i.state.siteForm.taglines;
1032 taglines.splice(index, 1);
1033 i.state.siteForm.taglines = undefined;
1034 i.setState(i.state);
1035 i.state.siteForm.taglines = taglines;
1036 i.setState(i.state);
1040 handleAddTaglineClick(
1042 event: InfernoMouseEvent<HTMLButtonElement>
1044 event.preventDefault();
1045 if (!i.state.siteForm.taglines) {
1046 i.state.siteForm.taglines = [];
1048 i.state.siteForm.taglines.push("");
1049 i.setState(i.state);
1052 handleSiteApplicationQuestionChange(val: string) {
1053 this.setState(s => ((s.siteForm.application_question = val), s));
1056 handleSiteDescChange(i: SiteForm, event: any) {
1057 i.state.siteForm.description = event.target.value;
1058 i.setState(i.state);
1061 handleSiteEnableNsfwChange(i: SiteForm, event: any) {
1062 i.state.siteForm.enable_nsfw = event.target.checked;
1063 i.setState(i.state);
1066 handleSiteRegistrationModeChange(i: SiteForm, event: any) {
1067 i.state.siteForm.registration_mode = event.target.value;
1068 i.setState(i.state);
1071 handleSiteCommunityCreationAdminOnly(i: SiteForm, event: any) {
1072 i.state.siteForm.community_creation_admin_only = event.target.checked;
1073 i.setState(i.state);
1076 handleSiteEnableDownvotesChange(i: SiteForm, event: any) {
1077 i.state.siteForm.enable_downvotes = event.target.checked;
1078 i.setState(i.state);
1081 handleSiteRequireEmailVerification(i: SiteForm, event: any) {
1082 i.state.siteForm.require_email_verification = event.target.checked;
1083 i.setState(i.state);
1086 handleSiteApplicationEmailAdmins(i: SiteForm, event: any) {
1087 i.state.siteForm.application_email_admins = event.target.checked;
1088 i.setState(i.state);
1091 handleSiteReportsEmailAdmins(i: SiteForm, event: any) {
1092 i.state.siteForm.reports_email_admins = event.target.checked;
1093 i.setState(i.state);
1096 handleSitePrivateInstance(i: SiteForm, event: any) {
1097 i.state.siteForm.private_instance = event.target.checked;
1098 i.setState(i.state);
1101 handleSiteHideModlogModNames(i: SiteForm, event: any) {
1102 i.state.siteForm.hide_modlog_mod_names = event.target.checked;
1103 i.setState(i.state);
1106 handleSiteDefaultTheme(i: SiteForm, event: any) {
1107 i.state.siteForm.default_theme = event.target.value;
1108 i.setState(i.state);
1111 handleIconUpload(url: string) {
1112 this.setState(s => ((s.siteForm.icon = url), s));
1115 handleIconRemove() {
1116 this.setState(s => ((s.siteForm.icon = ""), s));
1119 handleBannerUpload(url: string) {
1120 this.setState(s => ((s.siteForm.banner = url), s));
1123 handleBannerRemove() {
1124 this.setState(s => ((s.siteForm.banner = ""), s));
1127 handleSiteSlurFilterRegex(i: SiteForm, event: any) {
1128 i.setState(s => ((s.siteForm.slur_filter_regex = event.target.value), s));
1131 handleSiteActorNameMaxLength(i: SiteForm, event: any) {
1133 s => ((s.siteForm.actor_name_max_length = Number(event.target.value)), s)
1137 handleSiteRateLimitMessage(i: SiteForm, event: any) {
1139 s => ((s.siteForm.rate_limit_message = Number(event.target.value)), s)
1143 handleSiteRateLimitMessagePerSecond(i: SiteForm, event: any) {
1146 (s.siteForm.rate_limit_message_per_second = Number(event.target.value)),
1152 handleSiteRateLimitPost(i: SiteForm, event: any) {
1154 s => ((s.siteForm.rate_limit_post = Number(event.target.value)), s)
1158 handleSiteRateLimitPostPerSecond(i: SiteForm, event: any) {
1161 (s.siteForm.rate_limit_post_per_second = Number(event.target.value)), s
1166 handleSiteRateLimitImage(i: SiteForm, event: any) {
1168 s => ((s.siteForm.rate_limit_image = Number(event.target.value)), s)
1172 handleSiteRateLimitImagePerSecond(i: SiteForm, event: any) {
1175 (s.siteForm.rate_limit_image_per_second = Number(event.target.value)), s
1180 handleSiteRateLimitComment(i: SiteForm, event: any) {
1182 s => ((s.siteForm.rate_limit_comment = Number(event.target.value)), s)
1186 handleSiteRateLimitCommentPerSecond(i: SiteForm, event: any) {
1189 (s.siteForm.rate_limit_comment_per_second = Number(event.target.value)),
1195 handleSiteRateLimitSearch(i: SiteForm, event: any) {
1197 s => ((s.siteForm.rate_limit_search = Number(event.target.value)), s)
1201 handleSiteRateLimitSearchPerSecond(i: SiteForm, event: any) {
1204 (s.siteForm.rate_limit_search_per_second = Number(event.target.value)),
1210 handleSiteRateLimitRegister(i: SiteForm, event: any) {
1212 s => ((s.siteForm.rate_limit_register = Number(event.target.value)), s)
1216 handleSiteRateLimitRegisterPerSecond(i: SiteForm, event: any) {
1219 (s.siteForm.rate_limit_register_per_second = Number(
1227 handleSiteFederationEnabled(i: SiteForm, event: any) {
1228 i.state.siteForm.federation_enabled = event.target.checked;
1229 i.setState(i.state);
1232 handleSiteFederationDebug(i: SiteForm, event: any) {
1233 i.state.siteForm.federation_debug = event.target.checked;
1234 i.setState(i.state);
1237 handleSiteFederationWorkerCount(i: SiteForm, event: any) {
1240 (s.siteForm.federation_worker_count = Number(event.target.value)), s
1245 handleSiteCaptchaEnabled(i: SiteForm, event: any) {
1246 i.state.siteForm.captcha_enabled = event.target.checked;
1247 i.setState(i.state);
1250 handleSiteCaptchaDifficulty(i: SiteForm, event: any) {
1251 i.setState(s => ((s.siteForm.captcha_difficulty = event.target.value), s));
1254 handleDiscussionLanguageChange(val: number[]) {
1255 this.setState(s => ((s.siteForm.discussion_languages = val), s));
1258 handleDefaultPostListingTypeChange(val: ListingType) {
1259 this.setState(s => ((s.siteForm.default_post_listing_type = val), s));
1263 function splitToList(commaList: string): string[] {
1264 if (commaList !== "") {
1265 let list = commaList.trim().split(",");