|
|
@ -2,14 +2,16 @@ |
|
|
|
import React from 'react'; |
|
|
|
import React from 'react'; |
|
|
|
import PropTypes from 'prop-types'; |
|
|
|
import PropTypes from 'prop-types'; |
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes'; |
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes'; |
|
|
|
import { injectIntl, defineMessages, FormattedMessage } from 'react-intl'; |
|
|
|
import { defineMessages, FormattedMessage, injectIntl } from 'react-intl'; |
|
|
|
|
|
|
|
|
|
|
|
// Our imports
|
|
|
|
// Our imports
|
|
|
|
import SettingsItem from './item'; |
|
|
|
import LocalSettingsPageItem from './item'; |
|
|
|
|
|
|
|
|
|
|
|
// Stylesheet imports
|
|
|
|
// Stylesheet imports
|
|
|
|
import './style'; |
|
|
|
import './style'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
|
|
|
|
|
|
|
|
|
|
const messages = defineMessages({ |
|
|
|
const messages = defineMessages({ |
|
|
|
layout_auto: { id: 'layout.auto', defaultMessage: 'Auto' }, |
|
|
|
layout_auto: { id: 'layout.auto', defaultMessage: 'Auto' }, |
|
|
|
layout_desktop: { id: 'layout.desktop', defaultMessage: 'Desktop' }, |
|
|
|
layout_desktop: { id: 'layout.desktop', defaultMessage: 'Desktop' }, |
|
|
@ -17,27 +19,21 @@ const messages = defineMessages({ |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
@injectIntl |
|
|
|
@injectIntl |
|
|
|
export default class Settings extends React.PureComponent { |
|
|
|
export default class LocalSettingsPage extends React.PureComponent { |
|
|
|
|
|
|
|
|
|
|
|
static propTypes = { |
|
|
|
static propTypes = { |
|
|
|
settings: ImmutablePropTypes.map.isRequired, |
|
|
|
index : PropTypes.number, |
|
|
|
toggleSetting: PropTypes.func.isRequired, |
|
|
|
intl : PropTypes.object.isRequired, |
|
|
|
changeSetting: PropTypes.func.isRequired, |
|
|
|
onChange : PropTypes.func.isRequired, |
|
|
|
onClose: PropTypes.func.isRequired, |
|
|
|
settings : ImmutablePropTypes.map.isRequired, |
|
|
|
intl: PropTypes.object.isRequired, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
state = { |
|
|
|
|
|
|
|
currentIndex: 0, |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
General = () => { |
|
|
|
pages = [ |
|
|
|
const { intl } = this.props; |
|
|
|
({ intl, onChange, settings }) => ( |
|
|
|
return ( |
|
|
|
<div className='glitch local-settings__page general'> |
|
|
|
<div> |
|
|
|
|
|
|
|
<h1><FormattedMessage id='settings.general' defaultMessage='General' /></h1> |
|
|
|
<h1><FormattedMessage id='settings.general' defaultMessage='General' /></h1> |
|
|
|
<SettingsItem |
|
|
|
<LocalSettingsPageItem |
|
|
|
settings={this.props.settings} |
|
|
|
settings={settings} |
|
|
|
item={['layout']} |
|
|
|
item={['layout']} |
|
|
|
id='mastodon-settings--layout' |
|
|
|
id='mastodon-settings--layout' |
|
|
|
options={[ |
|
|
|
options={[ |
|
|
@ -45,180 +41,135 @@ export default class Settings extends React.PureComponent { |
|
|
|
{ value: 'multiple', message: intl.formatMessage(messages.layout_desktop) }, |
|
|
|
{ value: 'multiple', message: intl.formatMessage(messages.layout_desktop) }, |
|
|
|
{ value: 'single', message: intl.formatMessage(messages.layout_mobile) }, |
|
|
|
{ value: 'single', message: intl.formatMessage(messages.layout_mobile) }, |
|
|
|
]} |
|
|
|
]} |
|
|
|
onChange={this.props.changeSetting} |
|
|
|
onChange={onChange} |
|
|
|
> |
|
|
|
> |
|
|
|
<FormattedMessage id='settings.layout' defaultMessage='Layout:' /> |
|
|
|
<FormattedMessage id='settings.layout' defaultMessage='Layout:' /> |
|
|
|
</SettingsItem> |
|
|
|
</LocalSettingsPageItem> |
|
|
|
|
|
|
|
<LocalSettingsPageItem |
|
|
|
<SettingsItem |
|
|
|
settings={settings} |
|
|
|
settings={this.props.settings} |
|
|
|
|
|
|
|
item={['stretch']} |
|
|
|
item={['stretch']} |
|
|
|
id='mastodon-settings--stretch' |
|
|
|
id='mastodon-settings--stretch' |
|
|
|
onChange={this.props.toggleSetting} |
|
|
|
onChange={onChange} |
|
|
|
> |
|
|
|
> |
|
|
|
<FormattedMessage id='settings.wide_view' defaultMessage='Wide view (Desktop mode only)' /> |
|
|
|
<FormattedMessage id='settings.wide_view' defaultMessage='Wide view (Desktop mode only)' /> |
|
|
|
</SettingsItem> |
|
|
|
</LocalSettingsPageItem> |
|
|
|
|
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
); |
|
|
|
), |
|
|
|
} |
|
|
|
({ onChange, settings }) => ( |
|
|
|
|
|
|
|
<div className='glitch local-settings__page collapsed'> |
|
|
|
CollapsedStatuses = () => { |
|
|
|
|
|
|
|
return ( |
|
|
|
|
|
|
|
<div> |
|
|
|
|
|
|
|
<h1><FormattedMessage id='settings.collapsed_statuses' defaultMessage='Collapsed toots' /></h1> |
|
|
|
<h1><FormattedMessage id='settings.collapsed_statuses' defaultMessage='Collapsed toots' /></h1> |
|
|
|
<SettingsItem |
|
|
|
<LocalSettingsPageItem |
|
|
|
settings={this.props.settings} |
|
|
|
settings={settings} |
|
|
|
item={['collapsed', 'enabled']} |
|
|
|
item={['collapsed', 'enabled']} |
|
|
|
id='mastodon-settings--collapsed-enabled' |
|
|
|
id='mastodon-settings--collapsed-enabled' |
|
|
|
onChange={this.props.toggleSetting} |
|
|
|
onChange={onChange} |
|
|
|
> |
|
|
|
> |
|
|
|
<FormattedMessage id='settings.enable_collapsed' defaultMessage='Enable collapsed toots' /> |
|
|
|
<FormattedMessage id='settings.enable_collapsed' defaultMessage='Enable collapsed toots' /> |
|
|
|
</SettingsItem> |
|
|
|
</LocalSettingsPageItem> |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2><FormattedMessage id='settings.auto_collapse' defaultMessage='Automatic collapsing' /></h2> |
|
|
|
<h2><FormattedMessage id='settings.auto_collapse' defaultMessage='Automatic collapsing' /></h2> |
|
|
|
<SettingsItem |
|
|
|
<LocalSettingsPageItem |
|
|
|
settings={this.props.settings} |
|
|
|
settings={settings} |
|
|
|
item={['collapsed', 'auto', 'all']} |
|
|
|
item={['collapsed', 'auto', 'all']} |
|
|
|
id='mastodon-settings--collapsed-auto-all' |
|
|
|
id='mastodon-settings--collapsed-auto-all' |
|
|
|
onChange={this.props.toggleSetting} |
|
|
|
onChange={onChange} |
|
|
|
dependsOn={[['collapsed', 'enabled']]} |
|
|
|
dependsOn={[['collapsed', 'enabled']]} |
|
|
|
> |
|
|
|
> |
|
|
|
<FormattedMessage id='settings.auto_collapse_all' defaultMessage='Everything' /> |
|
|
|
<FormattedMessage id='settings.auto_collapse_all' defaultMessage='Everything' /> |
|
|
|
</SettingsItem> |
|
|
|
</LocalSettingsPageItem> |
|
|
|
<SettingsItem |
|
|
|
<LocalSettingsPageItem |
|
|
|
settings={this.props.settings} |
|
|
|
settings={settings} |
|
|
|
item={['collapsed', 'auto', 'notifications']} |
|
|
|
item={['collapsed', 'auto', 'notifications']} |
|
|
|
id='mastodon-settings--collapsed-auto-notifications' |
|
|
|
id='mastodon-settings--collapsed-auto-notifications' |
|
|
|
onChange={this.props.toggleSetting} |
|
|
|
onChange={onChange} |
|
|
|
dependsOn={[['collapsed', 'enabled']]} |
|
|
|
dependsOn={[['collapsed', 'enabled']]} |
|
|
|
dependsOnNot={[['collapsed', 'auto', 'all']]} |
|
|
|
dependsOnNot={[['collapsed', 'auto', 'all']]} |
|
|
|
> |
|
|
|
> |
|
|
|
<FormattedMessage id='settings.auto_collapse_notifications' defaultMessage='Notifications' /> |
|
|
|
<FormattedMessage id='settings.auto_collapse_notifications' defaultMessage='Notifications' /> |
|
|
|
</SettingsItem> |
|
|
|
</LocalSettingsPageItem> |
|
|
|
<SettingsItem |
|
|
|
<LocalSettingsPageItem |
|
|
|
settings={this.props.settings} |
|
|
|
settings={settings} |
|
|
|
item={['collapsed', 'auto', 'lengthy']} |
|
|
|
item={['collapsed', 'auto', 'lengthy']} |
|
|
|
id='mastodon-settings--collapsed-auto-lengthy' |
|
|
|
id='mastodon-settings--collapsed-auto-lengthy' |
|
|
|
onChange={this.props.toggleSetting} |
|
|
|
onChange={onChange} |
|
|
|
dependsOn={[['collapsed', 'enabled']]} |
|
|
|
dependsOn={[['collapsed', 'enabled']]} |
|
|
|
dependsOnNot={[['collapsed', 'auto', 'all']]} |
|
|
|
dependsOnNot={[['collapsed', 'auto', 'all']]} |
|
|
|
> |
|
|
|
> |
|
|
|
<FormattedMessage id='settings.auto_collapse_lengthy' defaultMessage='Lengthy toots' /> |
|
|
|
<FormattedMessage id='settings.auto_collapse_lengthy' defaultMessage='Lengthy toots' /> |
|
|
|
</SettingsItem> |
|
|
|
</LocalSettingsPageItem> |
|
|
|
<SettingsItem |
|
|
|
<LocalSettingsPageItem |
|
|
|
settings={this.props.settings} |
|
|
|
settings={settings} |
|
|
|
item={['collapsed', 'auto', 'replies']} |
|
|
|
item={['collapsed', 'auto', 'replies']} |
|
|
|
id='mastodon-settings--collapsed-auto-replies' |
|
|
|
id='mastodon-settings--collapsed-auto-replies' |
|
|
|
onChange={this.props.toggleSetting} |
|
|
|
onChange={onChange} |
|
|
|
dependsOn={[['collapsed', 'enabled']]} |
|
|
|
dependsOn={[['collapsed', 'enabled']]} |
|
|
|
dependsOnNot={[['collapsed', 'auto', 'all']]} |
|
|
|
dependsOnNot={[['collapsed', 'auto', 'all']]} |
|
|
|
> |
|
|
|
> |
|
|
|
<FormattedMessage id='settings.auto_collapse_replies' defaultMessage='Replies' /> |
|
|
|
<FormattedMessage id='settings.auto_collapse_replies' defaultMessage='Replies' /> |
|
|
|
</SettingsItem> |
|
|
|
</LocalSettingsPageItem> |
|
|
|
<SettingsItem |
|
|
|
<LocalSettingsPageItem |
|
|
|
settings={this.props.settings} |
|
|
|
settings={settings} |
|
|
|
item={['collapsed', 'auto', 'media']} |
|
|
|
item={['collapsed', 'auto', 'media']} |
|
|
|
id='mastodon-settings--collapsed-auto-media' |
|
|
|
id='mastodon-settings--collapsed-auto-media' |
|
|
|
onChange={this.props.toggleSetting} |
|
|
|
onChange={onChange} |
|
|
|
dependsOn={[['collapsed', 'enabled']]} |
|
|
|
dependsOn={[['collapsed', 'enabled']]} |
|
|
|
dependsOnNot={[['collapsed', 'auto', 'all']]} |
|
|
|
dependsOnNot={[['collapsed', 'auto', 'all']]} |
|
|
|
> |
|
|
|
> |
|
|
|
<FormattedMessage id='settings.auto_collapse_media' defaultMessage='Toots with media' /> |
|
|
|
<FormattedMessage id='settings.auto_collapse_media' defaultMessage='Toots with media' /> |
|
|
|
</SettingsItem> |
|
|
|
</LocalSettingsPageItem> |
|
|
|
</section> |
|
|
|
</section> |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2><FormattedMessage id='settings.image_backgrounds' defaultMessage='Image backgrounds' /></h2> |
|
|
|
<h2><FormattedMessage id='settings.image_backgrounds' defaultMessage='Image backgrounds' /></h2> |
|
|
|
<SettingsItem |
|
|
|
<LocalSettingsPageItem |
|
|
|
settings={this.props.settings} |
|
|
|
settings={settings} |
|
|
|
item={['collapsed', 'backgrounds', 'user_backgrounds']} |
|
|
|
item={['collapsed', 'backgrounds', 'user_backgrounds']} |
|
|
|
id='mastodon-settings--collapsed-user-backgrouns' |
|
|
|
id='mastodon-settings--collapsed-user-backgrouns' |
|
|
|
onChange={this.props.toggleSetting} |
|
|
|
onChange={onChange} |
|
|
|
dependsOn={[['collapsed', 'enabled']]} |
|
|
|
dependsOn={[['collapsed', 'enabled']]} |
|
|
|
> |
|
|
|
> |
|
|
|
<FormattedMessage id='settings.image_backgrounds_users' defaultMessage='Give collapsed toots an image background' /> |
|
|
|
<FormattedMessage id='settings.image_backgrounds_users' defaultMessage='Give collapsed toots an image background' /> |
|
|
|
</SettingsItem> |
|
|
|
</LocalSettingsPageItem> |
|
|
|
<SettingsItem |
|
|
|
<LocalSettingsPageItem |
|
|
|
settings={this.props.settings} |
|
|
|
settings={settings} |
|
|
|
item={['collapsed', 'backgrounds', 'preview_images']} |
|
|
|
item={['collapsed', 'backgrounds', 'preview_images']} |
|
|
|
id='mastodon-settings--collapsed-preview-images' |
|
|
|
id='mastodon-settings--collapsed-preview-images' |
|
|
|
onChange={this.props.toggleSetting} |
|
|
|
onChange={onChange} |
|
|
|
dependsOn={[['collapsed', 'enabled']]} |
|
|
|
dependsOn={[['collapsed', 'enabled']]} |
|
|
|
> |
|
|
|
> |
|
|
|
<FormattedMessage id='settings.image_backgrounds_media' defaultMessage='Preview collapsed toot media' /> |
|
|
|
<FormattedMessage id='settings.image_backgrounds_media' defaultMessage='Preview collapsed toot media' /> |
|
|
|
</SettingsItem> |
|
|
|
</LocalSettingsPageItem> |
|
|
|
</section> |
|
|
|
</section> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
); |
|
|
|
), |
|
|
|
} |
|
|
|
({ onChange, settings }) => ( |
|
|
|
|
|
|
|
<div className='glitch local-settings__page media'> |
|
|
|
Media = () => { |
|
|
|
|
|
|
|
return ( |
|
|
|
|
|
|
|
<div> |
|
|
|
|
|
|
|
<h1><FormattedMessage id='settings.media' defaultMessage='Media' /></h1> |
|
|
|
<h1><FormattedMessage id='settings.media' defaultMessage='Media' /></h1> |
|
|
|
<SettingsItem |
|
|
|
<LocalSettingsPageItem |
|
|
|
settings={this.props.settings} |
|
|
|
settings={settings} |
|
|
|
item={['media', 'letterbox']} |
|
|
|
item={['media', 'letterbox']} |
|
|
|
id='mastodon-settings--media-letterbox' |
|
|
|
id='mastodon-settings--media-letterbox' |
|
|
|
onChange={this.props.toggleSetting} |
|
|
|
onChange={onChange} |
|
|
|
> |
|
|
|
> |
|
|
|
<FormattedMessage id='settings.media_letterbox' defaultMessage='Letterbox media' /> |
|
|
|
<FormattedMessage id='settings.media_letterbox' defaultMessage='Letterbox media' /> |
|
|
|
</SettingsItem> |
|
|
|
</LocalSettingsPageItem> |
|
|
|
<SettingsItem |
|
|
|
<LocalSettingsPageItem |
|
|
|
settings={this.props.settings} |
|
|
|
settings={settings} |
|
|
|
item={['media', 'fullwidth']} |
|
|
|
item={['media', 'fullwidth']} |
|
|
|
id='mastodon-settings--media-fullwidth' |
|
|
|
id='mastodon-settings--media-fullwidth' |
|
|
|
onChange={this.props.toggleSetting} |
|
|
|
onChange={onChange} |
|
|
|
> |
|
|
|
> |
|
|
|
<FormattedMessage id='settings.media_fullwidth' defaultMessage='Full-width media previews' /> |
|
|
|
<FormattedMessage id='settings.media_fullwidth' defaultMessage='Full-width media previews' /> |
|
|
|
</SettingsItem> |
|
|
|
</LocalSettingsPageItem> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
); |
|
|
|
), |
|
|
|
} |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
navigateTo = (e) => |
|
|
|
|
|
|
|
this.setState({ currentIndex: +e.currentTarget.getAttribute('data-mastodon-navigation_index') }); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
render () { |
|
|
|
render () { |
|
|
|
|
|
|
|
const { pages } = this; |
|
|
|
|
|
|
|
const { index, intl, onChange, settings } = this.props; |
|
|
|
|
|
|
|
const CurrentPage = pages[index] || pages[0]; |
|
|
|
|
|
|
|
|
|
|
|
const { General, CollapsedStatuses, Media, navigateTo } = this; |
|
|
|
return <CurrentPage intl={intl} onChange={onChange} settings={settings} />; |
|
|
|
const { onClose } = this.props; |
|
|
|
|
|
|
|
const { currentIndex } = this.state; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
|
|
|
<div className='modal-root__modal settings-modal'> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<nav className='settings-modal__navigation'> |
|
|
|
|
|
|
|
<a onClick={navigateTo} role='button' data-mastodon-navigation_index='0' tabIndex='0' className={`settings-modal__navigation-item${currentIndex === 0 ? ' active' : ''}`}> |
|
|
|
|
|
|
|
<FormattedMessage id='settings.general' defaultMessage='General' /> |
|
|
|
|
|
|
|
</a> |
|
|
|
|
|
|
|
<a onClick={navigateTo} role='button' data-mastodon-navigation_index='1' tabIndex='0' className={`settings-modal__navigation-item${currentIndex === 1 ? ' active' : ''}`}> |
|
|
|
|
|
|
|
<FormattedMessage id='settings.collapsed_statuses' defaultMessage='Collapsed toots' /> |
|
|
|
|
|
|
|
</a> |
|
|
|
|
|
|
|
<a onClick={navigateTo} role='button' data-mastodon-navigation_index='2' tabIndex='0' className={`settings-modal__navigation-item${currentIndex === 2 ? ' active' : ''}`}> |
|
|
|
|
|
|
|
<FormattedMessage id='settings.media' defaultMessage='Media' /> |
|
|
|
|
|
|
|
</a> |
|
|
|
|
|
|
|
<a href='/settings/preferences' className='settings-modal__navigation-item'> |
|
|
|
|
|
|
|
<i className='fa fa-fw fa-cog' /> <FormattedMessage id='settings.preferences' defaultMessage='User preferences' /> |
|
|
|
|
|
|
|
</a> |
|
|
|
|
|
|
|
<a onClick={onClose} role='button' tabIndex='0' className='settings-modal__navigation-close'> |
|
|
|
|
|
|
|
<FormattedMessage id='settings.close' defaultMessage='Close' /> |
|
|
|
|
|
|
|
</a> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</nav> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div className='settings-modal__content'> |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
[ |
|
|
|
|
|
|
|
<General />, |
|
|
|
|
|
|
|
<CollapsedStatuses />, |
|
|
|
|
|
|
|
<Media />, |
|
|
|
|
|
|
|
][currentIndex] || <General /> |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |