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 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,
109 taglines: this.props.siteRes.taglines?.map(x => x.content),
115 async componentDidMount() {
116 this.setState({ themeList: await fetchThemeList() });
119 // Necessary to stop the loading
120 componentWillReceiveProps() {
121 this.setState({ loading: false });
124 componentDidUpdate() {
126 !this.state.loading &&
127 !this.props.siteRes.site_view.local_site.site_setup &&
128 (this.state.siteForm.name ||
129 this.state.siteForm.sidebar ||
130 this.state.siteForm.application_question ||
131 this.state.siteForm.description)
133 window.onbeforeunload = () => true;
135 window.onbeforeunload = null;
139 componentWillUnmount() {
140 window.onbeforeunload = null;
144 let siteSetup = this.props.siteRes.site_view.local_site.site_setup;
149 !this.state.loading &&
151 (this.state.siteForm.name ||
152 this.state.siteForm.sidebar ||
153 this.state.siteForm.application_question ||
154 this.state.siteForm.description)
156 message={i18n.t("block_leaving")}
158 <form onSubmit={linkEvent(this, this.handleCreateSiteSubmit)}>
161 ? capitalizeFirstLetter(i18n.t("save"))
162 : capitalizeFirstLetter(i18n.t("name"))
163 } ${i18n.t("your_site")}`}</h5>
164 <div className="form-group row">
165 <label className="col-12 col-form-label" htmlFor="create-site-name">
168 <div className="col-12">
171 id="create-site-name"
172 className="form-control"
173 value={this.state.siteForm.name}
174 onInput={linkEvent(this, this.handleSiteNameChange)}
181 <div className="form-group">
182 <label>{i18n.t("icon")}</label>
184 uploadTitle={i18n.t("upload_icon")}
185 imageSrc={this.state.siteForm.icon}
186 onUpload={this.handleIconUpload}
187 onRemove={this.handleIconRemove}
191 <div className="form-group">
192 <label>{i18n.t("banner")}</label>
194 uploadTitle={i18n.t("upload_banner")}
195 imageSrc={this.state.siteForm.banner}
196 onUpload={this.handleBannerUpload}
197 onRemove={this.handleBannerRemove}
200 <div className="form-group row">
201 <label className="col-12 col-form-label" htmlFor="site-desc">
202 {i18n.t("description")}
204 <div className="col-12">
207 className="form-control"
209 value={this.state.siteForm.description}
210 onInput={linkEvent(this, this.handleSiteDescChange)}
215 <div className="form-group row">
216 <label className="col-12 col-form-label">{i18n.t("sidebar")}</label>
217 <div className="col-12">
219 initialContent={this.state.siteForm.sidebar}
220 onContentChange={this.handleSiteSidebarChange}
221 hideNavigationWarnings
227 <div className="form-group row">
228 <label className="col-12 col-form-label">
229 {i18n.t("legal_information")}
231 <div className="col-12">
233 initialContent={this.state.siteForm.legal_information}
234 onContentChange={this.handleSiteLegalInfoChange}
235 hideNavigationWarnings
241 <div className="form-group row">
242 <div className="col-12">
243 <div className="form-check">
245 className="form-check-input"
246 id="create-site-downvotes"
248 checked={this.state.siteForm.enable_downvotes}
251 this.handleSiteEnableDownvotesChange
255 className="form-check-label"
256 htmlFor="create-site-downvotes"
258 {i18n.t("enable_downvotes")}
263 <div className="form-group row">
264 <div className="col-12">
265 <div className="form-check">
267 className="form-check-input"
268 id="create-site-enable-nsfw"
270 checked={this.state.siteForm.enable_nsfw}
271 onChange={linkEvent(this, this.handleSiteEnableNsfwChange)}
274 className="form-check-label"
275 htmlFor="create-site-enable-nsfw"
277 {i18n.t("enable_nsfw")}
282 <div className="form-group row">
283 <div className="col-12">
285 className="form-check-label mr-2"
286 htmlFor="create-site-registration-mode"
288 {i18n.t("registration_mode")}
291 id="create-site-registration-mode"
292 value={this.state.siteForm.registration_mode}
295 this.handleSiteRegistrationModeChange
297 className="custom-select w-auto"
299 <option value={RegistrationMode.RequireApplication}>
300 {i18n.t("require_registration_application")}
302 <option value={RegistrationMode.Open}>
303 {i18n.t("open_registration")}
305 <option value={RegistrationMode.Closed}>
306 {i18n.t("close_registration")}
311 {this.state.siteForm.registration_mode ==
312 RegistrationMode.RequireApplication && (
313 <div className="form-group row">
314 <label className="col-12 col-form-label">
315 {i18n.t("application_questionnaire")}
317 <div className="col-12">
319 initialContent={this.state.siteForm.application_question}
320 onContentChange={this.handleSiteApplicationQuestionChange}
321 hideNavigationWarnings
328 <div className="form-group row">
329 <div className="col-12">
330 <div className="form-check">
332 className="form-check-input"
333 id="create-site-community-creation-admin-only"
335 checked={this.state.siteForm.community_creation_admin_only}
338 this.handleSiteCommunityCreationAdminOnly
342 className="form-check-label"
343 htmlFor="create-site-community-creation-admin-only"
345 {i18n.t("community_creation_admin_only")}
350 <div className="form-group row">
351 <div className="col-12">
352 <div className="form-check">
354 className="form-check-input"
355 id="create-site-require-email-verification"
357 checked={this.state.siteForm.require_email_verification}
360 this.handleSiteRequireEmailVerification
364 className="form-check-label"
365 htmlFor="create-site-require-email-verification"
367 {i18n.t("require_email_verification")}
372 <div className="form-group row">
373 <div className="col-12">
374 <div className="form-check">
376 className="form-check-input"
377 id="create-site-application-email-admins"
379 checked={this.state.siteForm.application_email_admins}
382 this.handleSiteApplicationEmailAdmins
386 className="form-check-label"
387 htmlFor="create-site-email-admins"
389 {i18n.t("application_email_admins")}
394 <div className="form-group row">
395 <div className="col-12">
396 <div className="form-check">
398 className="form-check-input"
399 id="create-site-reports-email-admins"
401 checked={this.state.siteForm.reports_email_admins}
402 onChange={linkEvent(this, this.handleSiteReportsEmailAdmins)}
405 className="form-check-label"
406 htmlFor="create-site-reports-email-admins"
408 {i18n.t("reports_email_admins")}
413 <div className="form-group row">
414 <div className="col-12">
416 className="form-check-label mr-2"
417 htmlFor="create-site-default-theme"
422 id="create-site-default-theme"
423 value={this.state.siteForm.default_theme}
424 onChange={linkEvent(this, this.handleSiteDefaultTheme)}
425 className="custom-select w-auto"
427 <option value="browser">{i18n.t("browser_default")}</option>
428 {this.state.themeList?.map(theme => (
429 <option key={theme} value={theme}>
436 {this.props.showLocal && (
437 <form className="form-group row">
438 <label className="col-sm-3">{i18n.t("listing_type")}</label>
439 <div className="col-sm-9">
443 this.state.siteForm.default_post_listing_type ?? "Local"
447 showSubscribed={false}
448 onChange={this.handleDefaultPostListingTypeChange}
453 <div className="form-group row">
454 <div className="col-12">
455 <div className="form-check">
457 className="form-check-input"
458 id="create-site-private-instance"
460 checked={this.state.siteForm.private_instance}
461 onChange={linkEvent(this, this.handleSitePrivateInstance)}
464 className="form-check-label"
465 htmlFor="create-site-private-instance"
467 {i18n.t("private_instance")}
472 <div className="form-group row">
473 <div className="col-12">
474 <div className="form-check">
476 className="form-check-input"
477 id="create-site-hide-modlog-mod-names"
479 checked={this.state.siteForm.hide_modlog_mod_names}
480 onChange={linkEvent(this, this.handleSiteHideModlogModNames)}
483 className="form-check-label"
484 htmlFor="create-site-hide-modlog-mod-names"
486 {i18n.t("hide_modlog_mod_names")}
491 <div className="form-group row">
493 className="col-12 col-form-label"
494 htmlFor="create-site-slur-filter-regex"
496 {i18n.t("slur_filter_regex")}
498 <div className="col-12">
501 id="create-site-slur-filter-regex"
502 placeholder="(word1|word2)"
503 className="form-control"
504 value={this.state.siteForm.slur_filter_regex}
505 onInput={linkEvent(this, this.handleSiteSlurFilterRegex)}
511 allLanguages={this.props.siteRes.all_languages}
512 siteLanguages={this.props.siteRes.discussion_languages}
513 selectedLanguageIds={this.state.siteForm.discussion_languages}
515 onChange={this.handleDiscussionLanguageChange}
518 <div className="form-group row">
520 className="col-12 col-form-label"
521 htmlFor="create-site-actor-name"
523 {i18n.t("actor_name_max_length")}
525 <div className="col-12">
528 id="create-site-actor-name"
529 className="form-control"
531 value={this.state.siteForm.actor_name_max_length}
532 onInput={linkEvent(this, this.handleSiteActorNameMaxLength)}
536 <div className="form-group row">
537 <div className="col-12">
538 <div className="form-check">
540 className="form-check-input"
541 id="create-site-federation-enabled"
543 checked={this.state.siteForm.federation_enabled}
544 onChange={linkEvent(this, this.handleSiteFederationEnabled)}
547 className="form-check-label"
548 htmlFor="create-site-federation-enabled"
550 {i18n.t("federation_enabled")}
555 {this.state.siteForm.federation_enabled && (
557 <div className="form-group row">
559 className="col-12 col-form-label"
560 htmlFor="create-site-allowed-instances"
562 {i18n.t("allowed_instances")}
564 <div className="col-12">
567 placeholder="instance1.tld,instance2.tld"
568 id="create-site-allowed-instances"
569 className="form-control"
570 value={this.instancesToString(
571 this.state.siteForm.allowed_instances
573 onInput={linkEvent(this, this.handleSiteAllowedInstances)}
577 <div className="form-group row">
579 className="col-12 col-form-label"
580 htmlFor="create-site-blocked-instances"
582 {i18n.t("blocked_instances")}
584 <div className="col-12">
587 placeholder="instance1.tld,instance2.tld"
588 id="create-site-blocked-instances"
589 className="form-control"
590 value={this.instancesToString(
591 this.state.siteForm.blocked_instances
593 onInput={linkEvent(this, this.handleSiteBlockedInstances)}
597 <div className="form-group row">
598 <div className="col-12">
599 <div className="form-check">
601 className="form-check-input"
602 id="create-site-federation-debug"
604 checked={this.state.siteForm.federation_debug}
605 onChange={linkEvent(this, this.handleSiteFederationDebug)}
608 className="form-check-label"
609 htmlFor="create-site-federation-debug"
611 {i18n.t("federation_debug")}
616 <div className="form-group row">
618 className="col-12 col-form-label"
619 htmlFor="create-site-federation-worker-count"
621 {i18n.t("federation_worker_count")}
623 <div className="col-12">
626 id="create-site-federation-worker-count"
627 className="form-control"
629 value={this.state.siteForm.federation_worker_count}
632 this.handleSiteFederationWorkerCount
639 <div className="form-group row">
640 <div className="col-12">
641 <div className="form-check">
643 className="form-check-input"
644 id="create-site-captcha-enabled"
646 checked={this.state.siteForm.captcha_enabled}
647 onChange={linkEvent(this, this.handleSiteCaptchaEnabled)}
650 className="form-check-label"
651 htmlFor="create-site-captcha-enabled"
653 {i18n.t("captcha_enabled")}
658 {this.state.siteForm.captcha_enabled && (
659 <div className="form-group row">
660 <div className="col-12">
662 className="form-check-label mr-2"
663 htmlFor="create-site-captcha-difficulty"
665 {i18n.t("captcha_difficulty")}
668 id="create-site-captcha-difficulty"
669 value={this.state.siteForm.captcha_difficulty}
670 onChange={linkEvent(this, this.handleSiteCaptchaDifficulty)}
671 className="custom-select w-auto"
673 <option value="easy">{i18n.t("easy")}</option>
674 <option value="medium">{i18n.t("medium")}</option>
675 <option value="hard">{i18n.t("hard")}</option>
680 <div className="form-group row">
682 className="col-12 col-form-label"
683 htmlFor="create-site-rate-limit-message"
685 {i18n.t("rate_limit_message")}
687 <div className="col-12">
690 id="create-site-rate-limit-message"
691 className="form-control"
693 value={this.state.siteForm.rate_limit_message}
694 onInput={linkEvent(this, this.handleSiteRateLimitMessage)}
698 <div className="form-group row">
700 className="col-12 col-form-label"
701 htmlFor="create-site-rate-limit-message-per-second"
703 {i18n.t("per_second")}
705 <div className="col-12">
708 id="create-site-rate-limit-message-per-second"
709 className="form-control"
711 value={this.state.siteForm.rate_limit_message_per_second}
714 this.handleSiteRateLimitMessagePerSecond
719 <div className="form-group row">
721 className="col-12 col-form-label"
722 htmlFor="create-site-rate-limit-post"
724 {i18n.t("rate_limit_post")}
726 <div className="col-12">
729 id="create-site-rate-limit-post"
730 className="form-control"
732 value={this.state.siteForm.rate_limit_post}
733 onInput={linkEvent(this, this.handleSiteRateLimitPost)}
737 <div className="form-group row">
739 className="col-12 col-form-label"
740 htmlFor="create-site-rate-limit-post-per-second"
742 {i18n.t("per_second")}
744 <div className="col-12">
747 id="create-site-rate-limit-post-per-second"
748 className="form-control"
750 value={this.state.siteForm.rate_limit_post_per_second}
751 onInput={linkEvent(this, this.handleSiteRateLimitPostPerSecond)}
755 <div className="form-group row">
757 className="col-12 col-form-label"
758 htmlFor="create-site-rate-limit-register"
760 {i18n.t("rate_limit_register")}
762 <div className="col-12">
765 id="create-site-rate-limit-register"
766 className="form-control"
768 value={this.state.siteForm.rate_limit_register}
769 onInput={linkEvent(this, this.handleSiteRateLimitRegister)}
773 <div className="form-group row">
775 className="col-12 col-form-label"
776 htmlFor="create-site-rate-limit-register-per-second"
778 {i18n.t("per_second")}
780 <div className="col-12">
783 id="create-site-rate-limit-register-per-second"
784 className="form-control"
786 value={this.state.siteForm.rate_limit_register_per_second}
789 this.handleSiteRateLimitRegisterPerSecond
794 <div className="form-group row">
796 className="col-12 col-form-label"
797 htmlFor="create-site-rate-limit-image"
799 {i18n.t("rate_limit_image")}
801 <div className="col-12">
804 id="create-site-rate-limit-image"
805 className="form-control"
807 value={this.state.siteForm.rate_limit_image}
808 onInput={linkEvent(this, this.handleSiteRateLimitImage)}
812 <div className="form-group row">
814 className="col-12 col-form-label"
815 htmlFor="create-site-rate-limit-image-per-second"
817 {i18n.t("per_second")}
819 <div className="col-12">
822 id="create-site-rate-limit-image-per-second"
823 className="form-control"
825 value={this.state.siteForm.rate_limit_image_per_second}
828 this.handleSiteRateLimitImagePerSecond
833 <div className="form-group row">
835 className="col-12 col-form-label"
836 htmlFor="create-site-rate-limit-comment"
838 {i18n.t("rate_limit_comment")}
840 <div className="col-12">
843 id="create-site-rate-limit-comment"
844 className="form-control"
846 value={this.state.siteForm.rate_limit_comment}
847 onInput={linkEvent(this, this.handleSiteRateLimitComment)}
851 <div className="form-group row">
853 className="col-12 col-form-label"
854 htmlFor="create-site-rate-limit-comment-per-second"
856 {i18n.t("per_second")}
858 <div className="col-12">
861 id="create-site-rate-limit-comment-per-second"
862 className="form-control"
864 value={this.state.siteForm.rate_limit_comment_per_second}
867 this.handleSiteRateLimitCommentPerSecond
872 <div className="form-group row">
874 className="col-12 col-form-label"
875 htmlFor="create-site-rate-limit-search"
877 {i18n.t("rate_limit_search")}
879 <div className="col-12">
882 id="create-site-rate-limit-search"
883 className="form-control"
885 value={this.state.siteForm.rate_limit_search}
886 onInput={linkEvent(this, this.handleSiteRateLimitSearch)}
890 <div className="form-group row">
892 className="col-12 col-form-label"
893 htmlFor="create-site-rate-limit-search-per-second"
895 {i18n.t("per_second")}
897 <div className="col-12">
900 id="create-site-rate-limit-search-per-second"
901 className="form-control"
903 value={this.state.siteForm.rate_limit_search_per_second}
906 this.handleSiteRateLimitSearchPerSecond
911 <div className="form-group row">
912 <h5 className="col-12">{i18n.t("taglines")}</h5>
913 <div className="table-responsive col-12">
914 <table id="taglines_table" className="table table-sm table-hover">
915 <thead className="pointer"></thead>
917 {this.state.siteForm.taglines?.map((cv, index) => (
922 onContentChange={s =>
923 this.handleTaglineChange(this, index, s)
925 hideNavigationWarnings
926 allLanguages={this.props.siteRes.all_languages}
928 this.props.siteRes.discussion_languages
932 <td className="text-right">
934 className="btn btn-link btn-animate text-muted"
936 this.handleDeleteTaglineClick(this, index, e)
938 data-tippy-content={i18n.t("delete")}
939 aria-label={i18n.t("delete")}
943 classes={`icon-inline text-danger`}
952 className="btn btn-sm btn-secondary mr-2"
953 onClick={e => this.handleAddTaglineClick(this, e)}
955 {i18n.t("add_tagline")}
959 <div className="form-group row">
960 <div className="col-12">
963 className="btn btn-secondary mr-2"
964 disabled={this.state.loading}
966 {this.state.loading ? (
969 capitalizeFirstLetter(i18n.t("save"))
971 capitalizeFirstLetter(i18n.t("create"))
981 handleCreateSiteSubmit(i: SiteForm, event: any) {
982 event.preventDefault();
983 i.setState({ loading: true });
984 let auth = myAuth() ?? "TODO";
985 i.setState(s => ((s.siteForm.auth = auth), s));
986 if (i.props.siteRes.site_view.local_site.site_setup) {
987 WebSocketService.Instance.send(wsClient.editSite(i.state.siteForm));
989 let sForm = i.state.siteForm;
990 let form: CreateSite = {
991 name: sForm.name ?? "My site",
992 sidebar: sForm.sidebar,
993 description: sForm.description,
995 banner: sForm.banner,
996 community_creation_admin_only: sForm.community_creation_admin_only,
997 enable_nsfw: sForm.enable_nsfw,
998 enable_downvotes: sForm.enable_downvotes,
999 application_question: sForm.application_question,
1000 registration_mode: sForm.registration_mode,
1001 require_email_verification: sForm.require_email_verification,
1002 private_instance: sForm.private_instance,
1003 default_theme: sForm.default_theme,
1004 default_post_listing_type: sForm.default_post_listing_type,
1005 application_email_admins: sForm.application_email_admins,
1006 hide_modlog_mod_names: sForm.hide_modlog_mod_names,
1007 legal_information: sForm.legal_information,
1008 slur_filter_regex: sForm.slur_filter_regex,
1009 actor_name_max_length: sForm.actor_name_max_length,
1010 rate_limit_message: sForm.rate_limit_message,
1011 rate_limit_message_per_second: sForm.rate_limit_message_per_second,
1012 rate_limit_comment: sForm.rate_limit_comment,
1013 rate_limit_comment_per_second: sForm.rate_limit_comment_per_second,
1014 rate_limit_image: sForm.rate_limit_image,
1015 rate_limit_image_per_second: sForm.rate_limit_image_per_second,
1016 rate_limit_post: sForm.rate_limit_post,
1017 rate_limit_post_per_second: sForm.rate_limit_post_per_second,
1018 rate_limit_register: sForm.rate_limit_register,
1019 rate_limit_register_per_second: sForm.rate_limit_register_per_second,
1020 rate_limit_search: sForm.rate_limit_search,
1021 rate_limit_search_per_second: sForm.rate_limit_search_per_second,
1022 federation_enabled: sForm.federation_enabled,
1023 federation_debug: sForm.federation_debug,
1024 federation_worker_count: sForm.federation_worker_count,
1025 captcha_enabled: sForm.captcha_enabled,
1026 captcha_difficulty: sForm.captcha_difficulty,
1027 allowed_instances: sForm.allowed_instances,
1028 blocked_instances: sForm.blocked_instances,
1029 discussion_languages: sForm.discussion_languages,
1030 taglines: sForm.taglines,
1033 WebSocketService.Instance.send(wsClient.createSite(form));
1035 i.setState(i.state);
1038 instancesToString(opt?: string[]): string {
1039 return opt ? opt.join(",") : "";
1042 handleSiteAllowedInstances(i: SiteForm, event: any) {
1043 let list = splitToList(event.target.value);
1044 i.setState(s => ((s.siteForm.allowed_instances = list), s));
1047 handleSiteBlockedInstances(i: SiteForm, event: any) {
1048 let list = splitToList(event.target.value);
1049 i.setState(s => ((s.siteForm.blocked_instances = list), s));
1052 handleSiteNameChange(i: SiteForm, event: any) {
1053 i.state.siteForm.name = event.target.value;
1054 i.setState(i.state);
1057 handleSiteSidebarChange(val: string) {
1058 this.setState(s => ((s.siteForm.sidebar = val), s));
1061 handleSiteLegalInfoChange(val: string) {
1062 this.setState(s => ((s.siteForm.legal_information = val), s));
1065 handleTaglineChange(i: SiteForm, index: number, val: string) {
1066 let taglines = i.state.siteForm.taglines;
1068 taglines[index] = val;
1069 i.setState(i.state);
1073 handleDeleteTaglineClick(
1076 event: InfernoMouseEvent<HTMLButtonElement>
1078 event.preventDefault();
1079 let taglines = i.state.siteForm.taglines;
1081 taglines.splice(index, 1);
1082 i.state.siteForm.taglines = undefined;
1083 i.setState(i.state);
1084 i.state.siteForm.taglines = taglines;
1085 i.setState(i.state);
1089 handleAddTaglineClick(
1091 event: InfernoMouseEvent<HTMLButtonElement>
1093 event.preventDefault();
1094 if (!i.state.siteForm.taglines) {
1095 i.state.siteForm.taglines = [];
1097 i.state.siteForm.taglines.push("");
1098 i.setState(i.state);
1101 handleSiteApplicationQuestionChange(val: string) {
1102 this.setState(s => ((s.siteForm.application_question = val), s));
1105 handleSiteDescChange(i: SiteForm, event: any) {
1106 i.state.siteForm.description = event.target.value;
1107 i.setState(i.state);
1110 handleSiteEnableNsfwChange(i: SiteForm, event: any) {
1111 i.state.siteForm.enable_nsfw = event.target.checked;
1112 i.setState(i.state);
1115 handleSiteRegistrationModeChange(i: SiteForm, event: any) {
1116 i.state.siteForm.registration_mode = event.target.value;
1117 i.setState(i.state);
1120 handleSiteCommunityCreationAdminOnly(i: SiteForm, event: any) {
1121 i.state.siteForm.community_creation_admin_only = event.target.checked;
1122 i.setState(i.state);
1125 handleSiteEnableDownvotesChange(i: SiteForm, event: any) {
1126 i.state.siteForm.enable_downvotes = event.target.checked;
1127 i.setState(i.state);
1130 handleSiteRequireEmailVerification(i: SiteForm, event: any) {
1131 i.state.siteForm.require_email_verification = event.target.checked;
1132 i.setState(i.state);
1135 handleSiteApplicationEmailAdmins(i: SiteForm, event: any) {
1136 i.state.siteForm.application_email_admins = event.target.checked;
1137 i.setState(i.state);
1140 handleSiteReportsEmailAdmins(i: SiteForm, event: any) {
1141 i.state.siteForm.reports_email_admins = event.target.checked;
1142 i.setState(i.state);
1145 handleSitePrivateInstance(i: SiteForm, event: any) {
1146 i.state.siteForm.private_instance = event.target.checked;
1147 i.setState(i.state);
1150 handleSiteHideModlogModNames(i: SiteForm, event: any) {
1151 i.state.siteForm.hide_modlog_mod_names = event.target.checked;
1152 i.setState(i.state);
1155 handleSiteDefaultTheme(i: SiteForm, event: any) {
1156 i.state.siteForm.default_theme = event.target.value;
1157 i.setState(i.state);
1160 handleIconUpload(url: string) {
1161 this.setState(s => ((s.siteForm.icon = url), s));
1164 handleIconRemove() {
1165 this.setState(s => ((s.siteForm.icon = ""), s));
1168 handleBannerUpload(url: string) {
1169 this.setState(s => ((s.siteForm.banner = url), s));
1172 handleBannerRemove() {
1173 this.setState(s => ((s.siteForm.banner = ""), s));
1176 handleSiteSlurFilterRegex(i: SiteForm, event: any) {
1177 i.setState(s => ((s.siteForm.slur_filter_regex = event.target.value), s));
1180 handleSiteActorNameMaxLength(i: SiteForm, event: any) {
1182 s => ((s.siteForm.actor_name_max_length = Number(event.target.value)), s)
1186 handleSiteRateLimitMessage(i: SiteForm, event: any) {
1188 s => ((s.siteForm.rate_limit_message = Number(event.target.value)), s)
1192 handleSiteRateLimitMessagePerSecond(i: SiteForm, event: any) {
1195 (s.siteForm.rate_limit_message_per_second = Number(event.target.value)),
1201 handleSiteRateLimitPost(i: SiteForm, event: any) {
1203 s => ((s.siteForm.rate_limit_post = Number(event.target.value)), s)
1207 handleSiteRateLimitPostPerSecond(i: SiteForm, event: any) {
1210 (s.siteForm.rate_limit_post_per_second = Number(event.target.value)), s
1215 handleSiteRateLimitImage(i: SiteForm, event: any) {
1217 s => ((s.siteForm.rate_limit_image = Number(event.target.value)), s)
1221 handleSiteRateLimitImagePerSecond(i: SiteForm, event: any) {
1224 (s.siteForm.rate_limit_image_per_second = Number(event.target.value)), s
1229 handleSiteRateLimitComment(i: SiteForm, event: any) {
1231 s => ((s.siteForm.rate_limit_comment = Number(event.target.value)), s)
1235 handleSiteRateLimitCommentPerSecond(i: SiteForm, event: any) {
1238 (s.siteForm.rate_limit_comment_per_second = Number(event.target.value)),
1244 handleSiteRateLimitSearch(i: SiteForm, event: any) {
1246 s => ((s.siteForm.rate_limit_search = Number(event.target.value)), s)
1250 handleSiteRateLimitSearchPerSecond(i: SiteForm, event: any) {
1253 (s.siteForm.rate_limit_search_per_second = Number(event.target.value)),
1259 handleSiteRateLimitRegister(i: SiteForm, event: any) {
1261 s => ((s.siteForm.rate_limit_register = Number(event.target.value)), s)
1265 handleSiteRateLimitRegisterPerSecond(i: SiteForm, event: any) {
1268 (s.siteForm.rate_limit_register_per_second = Number(
1276 handleSiteFederationEnabled(i: SiteForm, event: any) {
1277 i.state.siteForm.federation_enabled = event.target.checked;
1278 i.setState(i.state);
1281 handleSiteFederationDebug(i: SiteForm, event: any) {
1282 i.state.siteForm.federation_debug = event.target.checked;
1283 i.setState(i.state);
1286 handleSiteFederationWorkerCount(i: SiteForm, event: any) {
1289 (s.siteForm.federation_worker_count = Number(event.target.value)), s
1294 handleSiteCaptchaEnabled(i: SiteForm, event: any) {
1295 i.state.siteForm.captcha_enabled = event.target.checked;
1296 i.setState(i.state);
1299 handleSiteCaptchaDifficulty(i: SiteForm, event: any) {
1300 i.setState(s => ((s.siteForm.captcha_difficulty = event.target.value), s));
1303 handleDiscussionLanguageChange(val: number[]) {
1304 this.setState(s => ((s.siteForm.discussion_languages = val), s));
1307 handleDefaultPostListingTypeChange(val: ListingType) {
1310 (s.siteForm.default_post_listing_type = ListingType[ListingType[val]]),
1317 function splitToList(commaList: string): string[] {
1318 if (commaList !== "") {
1319 let list = commaList.trim().split(",");