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 { Icon, 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 hide_modlog_mod_names: ls.hide_modlog_mod_names,
86 discussion_languages: this.props.siteRes.discussion_languages,
87 slur_filter_regex: ls.slur_filter_regex,
88 actor_name_max_length: ls.actor_name_max_length,
89 rate_limit_message: lsrl.message,
90 rate_limit_message_per_second: lsrl.message_per_second,
91 rate_limit_comment: lsrl.comment,
92 rate_limit_comment_per_second: lsrl.comment_per_second,
93 rate_limit_image: lsrl.image,
94 rate_limit_image_per_second: lsrl.image_per_second,
95 rate_limit_post: lsrl.post,
96 rate_limit_post_per_second: lsrl.post_per_second,
97 rate_limit_register: lsrl.register,
98 rate_limit_register_per_second: lsrl.register_per_second,
99 rate_limit_search: lsrl.search,
100 rate_limit_search_per_second: lsrl.search_per_second,
101 federation_enabled: ls.federation_enabled,
102 federation_debug: ls.federation_debug,
103 federation_worker_count: ls.federation_worker_count,
104 captcha_enabled: ls.captcha_enabled,
105 captcha_difficulty: ls.captcha_difficulty,
106 allowed_instances: this.props.siteRes.federated_instances?.allowed,
107 blocked_instances: this.props.siteRes.federated_instances?.blocked,
108 taglines: this.props.siteRes.taglines?.map(x => x.content),
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">
396 className="form-check-label mr-2"
397 htmlFor="create-site-default-theme"
402 id="create-site-default-theme"
403 value={this.state.siteForm.default_theme}
404 onChange={linkEvent(this, this.handleSiteDefaultTheme)}
405 className="custom-select w-auto"
407 <option value="browser">{i18n.t("browser_default")}</option>
408 {this.state.themeList?.map(theme => (
409 <option key={theme} value={theme}>
416 {this.props.showLocal && (
417 <form className="form-group row">
418 <label className="col-sm-3">{i18n.t("listing_type")}</label>
419 <div className="col-sm-9">
423 this.state.siteForm.default_post_listing_type ?? "Local"
427 showSubscribed={false}
428 onChange={this.handleDefaultPostListingTypeChange}
433 <div className="form-group row">
434 <div className="col-12">
435 <div className="form-check">
437 className="form-check-input"
438 id="create-site-private-instance"
440 checked={this.state.siteForm.private_instance}
441 onChange={linkEvent(this, this.handleSitePrivateInstance)}
444 className="form-check-label"
445 htmlFor="create-site-private-instance"
447 {i18n.t("private_instance")}
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-hide-modlog-mod-names"
459 checked={this.state.siteForm.hide_modlog_mod_names}
460 onChange={linkEvent(this, this.handleSiteHideModlogModNames)}
463 className="form-check-label"
464 htmlFor="create-site-hide-modlog-mod-names"
466 {i18n.t("hide_modlog_mod_names")}
471 <div className="form-group row">
473 className="col-12 col-form-label"
474 htmlFor="create-site-slur-filter-regex"
476 {i18n.t("slur_filter_regex")}
478 <div className="col-12">
481 id="create-site-slur-filter-regex"
482 placeholder="(word1|word2)"
483 className="form-control"
484 value={this.state.siteForm.slur_filter_regex}
485 onInput={linkEvent(this, this.handleSiteSlurFilterRegex)}
491 allLanguages={this.props.siteRes.all_languages}
492 siteLanguages={this.props.siteRes.discussion_languages}
493 selectedLanguageIds={this.state.siteForm.discussion_languages}
495 onChange={this.handleDiscussionLanguageChange}
498 <div className="form-group row">
500 className="col-12 col-form-label"
501 htmlFor="create-site-actor-name"
503 {i18n.t("actor_name_max_length")}
505 <div className="col-12">
508 id="create-site-actor-name"
509 className="form-control"
511 value={this.state.siteForm.actor_name_max_length}
512 onInput={linkEvent(this, this.handleSiteActorNameMaxLength)}
516 <div className="form-group row">
517 <div className="col-12">
518 <div className="form-check">
520 className="form-check-input"
521 id="create-site-federation-enabled"
523 checked={this.state.siteForm.federation_enabled}
524 onChange={linkEvent(this, this.handleSiteFederationEnabled)}
527 className="form-check-label"
528 htmlFor="create-site-federation-enabled"
530 {i18n.t("federation_enabled")}
535 {this.state.siteForm.federation_enabled && (
537 <div className="form-group row">
539 className="col-12 col-form-label"
540 htmlFor="create-site-allowed-instances"
542 {i18n.t("allowed_instances")}
544 <div className="col-12">
547 placeholder="instance1.tld,instance2.tld"
548 id="create-site-allowed-instances"
549 className="form-control"
550 value={this.instancesToString(
551 this.state.siteForm.allowed_instances
553 onInput={linkEvent(this, this.handleSiteAllowedInstances)}
557 <div className="form-group row">
559 className="col-12 col-form-label"
560 htmlFor="create-site-blocked-instances"
562 {i18n.t("blocked_instances")}
564 <div className="col-12">
567 placeholder="instance1.tld,instance2.tld"
568 id="create-site-blocked-instances"
569 className="form-control"
570 value={this.instancesToString(
571 this.state.siteForm.blocked_instances
573 onInput={linkEvent(this, this.handleSiteBlockedInstances)}
577 <div className="form-group row">
578 <div className="col-12">
579 <div className="form-check">
581 className="form-check-input"
582 id="create-site-federation-debug"
584 checked={this.state.siteForm.federation_debug}
585 onChange={linkEvent(this, this.handleSiteFederationDebug)}
588 className="form-check-label"
589 htmlFor="create-site-federation-debug"
591 {i18n.t("federation_debug")}
596 <div className="form-group row">
598 className="col-12 col-form-label"
599 htmlFor="create-site-federation-worker-count"
601 {i18n.t("federation_worker_count")}
603 <div className="col-12">
606 id="create-site-federation-worker-count"
607 className="form-control"
609 value={this.state.siteForm.federation_worker_count}
612 this.handleSiteFederationWorkerCount
619 <div className="form-group row">
620 <div className="col-12">
621 <div className="form-check">
623 className="form-check-input"
624 id="create-site-captcha-enabled"
626 checked={this.state.siteForm.captcha_enabled}
627 onChange={linkEvent(this, this.handleSiteCaptchaEnabled)}
630 className="form-check-label"
631 htmlFor="create-site-captcha-enabled"
633 {i18n.t("captcha_enabled")}
638 {this.state.siteForm.captcha_enabled && (
639 <div className="form-group row">
640 <div className="col-12">
642 className="form-check-label mr-2"
643 htmlFor="create-site-captcha-difficulty"
645 {i18n.t("captcha_difficulty")}
648 id="create-site-captcha-difficulty"
649 value={this.state.siteForm.captcha_difficulty}
650 onChange={linkEvent(this, this.handleSiteCaptchaDifficulty)}
651 className="custom-select w-auto"
653 <option value="easy">{i18n.t("easy")}</option>
654 <option value="medium">{i18n.t("medium")}</option>
655 <option value="hard">{i18n.t("hard")}</option>
660 <div className="form-group row">
662 className="col-12 col-form-label"
663 htmlFor="create-site-rate-limit-message"
665 {i18n.t("rate_limit_message")}
667 <div className="col-12">
670 id="create-site-rate-limit-message"
671 className="form-control"
673 value={this.state.siteForm.rate_limit_message}
674 onInput={linkEvent(this, this.handleSiteRateLimitMessage)}
678 <div className="form-group row">
680 className="col-12 col-form-label"
681 htmlFor="create-site-rate-limit-message-per-second"
683 {i18n.t("per_second")}
685 <div className="col-12">
688 id="create-site-rate-limit-message-per-second"
689 className="form-control"
691 value={this.state.siteForm.rate_limit_message_per_second}
694 this.handleSiteRateLimitMessagePerSecond
699 <div className="form-group row">
701 className="col-12 col-form-label"
702 htmlFor="create-site-rate-limit-post"
704 {i18n.t("rate_limit_post")}
706 <div className="col-12">
709 id="create-site-rate-limit-post"
710 className="form-control"
712 value={this.state.siteForm.rate_limit_post}
713 onInput={linkEvent(this, this.handleSiteRateLimitPost)}
717 <div className="form-group row">
719 className="col-12 col-form-label"
720 htmlFor="create-site-rate-limit-post-per-second"
722 {i18n.t("per_second")}
724 <div className="col-12">
727 id="create-site-rate-limit-post-per-second"
728 className="form-control"
730 value={this.state.siteForm.rate_limit_post_per_second}
731 onInput={linkEvent(this, this.handleSiteRateLimitPostPerSecond)}
735 <div className="form-group row">
737 className="col-12 col-form-label"
738 htmlFor="create-site-rate-limit-register"
740 {i18n.t("rate_limit_register")}
742 <div className="col-12">
745 id="create-site-rate-limit-register"
746 className="form-control"
748 value={this.state.siteForm.rate_limit_register}
749 onInput={linkEvent(this, this.handleSiteRateLimitRegister)}
753 <div className="form-group row">
755 className="col-12 col-form-label"
756 htmlFor="create-site-rate-limit-register-per-second"
758 {i18n.t("per_second")}
760 <div className="col-12">
763 id="create-site-rate-limit-register-per-second"
764 className="form-control"
766 value={this.state.siteForm.rate_limit_register_per_second}
769 this.handleSiteRateLimitRegisterPerSecond
774 <div className="form-group row">
776 className="col-12 col-form-label"
777 htmlFor="create-site-rate-limit-image"
779 {i18n.t("rate_limit_image")}
781 <div className="col-12">
784 id="create-site-rate-limit-image"
785 className="form-control"
787 value={this.state.siteForm.rate_limit_image}
788 onInput={linkEvent(this, this.handleSiteRateLimitImage)}
792 <div className="form-group row">
794 className="col-12 col-form-label"
795 htmlFor="create-site-rate-limit-image-per-second"
797 {i18n.t("per_second")}
799 <div className="col-12">
802 id="create-site-rate-limit-image-per-second"
803 className="form-control"
805 value={this.state.siteForm.rate_limit_image_per_second}
808 this.handleSiteRateLimitImagePerSecond
813 <div className="form-group row">
815 className="col-12 col-form-label"
816 htmlFor="create-site-rate-limit-comment"
818 {i18n.t("rate_limit_comment")}
820 <div className="col-12">
823 id="create-site-rate-limit-comment"
824 className="form-control"
826 value={this.state.siteForm.rate_limit_comment}
827 onInput={linkEvent(this, this.handleSiteRateLimitComment)}
831 <div className="form-group row">
833 className="col-12 col-form-label"
834 htmlFor="create-site-rate-limit-comment-per-second"
836 {i18n.t("per_second")}
838 <div className="col-12">
841 id="create-site-rate-limit-comment-per-second"
842 className="form-control"
844 value={this.state.siteForm.rate_limit_comment_per_second}
847 this.handleSiteRateLimitCommentPerSecond
852 <div className="form-group row">
854 className="col-12 col-form-label"
855 htmlFor="create-site-rate-limit-search"
857 {i18n.t("rate_limit_search")}
859 <div className="col-12">
862 id="create-site-rate-limit-search"
863 className="form-control"
865 value={this.state.siteForm.rate_limit_search}
866 onInput={linkEvent(this, this.handleSiteRateLimitSearch)}
870 <div className="form-group row">
872 className="col-12 col-form-label"
873 htmlFor="create-site-rate-limit-search-per-second"
875 {i18n.t("per_second")}
877 <div className="col-12">
880 id="create-site-rate-limit-search-per-second"
881 className="form-control"
883 value={this.state.siteForm.rate_limit_search_per_second}
886 this.handleSiteRateLimitSearchPerSecond
891 <div className="form-group row">
892 <h5 className="col-12">{i18n.t("taglines")}</h5>
893 <div className="table-responsive col-12">
894 <table id="taglines_table" className="table table-sm table-hover">
895 <thead className="pointer"></thead>
897 {this.state.siteForm.taglines?.map((cv, index) => (
902 onContentChange={s =>
903 this.handleTaglineChange(this, index, s)
905 hideNavigationWarnings
906 allLanguages={this.props.siteRes.all_languages}
908 this.props.siteRes.discussion_languages
912 <td className="text-right">
914 className="btn btn-link btn-animate text-muted"
916 this.handleDeleteTaglineClick(this, index, e)
918 data-tippy-content={i18n.t("delete")}
919 aria-label={i18n.t("delete")}
923 classes={`icon-inline text-danger`}
932 className="btn btn-sm btn-secondary mr-2"
933 onClick={e => this.handleAddTaglineClick(this, e)}
935 {i18n.t("add_tagline")}
939 <div className="form-group row">
940 <div className="col-12">
943 className="btn btn-secondary mr-2"
944 disabled={this.state.loading}
946 {this.state.loading ? (
949 capitalizeFirstLetter(i18n.t("save"))
951 capitalizeFirstLetter(i18n.t("create"))
961 handleCreateSiteSubmit(i: SiteForm, event: any) {
962 event.preventDefault();
963 i.setState({ loading: true });
964 let auth = myAuth() ?? "TODO";
965 i.setState(s => ((s.siteForm.auth = auth), s));
966 if (i.props.siteRes.site_view.local_site.site_setup) {
967 WebSocketService.Instance.send(wsClient.editSite(i.state.siteForm));
969 let sForm = i.state.siteForm;
970 let form: CreateSite = {
971 name: sForm.name ?? "My site",
972 sidebar: sForm.sidebar,
973 description: sForm.description,
975 banner: sForm.banner,
976 community_creation_admin_only: sForm.community_creation_admin_only,
977 enable_nsfw: sForm.enable_nsfw,
978 enable_downvotes: sForm.enable_downvotes,
979 application_question: sForm.application_question,
980 registration_mode: sForm.registration_mode,
981 require_email_verification: sForm.require_email_verification,
982 private_instance: sForm.private_instance,
983 default_theme: sForm.default_theme,
984 default_post_listing_type: sForm.default_post_listing_type,
985 application_email_admins: sForm.application_email_admins,
986 hide_modlog_mod_names: sForm.hide_modlog_mod_names,
987 legal_information: sForm.legal_information,
988 slur_filter_regex: sForm.slur_filter_regex,
989 actor_name_max_length: sForm.actor_name_max_length,
990 rate_limit_message: sForm.rate_limit_message,
991 rate_limit_message_per_second: sForm.rate_limit_message_per_second,
992 rate_limit_comment: sForm.rate_limit_comment,
993 rate_limit_comment_per_second: sForm.rate_limit_comment_per_second,
994 rate_limit_image: sForm.rate_limit_image,
995 rate_limit_image_per_second: sForm.rate_limit_image_per_second,
996 rate_limit_post: sForm.rate_limit_post,
997 rate_limit_post_per_second: sForm.rate_limit_post_per_second,
998 rate_limit_register: sForm.rate_limit_register,
999 rate_limit_register_per_second: sForm.rate_limit_register_per_second,
1000 rate_limit_search: sForm.rate_limit_search,
1001 rate_limit_search_per_second: sForm.rate_limit_search_per_second,
1002 federation_enabled: sForm.federation_enabled,
1003 federation_debug: sForm.federation_debug,
1004 federation_worker_count: sForm.federation_worker_count,
1005 captcha_enabled: sForm.captcha_enabled,
1006 captcha_difficulty: sForm.captcha_difficulty,
1007 allowed_instances: sForm.allowed_instances,
1008 blocked_instances: sForm.blocked_instances,
1009 discussion_languages: sForm.discussion_languages,
1010 taglines: sForm.taglines,
1013 WebSocketService.Instance.send(wsClient.createSite(form));
1015 i.setState(i.state);
1018 instancesToString(opt?: string[]): string {
1019 return opt ? opt.join(",") : "";
1022 handleSiteAllowedInstances(i: SiteForm, event: any) {
1023 let list = splitToList(event.target.value);
1024 i.setState(s => ((s.siteForm.allowed_instances = list), s));
1027 handleSiteBlockedInstances(i: SiteForm, event: any) {
1028 let list = splitToList(event.target.value);
1029 i.setState(s => ((s.siteForm.blocked_instances = list), s));
1032 handleSiteNameChange(i: SiteForm, event: any) {
1033 i.state.siteForm.name = event.target.value;
1034 i.setState(i.state);
1037 handleSiteSidebarChange(val: string) {
1038 this.setState(s => ((s.siteForm.sidebar = val), s));
1041 handleSiteLegalInfoChange(val: string) {
1042 this.setState(s => ((s.siteForm.legal_information = val), s));
1045 handleTaglineChange(i: SiteForm, index: number, val: string) {
1046 let taglines = i.state.siteForm.taglines;
1048 taglines[index] = val;
1049 i.setState(i.state);
1053 handleDeleteTaglineClick(
1056 event: InfernoMouseEvent<HTMLButtonElement>
1058 event.preventDefault();
1059 let taglines = i.state.siteForm.taglines;
1061 taglines.splice(index, 1);
1062 i.state.siteForm.taglines = undefined;
1063 i.setState(i.state);
1064 i.state.siteForm.taglines = taglines;
1065 i.setState(i.state);
1069 handleAddTaglineClick(
1071 event: InfernoMouseEvent<HTMLButtonElement>
1073 event.preventDefault();
1074 if (!i.state.siteForm.taglines) {
1075 i.state.siteForm.taglines = [];
1077 i.state.siteForm.taglines.push("");
1078 i.setState(i.state);
1081 handleSiteApplicationQuestionChange(val: string) {
1082 this.setState(s => ((s.siteForm.application_question = val), s));
1085 handleSiteDescChange(i: SiteForm, event: any) {
1086 i.state.siteForm.description = event.target.value;
1087 i.setState(i.state);
1090 handleSiteEnableNsfwChange(i: SiteForm, event: any) {
1091 i.state.siteForm.enable_nsfw = event.target.checked;
1092 i.setState(i.state);
1095 handleSiteRegistrationModeChange(i: SiteForm, event: any) {
1096 i.state.siteForm.registration_mode = event.target.value;
1097 i.setState(i.state);
1100 handleSiteCommunityCreationAdminOnly(i: SiteForm, event: any) {
1101 i.state.siteForm.community_creation_admin_only = event.target.checked;
1102 i.setState(i.state);
1105 handleSiteEnableDownvotesChange(i: SiteForm, event: any) {
1106 i.state.siteForm.enable_downvotes = event.target.checked;
1107 i.setState(i.state);
1110 handleSiteRequireEmailVerification(i: SiteForm, event: any) {
1111 i.state.siteForm.require_email_verification = event.target.checked;
1112 i.setState(i.state);
1115 handleSiteApplicationEmailAdmins(i: SiteForm, event: any) {
1116 i.state.siteForm.application_email_admins = event.target.checked;
1117 i.setState(i.state);
1120 handleSitePrivateInstance(i: SiteForm, event: any) {
1121 i.state.siteForm.private_instance = event.target.checked;
1122 i.setState(i.state);
1125 handleSiteHideModlogModNames(i: SiteForm, event: any) {
1126 i.state.siteForm.hide_modlog_mod_names = event.target.checked;
1127 i.setState(i.state);
1130 handleSiteDefaultTheme(i: SiteForm, event: any) {
1131 i.state.siteForm.default_theme = event.target.value;
1132 i.setState(i.state);
1135 handleIconUpload(url: string) {
1136 this.setState(s => ((s.siteForm.icon = url), s));
1139 handleIconRemove() {
1140 this.setState(s => ((s.siteForm.icon = ""), s));
1143 handleBannerUpload(url: string) {
1144 this.setState(s => ((s.siteForm.banner = url), s));
1147 handleBannerRemove() {
1148 this.setState(s => ((s.siteForm.banner = ""), s));
1151 handleSiteSlurFilterRegex(i: SiteForm, event: any) {
1152 i.setState(s => ((s.siteForm.slur_filter_regex = event.target.value), s));
1155 handleSiteActorNameMaxLength(i: SiteForm, event: any) {
1157 s => ((s.siteForm.actor_name_max_length = Number(event.target.value)), s)
1161 handleSiteRateLimitMessage(i: SiteForm, event: any) {
1163 s => ((s.siteForm.rate_limit_message = Number(event.target.value)), s)
1167 handleSiteRateLimitMessagePerSecond(i: SiteForm, event: any) {
1170 (s.siteForm.rate_limit_message_per_second = Number(event.target.value)),
1176 handleSiteRateLimitPost(i: SiteForm, event: any) {
1178 s => ((s.siteForm.rate_limit_post = Number(event.target.value)), s)
1182 handleSiteRateLimitPostPerSecond(i: SiteForm, event: any) {
1185 (s.siteForm.rate_limit_post_per_second = Number(event.target.value)), s
1190 handleSiteRateLimitImage(i: SiteForm, event: any) {
1192 s => ((s.siteForm.rate_limit_image = Number(event.target.value)), s)
1196 handleSiteRateLimitImagePerSecond(i: SiteForm, event: any) {
1199 (s.siteForm.rate_limit_image_per_second = Number(event.target.value)), s
1204 handleSiteRateLimitComment(i: SiteForm, event: any) {
1206 s => ((s.siteForm.rate_limit_comment = Number(event.target.value)), s)
1210 handleSiteRateLimitCommentPerSecond(i: SiteForm, event: any) {
1213 (s.siteForm.rate_limit_comment_per_second = Number(event.target.value)),
1219 handleSiteRateLimitSearch(i: SiteForm, event: any) {
1221 s => ((s.siteForm.rate_limit_search = Number(event.target.value)), s)
1225 handleSiteRateLimitSearchPerSecond(i: SiteForm, event: any) {
1228 (s.siteForm.rate_limit_search_per_second = Number(event.target.value)),
1234 handleSiteRateLimitRegister(i: SiteForm, event: any) {
1236 s => ((s.siteForm.rate_limit_register = Number(event.target.value)), s)
1240 handleSiteRateLimitRegisterPerSecond(i: SiteForm, event: any) {
1243 (s.siteForm.rate_limit_register_per_second = Number(
1251 handleSiteFederationEnabled(i: SiteForm, event: any) {
1252 i.state.siteForm.federation_enabled = event.target.checked;
1253 i.setState(i.state);
1256 handleSiteFederationDebug(i: SiteForm, event: any) {
1257 i.state.siteForm.federation_debug = event.target.checked;
1258 i.setState(i.state);
1261 handleSiteFederationWorkerCount(i: SiteForm, event: any) {
1264 (s.siteForm.federation_worker_count = Number(event.target.value)), s
1269 handleSiteCaptchaEnabled(i: SiteForm, event: any) {
1270 i.state.siteForm.captcha_enabled = event.target.checked;
1271 i.setState(i.state);
1274 handleSiteCaptchaDifficulty(i: SiteForm, event: any) {
1275 i.setState(s => ((s.siteForm.captcha_difficulty = event.target.value), s));
1278 handleDiscussionLanguageChange(val: number[]) {
1279 this.setState(s => ((s.siteForm.discussion_languages = val), s));
1282 handleDefaultPostListingTypeChange(val: ListingType) {
1285 (s.siteForm.default_post_listing_type = ListingType[ListingType[val]]),
1292 function splitToList(commaList: string): string[] {
1293 if (commaList !== "") {
1294 let list = commaList.trim().split(",");