|
| 1 | +import React, { PureComponent } from "react"; |
| 2 | +import PropTypes from "prop-types"; |
| 3 | +import { withTranslation } from "react-i18next"; |
| 4 | +import { connect } from "react-redux"; |
| 5 | +import Layout from "backend/components/layout"; |
| 6 | +import Form from "global/components/form"; |
| 7 | +import FormContainer from "global/containers/form"; |
| 8 | +import { settingsAPI, requests } from "api"; |
| 9 | +import { select } from "utils/entityUtils"; |
| 10 | +import PageHeader from "backend/components/layout/PageHeader"; |
| 11 | + |
| 12 | +export class SettingsContentContainer extends PureComponent { |
| 13 | + static mapStateToProps = state => { |
| 14 | + return { |
| 15 | + settings: select(requests.settings, state.entityStore) |
| 16 | + }; |
| 17 | + }; |
| 18 | + |
| 19 | + static displayName = "Settings.Content"; |
| 20 | + |
| 21 | + static propTypes = { |
| 22 | + settings: PropTypes.object |
| 23 | + }; |
| 24 | + |
| 25 | + render() { |
| 26 | + if (!this.props.settings) return null; |
| 27 | + const t = this.props.t; |
| 28 | + return ( |
| 29 | + <div> |
| 30 | + <PageHeader title={t("settings.content.header")} type="settings" /> |
| 31 | + <Layout.BackendPanel> |
| 32 | + <FormContainer.Form |
| 33 | + model={this.props.settings} |
| 34 | + name="backend-settings" |
| 35 | + update={settingsAPI.update} |
| 36 | + create={settingsAPI.update} |
| 37 | + className="form-secondary" |
| 38 | + > |
| 39 | + <Form.FieldGroup label={t("settings.content.top_bar_header")}> |
| 40 | + <Form.TextInput |
| 41 | + label={t("settings.content.text_label")} |
| 42 | + name="attributes[theme][topBarText]" |
| 43 | + placeholder={t("settings.content.text_placeholder")} |
| 44 | + /> |
| 45 | + <Form.TextInput |
| 46 | + label={t("settings.content.color_label")} |
| 47 | + name="attributes[theme][topBarColor]" |
| 48 | + placeholder={t("settings.content.color_placeholder")} |
| 49 | + instructions={t("settings.content.color_instructions")} |
| 50 | + /> |
| 51 | + <Form.TextInput |
| 52 | + label={t("settings.content.top_bar_url_label")} |
| 53 | + name="attributes[theme][topBarUrl]" |
| 54 | + placeholder={t("settings.content.top_bar_url_placeholder")} |
| 55 | + /> |
| 56 | + <Form.Select |
| 57 | + label={t("settings.content.mode_label")} |
| 58 | + name="attributes[theme][topBarMode]" |
| 59 | + options={[ |
| 60 | + { |
| 61 | + label: t("settings.content.mode_options.disabled"), |
| 62 | + value: "disabled" |
| 63 | + }, |
| 64 | + { |
| 65 | + label: t("settings.content.mode_options.always"), |
| 66 | + value: "enforced" |
| 67 | + }, |
| 68 | + { |
| 69 | + label: t("settings.content.mode_options.standalone"), |
| 70 | + value: "enabled" |
| 71 | + } |
| 72 | + ]} |
| 73 | + /> |
| 74 | + </Form.FieldGroup> |
| 75 | + <Form.FieldGroup |
| 76 | + label={t("settings.content.content_signup_header")} |
| 77 | + > |
| 78 | + <Form.TextInput |
| 79 | + wide |
| 80 | + label={t("settings.content.string_signup_terms_header")} |
| 81 | + name="attributes[theme][stringSignupTermsHeader]" |
| 82 | + /> |
| 83 | + <Form.TextArea |
| 84 | + wide |
| 85 | + label={t("settings.content.string_signup_terms_one")} |
| 86 | + name="attributes[theme][stringSignupTermsOne]" |
| 87 | + /> |
| 88 | + <Form.TextArea |
| 89 | + wide |
| 90 | + label={t("settings.content.string_signup_terms_two")} |
| 91 | + name="attributes[theme][stringSignupTermsTwo]" |
| 92 | + /> |
| 93 | + </Form.FieldGroup> |
| 94 | + <Form.FieldGroup |
| 95 | + label={t("settings.content.content_data_use_header")} |
| 96 | + > |
| 97 | + <Form.TextInput |
| 98 | + wide |
| 99 | + label={t("settings.content.string_data_use_header")} |
| 100 | + name="attributes[theme][stringDataUseHeader]" |
| 101 | + /> |
| 102 | + <Form.TextArea |
| 103 | + wide |
| 104 | + label={t("settings.content.string_data_use_copy")} |
| 105 | + name="attributes[theme][stringDataUseCopy]" |
| 106 | + instructions={t("settings.content.data_use_copy_instructions")} |
| 107 | + /> |
| 108 | + <Form.TextInput |
| 109 | + wide |
| 110 | + label={t("settings.content.string_cookies_banner_header")} |
| 111 | + name="attributes[theme][stringCookiesBannerHeader]" |
| 112 | + /> |
| 113 | + <Form.TextArea |
| 114 | + wide |
| 115 | + label={t("settings.content.string_cookies_banner_copy")} |
| 116 | + name="attributes[theme][stringCookiesBannerCopy]" |
| 117 | + instructions={t( |
| 118 | + "settings.content.cookies_banner_copy_instructions" |
| 119 | + )} |
| 120 | + /> |
| 121 | + </Form.FieldGroup> |
| 122 | + <Form.Save text={t("settings.save")} /> |
| 123 | + </FormContainer.Form> |
| 124 | + </Layout.BackendPanel> |
| 125 | + </div> |
| 126 | + ); |
| 127 | + } |
| 128 | +} |
| 129 | + |
| 130 | +export default withTranslation()( |
| 131 | + connect(SettingsContentContainer.mapStateToProps)(SettingsContentContainer) |
| 132 | +); |
0 commit comments