Merge branch 'develop' into 'develop'

Make promo panel/footer items localizable

See merge request soapbox-pub/soapbox-fe!545
datepicker-css
Alex Gleason 2021-06-25 20:12:58 +00:00
commit 59e47d6e6e
2 zmienionych plików z 13 dodań i 4 usunięć

Wyświetl plik

@ -5,6 +5,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { Link } from 'react-router-dom';
import { List as ImmutableList } from 'immutable';
import { getSettings } from 'soapbox/actions/settings';
import { getSoapboxConfig } from 'soapbox/actions/soapbox';
const mapStateToProps = (state, props) => {
@ -13,6 +14,7 @@ const mapStateToProps = (state, props) => {
return {
copyright: soapboxConfig.get('copyright'),
navlinks: soapboxConfig.getIn(['navlinks', 'homeFooter'], ImmutableList()),
locale: getSettings(state).get('locale'),
};
};
@ -21,11 +23,12 @@ class Footer extends ImmutablePureComponent {
static propTypes = {
copyright: PropTypes.string,
locale: PropTypes.string,
navlinks: ImmutablePropTypes.list,
}
render() {
const { copyright, navlinks } = this.props;
const { copyright, locale, navlinks } = this.props;
return (
<div className='footer'>
@ -36,7 +39,9 @@ class Footer extends ImmutablePureComponent {
<ul>
{navlinks.map((link, i) => (
<li key={i}>
<Link to={link.get('url')}>{link.get('title')}</Link>
<Link to={link.get('url')}>
{link.getIn(['titleLocales', locale]) || link.get('title')}
</Link>
</li>
))}
</ul>

Wyświetl plik

@ -1,22 +1,26 @@
import React from 'react';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import Icon from 'soapbox/components/icon';
import { connect } from 'react-redux';
import { getSettings } from 'soapbox/actions/settings';
import { getSoapboxConfig } from 'soapbox/actions/soapbox';
const mapStateToProps = state => ({
promoItems: getSoapboxConfig(state).getIn(['promoPanel', 'items']),
locale: getSettings(state).get('locale'),
});
export default @connect(mapStateToProps)
class PromoPanel extends React.PureComponent {
static propTypes = {
locale: PropTypes.string,
promoItems: ImmutablePropTypes.list,
}
render() {
const { promoItems } = this.props;
const { locale, promoItems } = this.props;
if (!promoItems) return null;
return (
@ -25,7 +29,7 @@ class PromoPanel extends React.PureComponent {
{promoItems.map((item, i) =>
(<a className='promo-panel-item' href={item.get('url')} target='_blank' key={i}>
<Icon id={item.get('icon')} className='promo-panel-item__icon' fixedWidth />
{item.get('text')}
{item.getIn(['textLocales', locale]) || item.get('text')}
</a>),
)}
</div>