Put "Media Only" option in column settings instead of content area headline (#7801)
* Action/reducer for changing column settings takes a path and a value instead of a javascript object * Settings menu version and column headline version working simultaneously * remove column headline entirely * remove css for headlines that aren't possible now * Remove commented out code from unfruitful attempt at this feature * Give direct timeline its own column settings bc it doesn't have a media only option * Fix typo in public timeline code that was preventing per-column settings from working properly * Fix codeclimate issues * Missing semicolons * Use redux state to set onlyMedia, let that do the update instead of a callback. Consequently, unpinned setting works without history modification * Unused import
This commit is contained in:
@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||||
import SettingText from '../../../components/setting_text';
|
||||
import SettingToggle from '../../notifications/components/setting_toggle';
|
||||
|
||||
const messages = defineMessages({
|
||||
filter_regex: { id: 'home.column_settings.filter_regex', defaultMessage: 'Filter out by regular expressions' },
|
||||
@ -16,6 +17,7 @@ export default class ColumnSettings extends React.PureComponent {
|
||||
settings: ImmutablePropTypes.map.isRequired,
|
||||
onChange: PropTypes.func.isRequired,
|
||||
intl: PropTypes.object.isRequired,
|
||||
columnId: PropTypes.string,
|
||||
};
|
||||
|
||||
render () {
|
||||
@ -23,6 +25,10 @@ export default class ColumnSettings extends React.PureComponent {
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className='column-settings__row'>
|
||||
<SettingToggle settings={settings} settingPath={['other', 'onlyMedia']} onChange={onChange} label={<FormattedMessage id='community.column_settings.media_only' defaultMessage='Media Only' />} />
|
||||
</div>
|
||||
|
||||
<span className='column-settings__section'><FormattedMessage id='home.column_settings.advanced' defaultMessage='Advanced' /></span>
|
||||
|
||||
<div className='column-settings__row'>
|
||||
|
@ -1,59 +0,0 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import React, { Component, Fragment } from 'react';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import { NavLink } from 'react-router-dom';
|
||||
|
||||
export default class SectionHeadline extends Component {
|
||||
|
||||
static propTypes = {
|
||||
timelineId: PropTypes.string.isRequired,
|
||||
to: PropTypes.string.isRequired,
|
||||
pinned: PropTypes.bool.isRequired,
|
||||
onlyMedia: PropTypes.bool.isRequired,
|
||||
onClick: PropTypes.func,
|
||||
};
|
||||
|
||||
shouldComponentUpdate (nextProps) {
|
||||
return (
|
||||
this.props.onlyMedia !== nextProps.onlyMedia ||
|
||||
this.props.pinned !== nextProps.pinned ||
|
||||
this.props.to !== nextProps.to ||
|
||||
this.props.timelineId !== nextProps.timelineId
|
||||
);
|
||||
}
|
||||
|
||||
handleClick = e => {
|
||||
const { onClick } = this.props;
|
||||
|
||||
if (typeof onClick === 'function') {
|
||||
e.preventDefault();
|
||||
|
||||
onClick.call(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
render () {
|
||||
const { timelineId, to, pinned, onlyMedia } = this.props;
|
||||
|
||||
return (
|
||||
<div className={`${timelineId}-timeline__section-headline`}>
|
||||
{pinned ? (
|
||||
<Fragment>
|
||||
<a href={to} className={!onlyMedia ? 'active' : undefined} onClick={this.handleClick}>
|
||||
<FormattedMessage id='timeline.posts' defaultMessage='Toots' />
|
||||
</a>
|
||||
<a href={`${to}/media`} className={onlyMedia ? 'active' : undefined} onClick={this.handleClick}>
|
||||
<FormattedMessage id='timeline.media' defaultMessage='Media' />
|
||||
</a>
|
||||
</Fragment>
|
||||
) : (
|
||||
<Fragment>
|
||||
<NavLink exact to={to} replace><FormattedMessage id='timeline.posts' defaultMessage='Toots' /></NavLink>
|
||||
<NavLink exact to={`${to}/media`} replace><FormattedMessage id='timeline.media' defaultMessage='Media' /></NavLink>
|
||||
</Fragment>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user