diff options
Diffstat (limited to 'app/javascript')
15 files changed, 177 insertions, 146 deletions
diff --git a/app/javascript/mastodon/actions/columns.js b/app/javascript/mastodon/actions/columns.js index f550e6c48..9b87415fb 100644 --- a/app/javascript/mastodon/actions/columns.js +++ b/app/javascript/mastodon/actions/columns.js @@ -40,12 +40,13 @@ export function moveColumn(uuid, direction) { }; }; -export function changeColumnParams(uuid, params) { +export function changeColumnParams(uuid, path, value) { return dispatch => { dispatch({ type: COLUMN_PARAMS_CHANGE, uuid, - params, + path, + value, }); dispatch(saveSettings()); diff --git a/app/javascript/mastodon/features/community_timeline/components/column_settings.js b/app/javascript/mastodon/features/community_timeline/components/column_settings.js index a992b27bb..3a1d19aa8 100644 --- a/app/javascript/mastodon/features/community_timeline/components/column_settings.js +++ b/app/javascript/mastodon/features/community_timeline/components/column_settings.js @@ -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'> diff --git a/app/javascript/mastodon/features/community_timeline/components/section_headline.js b/app/javascript/mastodon/features/community_timeline/components/section_headline.js deleted file mode 100644 index c7176d04b..000000000 --- a/app/javascript/mastodon/features/community_timeline/components/section_headline.js +++ /dev/null @@ -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> - ); - } - -} diff --git a/app/javascript/mastodon/features/community_timeline/containers/column_settings_container.js b/app/javascript/mastodon/features/community_timeline/containers/column_settings_container.js index f3489b409..405064c3f 100644 --- a/app/javascript/mastodon/features/community_timeline/containers/column_settings_container.js +++ b/app/javascript/mastodon/features/community_timeline/containers/column_settings_container.js @@ -1,17 +1,28 @@ import { connect } from 'react-redux'; import ColumnSettings from '../components/column_settings'; import { changeSetting } from '../../../actions/settings'; +import { changeColumnParams } from '../../../actions/columns'; -const mapStateToProps = state => ({ - settings: state.getIn(['settings', 'community']), -}); +const mapStateToProps = (state, { columnId }) => { + const uuid = columnId; + const columns = state.getIn(['settings', 'columns']); + const index = columns.findIndex(c => c.get('uuid') === uuid); -const mapDispatchToProps = dispatch => ({ + return { + settings: (uuid && index >= 0) ? columns.get(index).get('params') : state.getIn(['settings', 'community']), + }; +}; - onChange (key, checked) { - dispatch(changeSetting(['community', ...key], checked)); - }, - -}); +const mapDispatchToProps = (dispatch, { columnId }) => { + return { + onChange (key, checked) { + if (columnId) { + dispatch(changeColumnParams(columnId, key, checked)); + } else { + dispatch(changeSetting(['community', ...key], checked)); + } + }, + }; +}; export default connect(mapStateToProps, mapDispatchToProps)(ColumnSettings); diff --git a/app/javascript/mastodon/features/community_timeline/index.js b/app/javascript/mastodon/features/community_timeline/index.js index d375edbd5..eb9ad97a2 100644 --- a/app/javascript/mastodon/features/community_timeline/index.js +++ b/app/javascript/mastodon/features/community_timeline/index.js @@ -6,23 +6,33 @@ import StatusListContainer from '../ui/containers/status_list_container'; import Column from '../../components/column'; import ColumnHeader from '../../components/column_header'; import { expandCommunityTimeline } from '../../actions/timelines'; -import { addColumn, removeColumn, moveColumn, changeColumnParams } from '../../actions/columns'; +import { addColumn, removeColumn, moveColumn } from '../../actions/columns'; import ColumnSettingsContainer from './containers/column_settings_container'; -import SectionHeadline from './components/section_headline'; import { connectCommunityStream } from '../../actions/streaming'; const messages = defineMessages({ title: { id: 'column.community', defaultMessage: 'Local timeline' }, }); -const mapStateToProps = (state, { onlyMedia }) => ({ - hasUnread: state.getIn(['timelines', `community${onlyMedia ? ':media' : ''}`, 'unread']) > 0, -}); +const mapStateToProps = (state, { onlyMedia, columnId }) => { + const uuid = columnId; + const columns = state.getIn(['settings', 'columns']); + const index = columns.findIndex(c => c.get('uuid') === uuid); + + return { + hasUnread: state.getIn(['timelines', `community${onlyMedia ? ':media' : ''}`, 'unread']) > 0, + onlyMedia: (columnId && index >= 0) ? columns.get(index).getIn(['params', 'other', 'onlyMedia']) : state.getIn(['settings', 'community', 'other', 'onlyMedia']), + }; +}; @connect(mapStateToProps) @injectIntl export default class CommunityTimeline extends React.PureComponent { + static contextTypes = { + router: PropTypes.object, + }; + static defaultProps = { onlyMedia: false, }; @@ -89,27 +99,10 @@ export default class CommunityTimeline extends React.PureComponent { dispatch(expandCommunityTimeline({ maxId, onlyMedia })); } - handleHeadlineLinkClick = e => { - const { columnId, dispatch } = this.props; - const onlyMedia = /\/media$/.test(e.currentTarget.href); - - dispatch(changeColumnParams(columnId, { other: { onlyMedia } })); - } - render () { const { intl, hasUnread, columnId, multiColumn, onlyMedia } = this.props; const pinned = !!columnId; - const headline = ( - <SectionHeadline - timelineId='community' - to='/timelines/public/local' - pinned={pinned} - onlyMedia={onlyMedia} - onClick={this.handleHeadlineLinkClick} - /> - ); - return ( <Column ref={this.setRef}> <ColumnHeader @@ -122,12 +115,10 @@ export default class CommunityTimeline extends React.PureComponent { pinned={pinned} multiColumn={multiColumn} > - <ColumnSettingsContainer /> + <ColumnSettingsContainer columnId={columnId} /> </ColumnHeader> <StatusListContainer - prepend={headline} - alwaysPrepend trackScroll={!pinned} scrollKey={`community_timeline-${columnId}`} timelineId={`community${onlyMedia ? ':media' : ''}`} diff --git a/app/javascript/mastodon/features/compose/components/compose_form.js b/app/javascript/mastodon/features/compose/components/compose_form.js index e2d9eba81..cc9145683 100644 --- a/app/javascript/mastodon/features/compose/components/compose_form.js +++ b/app/javascript/mastodon/features/compose/components/compose_form.js @@ -128,9 +128,7 @@ export default class ComposeForm extends ImmutablePureComponent { this.autosuggestTextarea.textarea.focus(); } else if(prevProps.is_submitting && !this.props.is_submitting) { this.autosuggestTextarea.textarea.focus(); - } - - if (this.props.spoiler !== prevProps.spoiler) { + } else if (this.props.spoiler !== prevProps.spoiler) { if (this.props.spoiler) { this.spoilerText.focus(); } else { diff --git a/app/javascript/mastodon/features/direct_timeline/components/column_settings.js b/app/javascript/mastodon/features/direct_timeline/components/column_settings.js new file mode 100644 index 000000000..a992b27bb --- /dev/null +++ b/app/javascript/mastodon/features/direct_timeline/components/column_settings.js @@ -0,0 +1,35 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import ImmutablePropTypes from 'react-immutable-proptypes'; +import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; +import SettingText from '../../../components/setting_text'; + +const messages = defineMessages({ + filter_regex: { id: 'home.column_settings.filter_regex', defaultMessage: 'Filter out by regular expressions' }, + settings: { id: 'home.settings', defaultMessage: 'Column settings' }, +}); + +@injectIntl +export default class ColumnSettings extends React.PureComponent { + + static propTypes = { + settings: ImmutablePropTypes.map.isRequired, + onChange: PropTypes.func.isRequired, + intl: PropTypes.object.isRequired, + }; + + render () { + const { settings, onChange, intl } = this.props; + + return ( + <div> + <span className='column-settings__section'><FormattedMessage id='home.column_settings.advanced' defaultMessage='Advanced' /></span> + + <div className='column-settings__row'> + <SettingText settings={settings} settingKey={['regex', 'body']} onChange={onChange} label={intl.formatMessage(messages.filter_regex)} /> + </div> + </div> + ); + } + +} diff --git a/app/javascript/mastodon/features/direct_timeline/containers/column_settings_container.js b/app/javascript/mastodon/features/direct_timeline/containers/column_settings_container.js index 1833f69e5..38054ce9e 100644 --- a/app/javascript/mastodon/features/direct_timeline/containers/column_settings_container.js +++ b/app/javascript/mastodon/features/direct_timeline/containers/column_settings_container.js @@ -1,5 +1,5 @@ import { connect } from 'react-redux'; -import ColumnSettings from '../../community_timeline/components/column_settings'; +import ColumnSettings from '../components/column_settings'; import { changeSetting } from '../../../actions/settings'; const mapStateToProps = state => ({ diff --git a/app/javascript/mastodon/features/getting_started/index.js b/app/javascript/mastodon/features/getting_started/index.js index 115dfd2b9..0df2d8bbf 100644 --- a/app/javascript/mastodon/features/getting_started/index.js +++ b/app/javascript/mastodon/features/getting_started/index.js @@ -7,7 +7,7 @@ import { connect } from 'react-redux'; import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePureComponent from 'react-immutable-pure-component'; -import { me } from '../../initial_state'; +import { me, invitesEnabled } from '../../initial_state'; import { fetchFollowRequests } from '../../actions/accounts'; import { List as ImmutableList } from 'immutable'; import { Link } from 'react-router-dom'; @@ -135,9 +135,13 @@ export default class GettingStarted extends ImmutablePureComponent { <div className='getting-started getting-started__footer'> <ul> + <li><a href='https://bridge.joinmastodon.org/' target='_blank'><FormattedMessage id='getting_started.find_friends' defaultMessage='Find friends from Twitter' /></a> · </li> + {invitesEnabled && <li><a href='/invites' target='_blank'><FormattedMessage id='getting_started.invite' defaultMessage='Invite people' /></a> · </li>} {multiColumn && <li><Link to='/keyboard-shortcuts'><FormattedMessage id='navigation_bar.keyboard_shortcuts' defaultMessage='Hotkeys' /></Link> · </li>} + <li><a href='/auth/edit'><FormattedMessage id='getting_started.security' defaultMessage='Security' /></a> · </li> <li><a href='/about/more' target='_blank'><FormattedMessage id='navigation_bar.info' defaultMessage='About this instance' /></a> · </li> <li><a href='/terms' target='_blank'><FormattedMessage id='getting_started.terms' defaultMessage='Terms of service' /></a> · </li> + <li><a href='/settings/applications' target='_blank'><FormattedMessage id='getting_started.developers' defaultMessage='Developers' /></a> · </li> <li><a href='https://github.com/tootsuite/documentation#documentation' target='_blank'><FormattedMessage id='getting_started.documentation' defaultMessage='Documentation' /></a> · </li> <li><a href='/auth/sign_out' data-method='delete'><FormattedMessage id='navigation_bar.logout' defaultMessage='Logout' /></a></li> </ul> diff --git a/app/javascript/mastodon/features/public_timeline/containers/column_settings_container.js b/app/javascript/mastodon/features/public_timeline/containers/column_settings_container.js index 203e1da92..c56caa59e 100644 --- a/app/javascript/mastodon/features/public_timeline/containers/column_settings_container.js +++ b/app/javascript/mastodon/features/public_timeline/containers/column_settings_container.js @@ -1,17 +1,28 @@ import { connect } from 'react-redux'; import ColumnSettings from '../../community_timeline/components/column_settings'; import { changeSetting } from '../../../actions/settings'; +import { changeColumnParams } from '../../../actions/columns'; -const mapStateToProps = state => ({ - settings: state.getIn(['settings', 'public']), -}); +const mapStateToProps = (state, { columnId }) => { + const uuid = columnId; + const columns = state.getIn(['settings', 'columns']); + const index = columns.findIndex(c => c.get('uuid') === uuid); -const mapDispatchToProps = dispatch => ({ + return { + settings: (uuid && index >= 0) ? columns.get(index).get('params') : state.getIn(['settings', 'public']), + }; +}; - onChange (key, checked) { - dispatch(changeSetting(['public', ...key], checked)); - }, - -}); +const mapDispatchToProps = (dispatch, { columnId }) => { + return { + onChange (key, checked) { + if (columnId) { + dispatch(changeColumnParams(columnId, key, checked)); + } else { + dispatch(changeSetting(['public', ...key], checked)); + } + }, + }; +}; export default connect(mapStateToProps, mapDispatchToProps)(ColumnSettings); diff --git a/app/javascript/mastodon/features/public_timeline/index.js b/app/javascript/mastodon/features/public_timeline/index.js index 341af582a..2d5bb3baf 100644 --- a/app/javascript/mastodon/features/public_timeline/index.js +++ b/app/javascript/mastodon/features/public_timeline/index.js @@ -6,23 +6,33 @@ import StatusListContainer from '../ui/containers/status_list_container'; import Column from '../../components/column'; import ColumnHeader from '../../components/column_header'; import { expandPublicTimeline } from '../../actions/timelines'; -import { addColumn, removeColumn, moveColumn, changeColumnParams } from '../../actions/columns'; +import { addColumn, removeColumn, moveColumn } from '../../actions/columns'; import ColumnSettingsContainer from './containers/column_settings_container'; -import SectionHeadline from '../community_timeline/components/section_headline'; import { connectPublicStream } from '../../actions/streaming'; const messages = defineMessages({ title: { id: 'column.public', defaultMessage: 'Federated timeline' }, }); -const mapStateToProps = (state, { onlyMedia }) => ({ - hasUnread: state.getIn(['timelines', `public${onlyMedia ? ':media' : ''}`, 'unread']) > 0, -}); +const mapStateToProps = (state, { onlyMedia, columnId }) => { + const uuid = columnId; + const columns = state.getIn(['settings', 'columns']); + const index = columns.findIndex(c => c.get('uuid') === uuid); + + return { + hasUnread: state.getIn(['timelines', `public${onlyMedia ? ':media' : ''}`, 'unread']) > 0, + onlyMedia: (columnId && index >= 0) ? columns.get(index).getIn(['params', 'other', 'onlyMedia']) : state.getIn(['settings', 'public', 'other', 'onlyMedia']), + }; +}; @connect(mapStateToProps) @injectIntl export default class PublicTimeline extends React.PureComponent { + static contextTypes = { + router: PropTypes.object, + }; + static defaultProps = { onlyMedia: false, }; @@ -89,27 +99,17 @@ export default class PublicTimeline extends React.PureComponent { dispatch(expandPublicTimeline({ maxId, onlyMedia })); } - handleHeadlineLinkClick = e => { - const { columnId, dispatch } = this.props; - const onlyMedia = /\/media$/.test(e.currentTarget.href); - - dispatch(changeColumnParams(columnId, { other: { onlyMedia } })); + handleSettingChanged = (key, checked) => { + const { columnId } = this.props; + if (!columnId && key[0] === 'other' && key[1] === 'onlyMedia') { + this.context.router.history.replace(`/timelines/public${checked ? '/media' : ''}`); + } } render () { const { intl, columnId, hasUnread, multiColumn, onlyMedia } = this.props; const pinned = !!columnId; - const headline = ( - <SectionHeadline - timelineId='public' - to='/timelines/public' - pinned={pinned} - onlyMedia={onlyMedia} - onClick={this.handleHeadlineLinkClick} - /> - ); - return ( <Column ref={this.setRef}> <ColumnHeader @@ -122,12 +122,10 @@ export default class PublicTimeline extends React.PureComponent { pinned={pinned} multiColumn={multiColumn} > - <ColumnSettingsContainer /> + <ColumnSettingsContainer onChange={this.handleSettingChanged} columnId={columnId} /> </ColumnHeader> <StatusListContainer - prepend={headline} - alwaysPrepend timelineId={`public${onlyMedia ? ':media' : ''}`} onLoadMore={this.handleLoadMore} trackScroll={!pinned} diff --git a/app/javascript/mastodon/initial_state.js b/app/javascript/mastodon/initial_state.js index a67cdce3d..1d23e34b1 100644 --- a/app/javascript/mastodon/initial_state.js +++ b/app/javascript/mastodon/initial_state.js @@ -12,5 +12,6 @@ export const deleteModal = getMeta('delete_modal'); export const me = getMeta('me'); export const searchEnabled = getMeta('search_enabled'); export const maxChars = getMeta('max_toot_chars') || 500; +export const invitesEnabled = getMeta('invites_enabled'); export default initialState; diff --git a/app/javascript/mastodon/reducers/settings.js b/app/javascript/mastodon/reducers/settings.js index 0a034d739..12bcc2583 100644 --- a/app/javascript/mastodon/reducers/settings.js +++ b/app/javascript/mastodon/reducers/settings.js @@ -93,11 +93,11 @@ const moveColumn = (state, uuid, direction) => { .set('saved', false); }; -const changeColumnParams = (state, uuid, params) => { +const changeColumnParams = (state, uuid, path, value) => { const columns = state.get('columns'); const index = columns.findIndex(item => item.get('uuid') === uuid); - const newColumns = columns.update(index, column => column.update('params', () => fromJS(params))); + const newColumns = columns.update(index, column => column.updateIn(['params', ...path], () => value)); return state .set('columns', newColumns) @@ -127,7 +127,7 @@ export default function settings(state = initialState, action) { case COLUMN_MOVE: return moveColumn(state, action.uuid, action.direction); case COLUMN_PARAMS_CHANGE: - return changeColumnParams(state, action.uuid, action.params); + return changeColumnParams(state, action.uuid, action.path, action.value); case EMOJI_USE: return updateFrequentEmojis(state, action.emoji); case SETTING_SAVE: diff --git a/app/javascript/styles/mastodon/accounts.scss b/app/javascript/styles/mastodon/accounts.scss index 3ccce383b..14dc5dd62 100644 --- a/app/javascript/styles/mastodon/accounts.scss +++ b/app/javascript/styles/mastodon/accounts.scss @@ -458,23 +458,31 @@ } .account-card { - padding: 14px 10px; - background: $simple-background-color; border-radius: 4px; text-align: left; box-shadow: 0 0 15px rgba($base-shadow-color, 0.2); + background: $simple-background-color; + + &__header { + background-size: cover; + background-position: center center; + height: 90px; + border-radius: 4px 4px 0 0; + } - .detailed-status__display-name { + & > .detailed-status__display-name { display: block; overflow: hidden; - margin-bottom: 15px; + display: flex; + align-items: center; + padding: 10px; &:last-child { margin-bottom: 0; } - & > div { - float: left; + & > div:first-child { + flex: 0 0 auto; margin-right: 10px; width: 48px; height: 48px; @@ -483,9 +491,11 @@ .avatar { display: block; border-radius: 4px; + margin: 0; } .display-name { + flex: 1 0 auto; display: block; max-width: 100%; overflow: hidden; @@ -493,6 +503,10 @@ text-overflow: ellipsis; cursor: default; + & > .detailed-status__display-name { + margin-bottom: 0; + } + strong { font-weight: 500; color: $ui-base-color; @@ -519,9 +533,28 @@ } } - .account__header__content { - font-size: 14px; - color: $inverted-text-color; + .counter { + box-sizing: border-box; + flex: 0 0 auto; + color: $light-text-color; + padding: 0 10px; + cursor: default; + text-align: center; + position: relative; + line-height: 24px; + + .counter-label { + font-size: 12px; + display: block; + text-transform: uppercase; + } + + .counter-number { + font-weight: 500; + font-size: 16px; + color: $inverted-text-color; + font-family: 'mastodon-font-display', sans-serif; + } } } diff --git a/app/javascript/styles/mastodon/components.scss b/app/javascript/styles/mastodon/components.scss index 718c0c680..3ff59d30f 100644 --- a/app/javascript/styles/mastodon/components.scss +++ b/app/javascript/styles/mastodon/components.scss @@ -1494,6 +1494,7 @@ a.account__display-name { .navigation-bar { padding: 10px; display: flex; + align-items: center; flex-shrink: 0; cursor: default; color: $darker-text-color; @@ -1531,6 +1532,8 @@ a.account__display-name { .navigation-bar__profile { flex: 1 1 auto; margin-left: 8px; + line-height: 20px; + margin-top: -1px; overflow: hidden; } @@ -4806,8 +4809,6 @@ a.status-card { } } -.community-timeline__section-headline, -.public-timeline__section-headline, .account__section-headline { background: darken($ui-base-color, 4%); border-bottom: 1px solid lighten($ui-base-color, 8%); |