1 import { Component, InfernoMouseEvent, linkEvent } from "inferno";
2 import { Prompt } from "inferno-router";
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;
29 interface SiteFormState {
35 export class SiteForm extends Component<SiteFormProps, SiteFormState> {
36 state: SiteFormState = {
43 constructor(props: any, context: any) {
44 super(props, context);
46 this.handleSiteSidebarChange = this.handleSiteSidebarChange.bind(this);
47 this.handleSiteLegalInfoChange = this.handleSiteLegalInfoChange.bind(this);
48 this.handleSiteApplicationQuestionChange =
49 this.handleSiteApplicationQuestionChange.bind(this);
51 this.handleIconUpload = this.handleIconUpload.bind(this);
52 this.handleIconRemove = this.handleIconRemove.bind(this);
54 this.handleBannerUpload = this.handleBannerUpload.bind(this);
55 this.handleBannerRemove = this.handleBannerRemove.bind(this);
57 this.handleDefaultPostListingTypeChange =
58 this.handleDefaultPostListingTypeChange.bind(this);
60 this.handleDiscussionLanguageChange =
61 this.handleDiscussionLanguageChange.bind(this);
63 let site = this.props.siteRes.site_view.site;
64 let ls = this.props.siteRes.site_view.local_site;
65 let lsrl = this.props.siteRes.site_view.local_site_rate_limit;
70 sidebar: site.sidebar,
71 description: site.description,
72 enable_downvotes: ls.enable_downvotes,
73 registration_mode: ls.registration_mode,
74 enable_nsfw: ls.enable_nsfw,
75 community_creation_admin_only: ls.community_creation_admin_only,
78 require_email_verification: ls.require_email_verification,
79 application_question: ls.application_question,
80 private_instance: ls.private_instance,
81 default_theme: ls.default_theme,
82 default_post_listing_type: ls.default_post_listing_type,
83 legal_information: ls.legal_information,
84 application_email_admins: ls.application_email_admins,
85 reports_email_admins: ls.reports_email_admins,
86 hide_modlog_mod_names: ls.hide_modlog_mod_names,
87 discussion_languages: this.props.siteRes.discussion_languages,
88 slur_filter_regex: ls.slur_filter_regex,
89 actor_name_max_length: ls.actor_name_max_length,
90 rate_limit_message: lsrl.message,
91 rate_limit_message_per_second: lsrl.message_per_second,
92 rate_limit_comment: lsrl.comment,
93 rate_limit_comment_per_second: lsrl.comment_per_second,
94 rate_limit_image: lsrl.image,
95 rate_limit_image_per_second: lsrl.image_per_second,
96 rate_limit_post: lsrl.post,
97 rate_limit_post_per_second: lsrl.post_per_second,
98 rate_limit_register: lsrl.register,
99 rate_limit_register_per_second: lsrl.register_per_second,
100 rate_limit_search: lsrl.search,
101 rate_limit_search_per_second: lsrl.search_per_second,
102 federation_enabled: ls.federation_enabled,
103 federation_debug: ls.federation_debug,
104 federation_worker_count: ls.federation_worker_count,
105 captcha_enabled: ls.captcha_enabled,
106 captcha_difficulty: ls.captcha_difficulty,
107 allowed_instances: this.props.siteRes.federated_instances?.allowed,
108 blocked_instances: this.props.siteRes.federated_instances?.blocked,
114 async componentDidMount() {
115 this.setState({ themeList: await fetchThemeList() });
118 // Necessary to stop the loading
119 componentWillReceiveProps() {
120 this.setState({ loading: false });
123 componentDidUpdate() {
125 !this.state.loading &&
126 !this.props.siteRes.site_view.local_site.site_setup &&
127 (this.state.siteForm.name ||
128 this.state.siteForm.sidebar ||
129 this.state.siteForm.application_question ||
130 this.state.siteForm.description)
132 window.onbeforeunload = () => true;
134 window.onbeforeunload = null;
138 componentWillUnmount() {
139 window.onbeforeunload = null;
143 let siteSetup = this.props.siteRes.site_view.local_site.site_setup;
148 !this.state.loading &&
150 (this.state.siteForm.name ||
151 this.state.siteForm.sidebar ||
152 this.state.siteForm.application_question ||
153 this.state.siteForm.description)
155 message={i18n.t("block_leaving")}
157 <form onSubmit={linkEvent(this, this.handleCreateSiteSubmit)}>
160 ? capitalizeFirstLetter(i18n.t("save"))
161 : capitalizeFirstLetter(i18n.t("name"))
162 } ${i18n.t("your_site")}`}</h5>
163 <div className="form-group row">
164 <label className="col-12 col-form-label" htmlFor="create-site-name">
167 <div className="col-12">
170 id="create-site-name"
171 className="form-control"
172 value={this.state.siteForm.name}
173 onInput={linkEvent(this, this.handleSiteNameChange)}
180 <div className="form-group">
181 <label>{i18n.t("icon")}</label>
183 uploadTitle={i18n.t("upload_icon")}
184 imageSrc={this.state.siteForm.icon}
185 onUpload={this.handleIconUpload}
186 onRemove={this.handleIconRemove}
190 <div className="form-group">
191 <label>{i18n.t("banner")}</label>
193 uploadTitle={i18n.t("upload_banner")}
194 imageSrc={this.state.siteForm.banner}
195 onUpload={this.handleBannerUpload}
196 onRemove={this.handleBannerRemove}
199 <div className="form-group row">
200 <label className="col-12 col-form-label" htmlFor="site-desc">
201 {i18n.t("description")}
203 <div className="col-12">
206 className="form-control"
208 value={this.state.siteForm.description}
209 onInput={linkEvent(this, this.handleSiteDescChange)}
214 <div className="form-group row">
215 <label className="col-12 col-form-label">{i18n.t("sidebar")}</label>
216 <div className="col-12">
218 initialContent={this.state.siteForm.sidebar}
219 onContentChange={this.handleSiteSidebarChange}
220 hideNavigationWarnings
226 <div className="form-group row">
227 <label className="col-12 col-form-label">
228 {i18n.t("legal_information")}
230 <div className="col-12">
232 initialContent={this.state.siteForm.legal_information}
233 onContentChange={this.handleSiteLegalInfoChange}
234 hideNavigationWarnings
240 <div className="form-group row">
241 <div className="col-12">
242 <div className="form-check">
244 className="form-check-input"
245 id="create-site-downvotes"
247 checked={this.state.siteForm.enable_downvotes}
250 this.handleSiteEnableDownvotesChange
254 className="form-check-label"
255 htmlFor="create-site-downvotes"
257 {i18n.t("enable_downvotes")}
262 <div className="form-group row">
263 <div className="col-12">
264 <div className="form-check">
266 className="form-check-input"
267 id="create-site-enable-nsfw"
269 checked={this.state.siteForm.enable_nsfw}
270 onChange={linkEvent(this, this.handleSiteEnableNsfwChange)}
273 className="form-check-label"
274 htmlFor="create-site-enable-nsfw"
276 {i18n.t("enable_nsfw")}
281 <div className="form-group row">
282 <div className="col-12">
284 className="form-check-label mr-2"
285 htmlFor="create-site-registration-mode"
287 {i18n.t("registration_mode")}
290 id="create-site-registration-mode"
291 value={this.state.siteForm.registration_mode}
294 this.handleSiteRegistrationModeChange
296 className="custom-select w-auto"
298 <option value={RegistrationMode.RequireApplication}>
299 {i18n.t("require_registration_application")}
301 <option value={RegistrationMode.Open}>
302 {i18n.t("open_registration")}
304 <option value={RegistrationMode.Closed}>
305 {i18n.t("close_registration")}
310 {this.state.siteForm.registration_mode ==
311 RegistrationMode.RequireApplication && (
312 <div className="form-group row">
313 <label className="col-12 col-form-label">
314 {i18n.t("application_questionnaire")}
316 <div className="col-12">
318 initialContent={this.state.siteForm.application_question}
319 onContentChange={this.handleSiteApplicationQuestionChange}
320 hideNavigationWarnings
327 <div className="form-group row">
328 <div className="col-12">
329 <div className="form-check">
331 className="form-check-input"
332 id="create-site-community-creation-admin-only"
334 checked={this.state.siteForm.community_creation_admin_only}
337 this.handleSiteCommunityCreationAdminOnly
341 className="form-check-label"
342 htmlFor="create-site-community-creation-admin-only"
344 {i18n.t("community_creation_admin_only")}
349 <div className="form-group row">
350 <div className="col-12">
351 <div className="form-check">
353 className="form-check-input"
354 id="create-site-require-email-verification"
356 checked={this.state.siteForm.require_email_verification}
359 this.handleSiteRequireEmailVerification
363 className="form-check-label"
364 htmlFor="create-site-require-email-verification"
366 {i18n.t("require_email_verification")}
371 <div className="form-group row">
372 <div className="col-12">
373 <div className="form-check">
375 className="form-check-input"
376 id="create-site-application-email-admins"
378 checked={this.state.siteForm.application_email_admins}
381 this.handleSiteApplicationEmailAdmins
385 className="form-check-label"
386 htmlFor="create-site-email-admins"
388 {i18n.t("application_email_admins")}
393 <div className="form-group row">
394 <div className="col-12">
395 <div className="form-check">
397 className="form-check-input"
398 id="create-site-reports-email-admins"
400 checked={this.state.siteForm.reports_email_admins}
401 onChange={linkEvent(this, this.handleSiteReportsEmailAdmins)}
404 className="form-check-label"
405 htmlFor="create-site-reports-email-admins"
407 {i18n.t("reports_email_admins")}
412 <div className="form-group row">
413 <div className="col-12">
415 className="form-check-label mr-2"
416 htmlFor="create-site-default-theme"
421 id="create-site-default-theme"
422 value={this.state.siteForm.default_theme}
423 onChange={linkEvent(this, this.handleSiteDefaultTheme)}
424 className="custom-select w-auto"
426 <option value="browser">{i18n.t("browser_default")}</option>
427 {this.state.themeList?.map(theme => (
428 <option key={theme} value={theme}>
435 {this.props.showLocal && (
436 <form className="form-group row">
437 <label className="col-sm-3">{i18n.t("listing_type")}</label>
438 <div className="col-sm-9">
442 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) {
1261 (s.siteForm.default_post_listing_type = ListingType[ListingType[val]]),
1268 function splitToList(commaList: string): string[] {
1269 if (commaList !== "") {
1270 let list = commaList.trim().split(",");