CommunityView,
CreateCommunity,
EditCommunity,
+ Language,
toUndefined,
UserOperation,
wsJsonToRes,
} from "../../utils";
import { Icon, Spinner } from "../common/icon";
import { ImageUploadForm } from "../common/image-upload-form";
+import { LanguageSelect } from "../common/language-select";
import { MarkdownTextArea } from "../common/markdown-textarea";
interface CommunityFormProps {
community_view: Option<CommunityView>; // If a community is given, that means this is an edit
+ allLanguages: Language[];
+ siteLanguages: number[];
+ communityLanguages: Option<number[]>;
onCancel?(): any;
onCreate?(community: CommunityView): any;
onEdit?(community: CommunityView): any;
name: undefined,
title: undefined,
description: None,
+ discussion_languages: this.props.communityLanguages,
nsfw: None,
icon: None,
banner: None,
this.handleBannerUpload = this.handleBannerUpload.bind(this);
this.handleBannerRemove = this.handleBannerRemove.bind(this);
+ this.handleDiscussionLanguageChange =
+ this.handleDiscussionLanguageChange.bind(this);
+
this.parseMessage = this.parseMessage.bind(this);
this.subscription = wsSubscribe(this.parseMessage);
posting_restricted_to_mods: Some(
cv.community.posting_restricted_to_mods
),
+ discussion_languages: this.props.communityLanguages,
auth: undefined,
}),
};
maxLength={None}
onContentChange={this.handleCommunityDescriptionChange}
allLanguages={[]}
+ siteLanguages={[]}
/>
</div>
</div>
</div>
</div>
</div>
+ <LanguageSelect
+ allLanguages={this.props.allLanguages}
+ siteLanguages={this.props.siteLanguages}
+ showSite
+ selectedLanguageIds={this.state.communityForm.discussion_languages}
+ multiple={true}
+ onChange={this.handleDiscussionLanguageChange}
+ />
<div className="form-group row">
<div className="col-12">
<button
banner: cForm.banner,
nsfw: cForm.nsfw,
posting_restricted_to_mods: cForm.posting_restricted_to_mods,
+ discussion_languages: cForm.discussion_languages,
auth: cForm.auth,
});
this.setState(s => ((s.communityForm.banner = Some("")), s));
}
+ handleDiscussionLanguageChange(val: number[]) {
+ this.setState(s => ((s.communityForm.discussion_languages = Some(val)), s));
+ }
+
parseMessage(msg: any) {
let op = wsUserOp(msg);
console.log(msg);