modified to process customCss soapbox.json list element per Neenster format

This commit is contained in:
crockwave 2020-07-27 19:16:02 -05:00
parent abe8b28b69
commit a0befffab0

View file

@ -35,7 +35,7 @@ const mapStateToProps = state => {
return { return {
// themeCss: generateThemeCss(soapbox.get('brandColor')), // themeCss: generateThemeCss(soapbox.get('brandColor')),
brandColor: soapbox.get('brandColor'), brandColor: soapbox.get('brandColor'),
customCssItems: soapbox.getIn(['customCSS', 'items']), customCssItems: soapbox.get('customCss'),
logo: soapbox.get('logo'), logo: soapbox.get('logo'),
banner: soapbox.get('banner'), banner: soapbox.get('banner'),
promoItems: soapbox.getIn(['promoPanel', 'items']), promoItems: soapbox.getIn(['promoPanel', 'items']),
@ -54,7 +54,6 @@ class ConfigSoapbox extends ImmutablePureComponent {
static propTypes = { static propTypes = {
dispatch: PropTypes.func.isRequired, dispatch: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired, intl: PropTypes.object.isRequired,
// themeCss: PropTypes.string,
brandColor: PropTypes.string, brandColor: PropTypes.string,
customCssItems: ImmutablePropTypes.list, customCssItems: ImmutablePropTypes.list,
logo: PropTypes.string, logo: PropTypes.string,
@ -103,16 +102,12 @@ class ConfigSoapbox extends ImmutablePureComponent {
]); ]);
}; };
if (!this.state.customCssItems) { if (!this.state.customCssItems) {
this.state.customCssItems = ImmutableList([ this.state.customCssItems = ImmutableList([]);
ImmutableMap({
url: '',
}),
]);
}; };
this.handlecustomCSSChange = this.handleCustomCSSChange.bind(this); this.handlecustomCSSChange = this.handleCustomCSSChange.bind(this);
// this.handleAddPromoPanelItem = this.handleAddPromoPanelItem.bind(this); // this.handleAddPromoPanelItem = this.handleAddPromoPanelItem.bind(this);
// this.handleAddHomeFooterItem = this.handleAddHomeFooterItem.bind(this); this.handleAddHomeFooterItem = this.handleAddHomeFooterItem.bind(this);
// this.handleAddCSSItem = this.handleAddCSSItem.bind(this); this.handleAddCSSItem = this.handleAddCSSItem.bind(this);
} }
getPromoItemsParams = () => { getPromoItemsParams = () => {
@ -140,7 +135,7 @@ class ConfigSoapbox extends ImmutablePureComponent {
let params = ImmutableMap(); let params = ImmutableMap();
this.state.customCssItems.forEach((f, i) => this.state.customCssItems.forEach((f, i) =>
params = params params = params
.set(`custom_css_attributes[${i}][url]`, f.get('url')) .set(`custom_css_attributes[${i}][url]`, f)
); );
return params; return params;
} }
@ -148,7 +143,6 @@ class ConfigSoapbox extends ImmutablePureComponent {
getParams = () => { getParams = () => {
const { state } = this; const { state } = this;
return Object.assign({ return Object.assign({
// themeCss: state.themeCss,
brandColor: state.brandColor, brandColor: state.brandColor,
logoFile: state.logoFile, logoFile: state.logoFile,
patronEnabled: state.patronEnabled, patronEnabled: state.patronEnabled,
@ -209,10 +203,10 @@ class ConfigSoapbox extends ImmutablePureComponent {
}; };
} }
handleCustomCSSChange = (i, key) => { handleCustomCSSChange = i => {
return (e) => { return (e) => {
this.setState({ this.setState({
customCssItems: this.state.customCssItems.setIn([i, key], e.target.value), customCssItems: this.state.customCssItems.setIn([i], e.target.value),
}); });
}; };
} }
@ -253,11 +247,7 @@ class ConfigSoapbox extends ImmutablePureComponent {
handleAddCSSItem = () => { handleAddCSSItem = () => {
this.setState({ this.setState({
customCssItems: this.state.customCssItems.concat([ customCssItems: this.state.customCssItems.concat(['']),
ImmutableMap({
url: '',
}),
]),
}); });
} }
@ -400,8 +390,8 @@ class ConfigSoapbox extends ImmutablePureComponent {
<TextInput <TextInput
label={intl.formatMessage(messages.customCssLabel)} label={intl.formatMessage(messages.customCssLabel)}
placeholder={intl.formatMessage(messages.customCssLabel)} placeholder={intl.formatMessage(messages.customCssLabel)}
value={field.get('url')} value={field}
onChange={this.handlecustomCSSChange(i, 'url')} onChange={this.handlecustomCSSChange(i)}
/> />
</div> </div>
)) ))