getDataTypeFromProps,
getListingTypeFromProps,
getPageFromProps,
+ getRandomFromList,
getSortTypeFromProps,
isBrowser,
isPostBlocked,
+ mdToHtml,
notifyPost,
nsfwCheck,
postToCommentSortType,
showSidebarMobile: boolean;
subscribedCollapsed: boolean;
loading: boolean;
+ tagline: Option<string>;
}
interface HomeProps {
dataType: getDataTypeFromProps(this.props),
sort: getSortTypeFromProps(this.props),
page: getPageFromProps(this.props),
+ tagline: None
};
constructor(props: any, context: any) {
wsClient.communityJoin({ community_id: 0 })
);
}
+ const taglines = this.state.siteRes.taglines;
this.state = {
...this.state,
trendingCommunities: trendingRes.communities,
loading: false,
+ tagline: taglines.map(tls => getRandomFromList(tls).content)
};
} else {
this.fetchTrendingCommunities();
{this.state.siteRes.site_view.local_site.site_setup && (
<div className="row">
<main role="main" className="col-12 col-md-8">
+ {this.state.tagline.match({
+ some: tagline => <div id="tagline" dangerouslySetInnerHTML={mdToHtml(tagline)}></div>,
+ none: <></>,
+ })}
<div className="d-block d-md-none">{this.mobileView()}</div>
{this.posts()}
</main>
import { None, Option, Some } from "@sniptt/monads";
-import { Component, linkEvent } from "inferno";
+import { Component, InfernoMouseEvent, linkEvent } from "inferno";
import { Prompt } from "inferno-router";
import {
CreateSite,
fetchThemeList,
wsClient,
} from "../../utils";
-import { Spinner } from "../common/icon";
+import { Icon, Spinner } from "../common/icon";
import { ImageUploadForm } from "../common/image-upload-form";
import { LanguageSelect } from "../common/language-select";
import { ListingTypeSelect } from "../common/listing-type-select";
captcha_difficulty: None,
allowed_instances: None,
blocked_instances: None,
+ taglines: None,
auth: undefined,
}),
loading: false,
blocked_instances: this.props.siteRes.federated_instances.andThen(
f => f.blocked
),
+ taglines: this.props.siteRes.taglines.map(x => x.map(y => y.content)),
auth: undefined,
}),
};
/>
</div>
</div>
+ {siteSetup && <div className="form-group row">
+ <h5 className="col-12">{i18n.t("taglines")}</h5>
+ <div className="table-responsive col-12">
+ <table id="taglines_table" className="table table-sm table-hover">
+ <thead className="pointer"></thead>
+ <tbody>
+ {this.state.siteForm.taglines
+ .unwrapOr([])
+ .map((cv, index) => (
+ <tr key={index}>
+ <td>
+ <MarkdownTextArea
+ initialContent={Some(cv)}
+ initialLanguageId={None}
+ placeholder={None}
+ buttonTitle={None}
+ maxLength={None}
+ onContentChange={s =>
+ this.handleTaglineChange(this, index, s)
+ }
+ hideNavigationWarnings
+ allLanguages={this.props.siteRes.all_languages}
+ />
+ </td>
+ <td className="text-right">
+ <button
+ className="btn btn-link btn-animate text-muted"
+ onClick={e =>
+ this.handleDeleteTaglineClick(this, index, e)
+ }
+ data-tippy-content={i18n.t("delete")}
+ aria-label={i18n.t("delete")}
+ >
+ <Icon
+ icon="trash"
+ classes={`icon-inline text-danger`}
+ />
+ </button>
+ </td>
+ </tr>
+ ))}
+ </tbody>
+ </table>
+ <button
+ className="btn btn-sm btn-secondary mr-2"
+ onClick={e => this.handleAddTaglineClick(this, e)}
+ >
+ {i18n.t("add_tagline")}
+ </button>
+ </div>
+ </div>}
<div className="form-group row">
<div className="col-12">
<button
event.preventDefault();
i.setState({ loading: true });
i.setState(s => ((s.siteForm.auth = auth().unwrap()), s));
-
if (i.props.siteRes.site_view.local_site.site_setup) {
WebSocketService.Instance.send(wsClient.editSite(i.state.siteForm));
} else {
this.setState(s => ((s.siteForm.legal_information = Some(val)), s));
}
+ handleTaglineChange(i: SiteForm, index: number, val: string) {
+ i.state.siteForm.taglines.match({
+ some: tls => { tls[index] = val; },
+ none: void 0
+ });
+ i.setState(i.state);
+ }
+
+ handleDeleteTaglineClick(
+ i: SiteForm,
+ index: number,
+ event: InfernoMouseEvent<HTMLButtonElement>
+ ) {
+ event.preventDefault();
+ if (i.state.siteForm.taglines.isSome()){
+ let taglines = i.state.siteForm.taglines.unwrap();
+ taglines.splice(index, 1);
+ i.state.siteForm.taglines = None; // force rerender of table rows
+ i.setState(i.state);
+ i.state.siteForm.taglines = Some(taglines);
+ i.setState(i.state);
+ }
+ }
+
+ handleAddTaglineClick(
+ i: SiteForm,
+ event: InfernoMouseEvent<HTMLButtonElement>
+ ) {
+ event.preventDefault();
+ if (i.state.siteForm.taglines.isNone()){
+ i.state.siteForm.taglines = Some([]);
+ }
+ i.state.siteForm.taglines.unwrap().push("");
+ i.setState(i.state);
+ }
+
handleSiteApplicationQuestionChange(val: string) {
this.setState(s => ((s.siteForm.application_question = Some(val)), s));
}