diff --git a/src/shared/components/home/admin-settings.tsx b/src/shared/components/home/admin-settings.tsx index 5b16d2ec..6d2707e5 100644 --- a/src/shared/components/home/admin-settings.tsx +++ b/src/shared/components/home/admin-settings.tsx @@ -30,6 +30,7 @@ import { Spinner } from "../common/icon"; import { PersonListing } from "../person/person-listing"; import { EmojiForm } from "./emojis-form"; import { SiteForm } from "./site-form"; +import { TaglineForm } from "./tagline-form"; interface AdminSettingsState { siteRes: GetSiteResponse; @@ -134,6 +135,19 @@ export class AdminSettings extends Component { {i18n.t("site")} +
  • + +
  • - - +
    +
    +
    + +
    +
    + +
    +
    + + + ); + } + + handleTaglineChange(i: TaglineForm, index: number, val: string) { + let taglines = i.state.siteForm.taglines; + if (taglines) { + taglines[index] = val; + i.setState(i.state); + } + } + + handleDeleteTaglineClick( + props: { form: TaglineForm; index: number }, + event: any + ) { + event.preventDefault(); + let taglines = props.form.state.siteForm.taglines; + if (taglines) { + taglines.splice(props.index, 1); + props.form.state.siteForm.taglines = undefined; + props.form.setState(props.form.state); + props.form.state.siteForm.taglines = taglines; + props.form.setState({ ...props.form.state, editingRow: undefined }); + } + } + + handleEditTaglineClick( + props: { form: TaglineForm; index: number }, + event: any + ) { + event.preventDefault(); + if (this.state.editingRow == props.index) { + props.form.setState({ editingRow: undefined }); + } else { + props.form.setState({ editingRow: props.index }); + } + } + + handleSaveClick(i: TaglineForm) { + i.setState({ loading: true }); + let auth = myAuth() ?? "TODO"; + i.setState(s => ((s.siteForm.auth = auth), s)); + WebSocketService.Instance.send(wsClient.editSite(i.state.siteForm)); + i.setState({ ...i.state, editingRow: undefined }); + } + + handleAddTaglineClick( + i: TaglineForm, + event: InfernoMouseEvent + ) { + event.preventDefault(); + if (!i.state.siteForm.taglines) { + i.state.siteForm.taglines = []; + } + i.state.siteForm.taglines.push(""); + i.setState({ + ...i.state, + editingRow: i.state.siteForm.taglines.length - 1, + }); + } +}