From acf1842896682674d9ab4d0f87ec04c6174468fa Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 9 Feb 2021 01:21:06 +0100 Subject: Change max. image dimensions to 1920x1080px (1080p) (#15690) * Change max. image size to 1920x1080px * Change it in web UI too --- app/javascript/mastodon/utils/resize_image.js | 2 +- app/models/media_attachment.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/javascript/mastodon/utils/resize_image.js b/app/javascript/mastodon/utils/resize_image.js index 8f1485379..22ff86801 100644 --- a/app/javascript/mastodon/utils/resize_image.js +++ b/app/javascript/mastodon/utils/resize_image.js @@ -1,6 +1,6 @@ import EXIF from 'exif-js'; -const MAX_IMAGE_PIXELS = 1638400; // 1280x1280px +const MAX_IMAGE_PIXELS = 2073600; // 1920x1080px const _browser_quirks = {}; diff --git a/app/models/media_attachment.rb b/app/models/media_attachment.rb index 663bb0896..5cf4d8127 100644 --- a/app/models/media_attachment.rb +++ b/app/models/media_attachment.rb @@ -59,7 +59,7 @@ class MediaAttachment < ApplicationRecord IMAGE_STYLES = { original: { - pixels: 1_638_400, # 1280x1280px + pixels: 2_073_600, # 1920x1080px file_geometry_parser: FastGeometryParser, }.freeze, -- cgit From acdeb162b8c2e7d036c34690de85dea70277713d Mon Sep 17 00:00:00 2001 From: Claire Date: Tue, 9 Feb 2021 18:12:54 +0100 Subject: Create instance actor if it hasn't been properly seeded (#15693) An uncommon but somewhat difficult to digagnose issue is dealing with improperly-seeded databases. In such cases, instance-signed fetches will fail with a ActiveRecord::RecordNotFound error, usually caught and handled as generic 404, leading people to think the remote resource itself has not been found, while it's the local instance actor that does not exist. This commit changes the code so that failure to find the instance actor automatically creates a new one, so that improperly-seeded databases do not cause any issue. --- app/controllers/instance_actors_controller.rb | 2 +- app/models/concerns/account_finder_concern.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/controllers/instance_actors_controller.rb b/app/controllers/instance_actors_controller.rb index 4b074ca19..b3b5476e2 100644 --- a/app/controllers/instance_actors_controller.rb +++ b/app/controllers/instance_actors_controller.rb @@ -13,7 +13,7 @@ class InstanceActorsController < ApplicationController private def set_account - @account = Account.find(-99) + @account = Account.representative end def restrict_fields_to diff --git a/app/models/concerns/account_finder_concern.rb b/app/models/concerns/account_finder_concern.rb index 04b2c981b..0dadddad1 100644 --- a/app/models/concerns/account_finder_concern.rb +++ b/app/models/concerns/account_finder_concern.rb @@ -14,6 +14,8 @@ module AccountFinderConcern def representative Account.find(-99) + rescue ActiveRecord::RecordNotFound + Account.create!(id: -99, actor_type: 'Application', locked: true, username: Rails.configuration.x.local_domain) end def find_local(username) -- cgit From 07b46cb332ae197584e3ed3f23fe814b7793ec4c Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 11 Feb 2021 00:53:12 +0100 Subject: Add dropdown for boost privacy in boost confirmation modal (#15704) * Various dropdown code quality fixes * Prepare support for privacy selection in boost modal * Add dropdown for boost privacy in boost confirmation modal --- app/javascript/mastodon/actions/boosts.js | 29 +++++++++++++++++ app/javascript/mastodon/actions/interactions.js | 4 +-- .../mastodon/components/dropdown_menu.js | 1 - .../mastodon/containers/dropdown_menu_container.js | 1 - .../mastodon/containers/status_container.js | 7 ++-- .../compose/components/privacy_dropdown.js | 18 ++++++---- .../containers/privacy_dropdown_container.js | 1 - .../containers/notification_container.js | 7 ++-- .../picture_in_picture/components/footer.js | 11 ++++--- .../status/containers/detailed_status_container.js | 7 ++-- app/javascript/mastodon/features/status/index.js | 7 ++-- .../mastodon/features/ui/components/boost_modal.js | 38 ++++++++++++++++++++-- app/javascript/mastodon/reducers/boosts.js | 25 ++++++++++++++ app/javascript/mastodon/reducers/index.js | 2 ++ app/javascript/styles/mastodon/components.scss | 10 ++++++ 15 files changed, 137 insertions(+), 31 deletions(-) create mode 100644 app/javascript/mastodon/actions/boosts.js create mode 100644 app/javascript/mastodon/reducers/boosts.js (limited to 'app') diff --git a/app/javascript/mastodon/actions/boosts.js b/app/javascript/mastodon/actions/boosts.js new file mode 100644 index 000000000..6e14065d6 --- /dev/null +++ b/app/javascript/mastodon/actions/boosts.js @@ -0,0 +1,29 @@ +import { openModal } from './modal'; + +export const BOOSTS_INIT_MODAL = 'BOOSTS_INIT_MODAL'; +export const BOOSTS_CHANGE_PRIVACY = 'BOOSTS_CHANGE_PRIVACY'; + +export function initBoostModal(props) { + return (dispatch, getState) => { + const default_privacy = getState().getIn(['compose', 'default_privacy']); + + const privacy = props.status.get('visibility') === 'private' ? 'private' : default_privacy; + + dispatch({ + type: BOOSTS_INIT_MODAL, + privacy + }); + + dispatch(openModal('BOOST', props)); + }; +} + + +export function changeBoostPrivacy(privacy) { + return dispatch => { + dispatch({ + type: BOOSTS_CHANGE_PRIVACY, + privacy, + }); + }; +} diff --git a/app/javascript/mastodon/actions/interactions.js b/app/javascript/mastodon/actions/interactions.js index 28c6b1a62..d60ccc1fb 100644 --- a/app/javascript/mastodon/actions/interactions.js +++ b/app/javascript/mastodon/actions/interactions.js @@ -41,11 +41,11 @@ export const UNBOOKMARK_REQUEST = 'UNBOOKMARKED_REQUEST'; export const UNBOOKMARK_SUCCESS = 'UNBOOKMARKED_SUCCESS'; export const UNBOOKMARK_FAIL = 'UNBOOKMARKED_FAIL'; -export function reblog(status) { +export function reblog(status, visibility) { return function (dispatch, getState) { dispatch(reblogRequest(status)); - api(getState).post(`/api/v1/statuses/${status.get('id')}/reblog`).then(function (response) { + api(getState).post(`/api/v1/statuses/${status.get('id')}/reblog`, { visibility }).then(function (response) { // The reblog API method returns a new status wrapped around the original. In this case we are only // interested in how the original is modified, hence passing it skipping the wrapper dispatch(importFetchedStatus(response.data.reblog)); diff --git a/app/javascript/mastodon/components/dropdown_menu.js b/app/javascript/mastodon/components/dropdown_menu.js index c6b4b1187..7d0588901 100644 --- a/app/javascript/mastodon/components/dropdown_menu.js +++ b/app/javascript/mastodon/components/dropdown_menu.js @@ -177,7 +177,6 @@ export default class Dropdown extends React.PureComponent { disabled: PropTypes.bool, status: ImmutablePropTypes.map, isUserTouching: PropTypes.func, - isModalOpen: PropTypes.bool.isRequired, onOpen: PropTypes.func.isRequired, onClose: PropTypes.func.isRequired, dropdownPlacement: PropTypes.string, diff --git a/app/javascript/mastodon/containers/dropdown_menu_container.js b/app/javascript/mastodon/containers/dropdown_menu_container.js index 6ec9bbffd..c45bab40b 100644 --- a/app/javascript/mastodon/containers/dropdown_menu_container.js +++ b/app/javascript/mastodon/containers/dropdown_menu_container.js @@ -6,7 +6,6 @@ import DropdownMenu from '../components/dropdown_menu'; import { isUserTouching } from '../is_mobile'; const mapStateToProps = state => ({ - isModalOpen: state.get('modal').modalType === 'ACTIONS', dropdownPlacement: state.getIn(['dropdown_menu', 'placement']), openDropdownId: state.getIn(['dropdown_menu', 'openId']), openedViaKeyboard: state.getIn(['dropdown_menu', 'keyboard']), diff --git a/app/javascript/mastodon/containers/status_container.js b/app/javascript/mastodon/containers/status_container.js index d6bcb8973..9abdec138 100644 --- a/app/javascript/mastodon/containers/status_container.js +++ b/app/javascript/mastodon/containers/status_container.js @@ -35,6 +35,7 @@ import { } from '../actions/domain_blocks'; import { initMuteModal } from '../actions/mutes'; import { initBlockModal } from '../actions/blocks'; +import { initBoostModal } from '../actions/boosts'; import { initReport } from '../actions/reports'; import { openModal } from '../actions/modal'; import { deployPictureInPicture } from '../actions/picture_in_picture'; @@ -82,11 +83,11 @@ const mapDispatchToProps = (dispatch, { intl }) => ({ }); }, - onModalReblog (status) { + onModalReblog (status, privacy) { if (status.get('reblogged')) { dispatch(unreblog(status)); } else { - dispatch(reblog(status)); + dispatch(reblog(status, privacy)); } }, @@ -94,7 +95,7 @@ const mapDispatchToProps = (dispatch, { intl }) => ({ if ((e && e.shiftKey) || !boostModal) { this.onModalReblog(status); } else { - dispatch(openModal('BOOST', { status, onReblog: this.onModalReblog })); + dispatch(initBoostModal({ status, onReblog: this.onModalReblog })); } }, diff --git a/app/javascript/mastodon/features/compose/components/privacy_dropdown.js b/app/javascript/mastodon/features/compose/components/privacy_dropdown.js index 309f46290..936b14e9e 100644 --- a/app/javascript/mastodon/features/compose/components/privacy_dropdown.js +++ b/app/javascript/mastodon/features/compose/components/privacy_dropdown.js @@ -127,7 +127,7 @@ class PrivacyDropdownMenu extends React.PureComponent { // It should not be transformed when mounting because the resulting // size will be used to determine the coordinate of the menu by // react-overlays -
+
{items.map(item => (
@@ -153,11 +153,12 @@ class PrivacyDropdown extends React.PureComponent { static propTypes = { isUserTouching: PropTypes.func, - isModalOpen: PropTypes.bool.isRequired, onModalOpen: PropTypes.func, onModalClose: PropTypes.func, value: PropTypes.string.isRequired, onChange: PropTypes.func.isRequired, + noDirect: PropTpes.bool, + container: PropTypes.func, intl: PropTypes.object.isRequired, }; @@ -167,7 +168,7 @@ class PrivacyDropdown extends React.PureComponent { }; handleToggle = ({ target }) => { - if (this.props.isUserTouching()) { + if (this.props.isUserTouching && this.props.isUserTouching()) { if (this.state.open) { this.props.onModalClose(); } else { @@ -236,12 +237,17 @@ class PrivacyDropdown extends React.PureComponent { { icon: 'globe', value: 'public', text: formatMessage(messages.public_short), meta: formatMessage(messages.public_long) }, { icon: 'unlock', value: 'unlisted', text: formatMessage(messages.unlisted_short), meta: formatMessage(messages.unlisted_long) }, { icon: 'lock', value: 'private', text: formatMessage(messages.private_short), meta: formatMessage(messages.private_long) }, - { icon: 'envelope', value: 'direct', text: formatMessage(messages.direct_short), meta: formatMessage(messages.direct_long) }, ]; + + if (!this.props.noDirect) { + this.options.push( + { icon: 'envelope', value: 'direct', text: formatMessage(messages.direct_short), meta: formatMessage(messages.direct_long) }, + ); + } } render () { - const { value, intl } = this.props; + const { value, container, intl } = this.props; const { open, placement } = this.state; const valueOption = this.options.find(item => item.value === value); @@ -264,7 +270,7 @@ class PrivacyDropdown extends React.PureComponent { />
- + ({ - isModalOpen: state.get('modal').modalType === 'ACTIONS', value: state.getIn(['compose', 'privacy']), }); diff --git a/app/javascript/mastodon/features/notifications/containers/notification_container.js b/app/javascript/mastodon/features/notifications/containers/notification_container.js index 78576c760..555d5e1b5 100644 --- a/app/javascript/mastodon/features/notifications/containers/notification_container.js +++ b/app/javascript/mastodon/features/notifications/containers/notification_container.js @@ -1,6 +1,7 @@ import { connect } from 'react-redux'; import { makeGetNotification, makeGetStatus } from '../../../selectors'; import Notification from '../components/notification'; +import { initBoostModal } from '../../../actions/boosts'; import { openModal } from '../../../actions/modal'; import { mentionCompose } from '../../../actions/compose'; import { @@ -35,8 +36,8 @@ const mapDispatchToProps = dispatch => ({ dispatch(mentionCompose(account, router)); }, - onModalReblog (status) { - dispatch(reblog(status)); + onModalReblog (status, privacy) { + dispatch(reblog(status, privacy)); }, onReblog (status, e) { @@ -46,7 +47,7 @@ const mapDispatchToProps = dispatch => ({ if (e.shiftKey || !boostModal) { this.onModalReblog(status); } else { - dispatch(openModal('BOOST', { status, onReblog: this.onModalReblog })); + dispatch(initBoostModal({ status, onReblog: this.onModalReblog })); } } }, diff --git a/app/javascript/mastodon/features/picture_in_picture/components/footer.js b/app/javascript/mastodon/features/picture_in_picture/components/footer.js index 1b1ec6d54..1ecb18bf8 100644 --- a/app/javascript/mastodon/features/picture_in_picture/components/footer.js +++ b/app/javascript/mastodon/features/picture_in_picture/components/footer.js @@ -10,6 +10,7 @@ import { defineMessages, injectIntl } from 'react-intl'; import { replyCompose } from 'mastodon/actions/compose'; import { reblog, favourite, unreblog, unfavourite } from 'mastodon/actions/interactions'; import { makeGetStatus } from 'mastodon/selectors'; +import { initBoostModal } from 'mastodon/actions/boosts'; import { openModal } from 'mastodon/actions/modal'; const messages = defineMessages({ @@ -89,9 +90,9 @@ class Footer extends ImmutablePureComponent { } }; - _performReblog = () => { - const { dispatch, status } = this.props; - dispatch(reblog(status)); + _performReblog = (status, privacy) => { + const { dispatch } = this.props; + dispatch(reblog(status, privacy)); } handleReblogClick = e => { @@ -100,9 +101,9 @@ class Footer extends ImmutablePureComponent { if (status.get('reblogged')) { dispatch(unreblog(status)); } else if ((e && e.shiftKey) || !boostModal) { - this._performReblog(); + this._performReblog(status); } else { - dispatch(openModal('BOOST', { status, onReblog: this._performReblog })); + dispatch(initBoostModal({ status, onReblog: this._performReblog })); } }; diff --git a/app/javascript/mastodon/features/status/containers/detailed_status_container.js b/app/javascript/mastodon/features/status/containers/detailed_status_container.js index 0ac4519c8..bfed16620 100644 --- a/app/javascript/mastodon/features/status/containers/detailed_status_container.js +++ b/app/javascript/mastodon/features/status/containers/detailed_status_container.js @@ -23,6 +23,7 @@ import { } from '../../../actions/statuses'; import { initMuteModal } from '../../../actions/mutes'; import { initBlockModal } from '../../../actions/blocks'; +import { initBoostModal } from '../../../actions/boosts'; import { initReport } from '../../../actions/reports'; import { openModal } from '../../../actions/modal'; import { defineMessages, injectIntl } from 'react-intl'; @@ -68,8 +69,8 @@ const mapDispatchToProps = (dispatch, { intl }) => ({ }); }, - onModalReblog (status) { - dispatch(reblog(status)); + onModalReblog (status, privacy) { + dispatch(reblog(status, privacy)); }, onReblog (status, e) { @@ -79,7 +80,7 @@ const mapDispatchToProps = (dispatch, { intl }) => ({ if (e.shiftKey || !boostModal) { this.onModalReblog(status); } else { - dispatch(openModal('BOOST', { status, onReblog: this.onModalReblog })); + dispatch(initBoostModal({ status, onReblog: this.onModalReblog })); } } }, diff --git a/app/javascript/mastodon/features/status/index.js b/app/javascript/mastodon/features/status/index.js index 09822f372..df8362a1b 100644 --- a/app/javascript/mastodon/features/status/index.js +++ b/app/javascript/mastodon/features/status/index.js @@ -42,6 +42,7 @@ import { } from '../../actions/domain_blocks'; import { initMuteModal } from '../../actions/mutes'; import { initBlockModal } from '../../actions/blocks'; +import { initBoostModal } from '../../actions/boosts'; import { initReport } from '../../actions/reports'; import { makeGetStatus, makeGetPictureInPicture } from '../../selectors'; import { ScrollContainer } from 'react-router-scroll-4'; @@ -234,8 +235,8 @@ class Status extends ImmutablePureComponent { } } - handleModalReblog = (status) => { - this.props.dispatch(reblog(status)); + handleModalReblog = (status, privacy) => { + this.props.dispatch(reblog(status, privacy)); } handleReblogClick = (status, e) => { @@ -245,7 +246,7 @@ class Status extends ImmutablePureComponent { if ((e && e.shiftKey) || !boostModal) { this.handleModalReblog(status); } else { - this.props.dispatch(openModal('BOOST', { status, onReblog: this.handleModalReblog })); + this.props.dispatch(initBoostModal({ status, onReblog: this.handleModalReblog })); } } } diff --git a/app/javascript/mastodon/features/ui/components/boost_modal.js b/app/javascript/mastodon/features/ui/components/boost_modal.js index 963bb5dc4..83229833b 100644 --- a/app/javascript/mastodon/features/ui/components/boost_modal.js +++ b/app/javascript/mastodon/features/ui/components/boost_modal.js @@ -1,4 +1,5 @@ import React from 'react'; +import { connect } from 'react-redux'; import ImmutablePropTypes from 'react-immutable-proptypes'; import PropTypes from 'prop-types'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; @@ -10,7 +11,9 @@ import DisplayName from '../../../components/display_name'; import ImmutablePureComponent from 'react-immutable-pure-component'; import Icon from 'mastodon/components/icon'; import AttachmentList from 'mastodon/components/attachment_list'; +import PrivacyDropdown from 'mastodon/features/compose/components/privacy_dropdown'; import classNames from 'classnames'; +import { changeBoostPrivacy } from 'mastodon/actions/boosts'; const messages = defineMessages({ cancel_reblog: { id: 'status.cancel_reblog_private', defaultMessage: 'Unboost' }, @@ -21,7 +24,22 @@ const messages = defineMessages({ direct_short: { id: 'privacy.direct.short', defaultMessage: 'Direct' }, }); -export default @injectIntl +const mapStateToProps = state => { + return { + privacy: state.getIn(['boosts', 'new', 'privacy']), + }; +}; + +const mapDispatchToProps = dispatch => { + return { + onChangeBoostPrivacy(value) { + dispatch(changeBoostPrivacy(value)); + }, + }; +}; + +export default @connect(mapStateToProps, mapDispatchToProps) +@injectIntl class BoostModal extends ImmutablePureComponent { static contextTypes = { @@ -32,6 +50,8 @@ class BoostModal extends ImmutablePureComponent { status: ImmutablePropTypes.map.isRequired, onReblog: PropTypes.func.isRequired, onClose: PropTypes.func.isRequired, + onChangeBoostPrivacy: PropTypes.func.isRequired, + privacy: PropTypes.string.isRequired, intl: PropTypes.object.isRequired, }; @@ -40,7 +60,7 @@ class BoostModal extends ImmutablePureComponent { } handleReblog = () => { - this.props.onReblog(this.props.status); + this.props.onReblog(this.props.status, this.props.privacy); this.props.onClose(); } @@ -52,12 +72,16 @@ class BoostModal extends ImmutablePureComponent { } } + _findContainer = () => { + return document.getElementsByClassName('modal-root__container')[0]; + }; + setRef = (c) => { this.button = c; } render () { - const { status, intl } = this.props; + const { status, privacy, intl } = this.props; const buttonText = status.get('reblogged') ? messages.cancel_reblog : messages.reblog; const visibilityIconInfo = { @@ -102,6 +126,14 @@ class BoostModal extends ImmutablePureComponent {
Shift + }} />
+ {status.get('visibility') !== 'private' && !status.get('reblogged') && ( + + )}
diff --git a/app/javascript/mastodon/reducers/boosts.js b/app/javascript/mastodon/reducers/boosts.js new file mode 100644 index 000000000..d0d825057 --- /dev/null +++ b/app/javascript/mastodon/reducers/boosts.js @@ -0,0 +1,25 @@ +import Immutable from 'immutable'; + +import { + BOOSTS_INIT_MODAL, + BOOSTS_CHANGE_PRIVACY, +} from 'mastodon/actions/boosts'; + +const initialState = Immutable.Map({ + new: Immutable.Map({ + privacy: 'public', + }), +}); + +export default function mutes(state = initialState, action) { + switch (action.type) { + case BOOSTS_INIT_MODAL: + return state.withMutations((state) => { + state.setIn(['new', 'privacy'], action.privacy); + }); + case BOOSTS_CHANGE_PRIVACY: + return state.setIn(['new', 'privacy'], action.privacy); + default: + return state; + } +} diff --git a/app/javascript/mastodon/reducers/index.js b/app/javascript/mastodon/reducers/index.js index a8fb69c27..3b3c5ae29 100644 --- a/app/javascript/mastodon/reducers/index.js +++ b/app/javascript/mastodon/reducers/index.js @@ -16,6 +16,7 @@ import push_notifications from './push_notifications'; import status_lists from './status_lists'; import mutes from './mutes'; import blocks from './blocks'; +import boosts from './boosts'; import reports from './reports'; import contexts from './contexts'; import compose from './compose'; @@ -57,6 +58,7 @@ const reducers = { push_notifications, mutes, blocks, + boosts, reports, contexts, compose, diff --git a/app/javascript/styles/mastodon/components.scss b/app/javascript/styles/mastodon/components.scss index 43b340723..bdb7ce768 100644 --- a/app/javascript/styles/mastodon/components.scss +++ b/app/javascript/styles/mastodon/components.scss @@ -4209,6 +4209,7 @@ a.status-card.compact:hover { border-radius: 4px; margin-left: 40px; overflow: hidden; + z-index: 2; &.top { transform-origin: 50% 100%; @@ -4219,6 +4220,15 @@ a.status-card.compact:hover { } } +.modal-root__container .privacy-dropdown { + flex-grow: 0; +} + +.modal-root__container .privacy-dropdown__dropdown { + pointer-events: auto; + z-index: 9999; +} + .privacy-dropdown__option { color: $inverted-text-color; padding: 10px; -- cgit From f5fefdc11aee24626d78480766fda878911f58b7 Mon Sep 17 00:00:00 2001 From: Mélanie Chauvel Date: Thu, 11 Feb 2021 01:05:04 +0100 Subject: Slightly reorder three dots menu on toots to make it more intuitive (#15647) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Slightly reorder three dots menu on toots to make it more intuitive - Make “Pin to profile” always appear at the same place - Add separator to group “Bookmark” and “Pin to profile” - Fix separator being the first item in some cases * Fix missing semicolon and keep status_action_bar.js and action_bar.js in sync --- .../mastodon/components/status_action_bar.js | 18 +++++++++++------- .../mastodon/features/status/components/action_bar.js | 7 ++++--- 2 files changed, 15 insertions(+), 10 deletions(-) (limited to 'app') diff --git a/app/javascript/mastodon/components/status_action_bar.js b/app/javascript/mastodon/components/status_action_bar.js index 66b5a17ac..9981f2449 100644 --- a/app/javascript/mastodon/components/status_action_bar.js +++ b/app/javascript/mastodon/components/status_action_bar.js @@ -223,10 +223,11 @@ class StatusActionBar extends ImmutablePureComponent { render () { const { status, relationship, intl, withDismiss, scrollKey } = this.props; - const mutingConversation = status.get('muted'); const anonymousAccess = !me; const publicStatus = ['public', 'unlisted'].includes(status.get('visibility')); + const mutingConversation = status.get('muted'); const account = status.get('account'); + const writtenByMe = status.getIn(['account', 'id']) === me; let menu = []; @@ -237,19 +238,22 @@ class StatusActionBar extends ImmutablePureComponent { menu.push({ text: intl.formatMessage(messages.embed), action: this.handleEmbed }); } + menu.push(null); + menu.push({ text: intl.formatMessage(status.get('bookmarked') ? messages.removeBookmark : messages.bookmark), action: this.handleBookmarkClick }); + + if (writtenByMe && publicStatus) { + menu.push({ text: intl.formatMessage(status.get('pinned') ? messages.unpin : messages.pin), action: this.handlePinClick }); + } + menu.push(null); - if (status.getIn(['account', 'id']) === me || withDismiss) { + if (writtenByMe || withDismiss) { menu.push({ text: intl.formatMessage(mutingConversation ? messages.unmuteConversation : messages.muteConversation), action: this.handleConversationMuteClick }); menu.push(null); } - if (status.getIn(['account', 'id']) === me) { - if (publicStatus) { - menu.push({ text: intl.formatMessage(status.get('pinned') ? messages.unpin : messages.pin), action: this.handlePinClick }); - } - + if (writtenByMe) { menu.push({ text: intl.formatMessage(messages.delete), action: this.handleDeleteClick }); menu.push({ text: intl.formatMessage(messages.redraft), action: this.handleRedraftClick }); } else { diff --git a/app/javascript/mastodon/features/status/components/action_bar.js b/app/javascript/mastodon/features/status/components/action_bar.js index d7d504bc5..ffa2510c0 100644 --- a/app/javascript/mastodon/features/status/components/action_bar.js +++ b/app/javascript/mastodon/features/status/components/action_bar.js @@ -187,9 +187,10 @@ class ActionBar extends React.PureComponent { render () { const { status, relationship, intl } = this.props; - const publicStatus = ['public', 'unlisted'].includes(status.get('visibility')); + const publicStatus = ['public', 'unlisted'].includes(status.get('visibility')); const mutingConversation = status.get('muted'); const account = status.get('account'); + const writtenByMe = status.getIn(['account', 'id']) === me; let menu = []; @@ -199,12 +200,12 @@ class ActionBar extends React.PureComponent { menu.push(null); } - if (me === status.getIn(['account', 'id'])) { + if (writtenByMe) { if (publicStatus) { menu.push({ text: intl.formatMessage(status.get('pinned') ? messages.unpin : messages.pin), action: this.handlePinClick }); + menu.push(null); } - menu.push(null); menu.push({ text: intl.formatMessage(mutingConversation ? messages.unmuteConversation : messages.muteConversation), action: this.handleConversationMuteClick }); menu.push(null); menu.push({ text: intl.formatMessage(messages.delete), action: this.handleDeleteClick }); -- cgit From be3b9f81518196f73f2b9636137732659df8cc5b Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 11 Feb 2021 01:53:44 +0100 Subject: Fix URI of repeat follow requests not being recorded (#15662) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix URI of repeat follow requests not being recorded In case we receive a “repeat” or “duplicate” follow request, we automatically fast-forward the accept with the latest received Activity `id`, but we don't record it. In general, a “repeat” or “duplicate” follow request may happen if for some reason (e.g. inconsistent handling of Block or Undo Accept activities, an instance being brought back up from the dead, etc.) the local instance thought the remote actor were following them while the remote actor thought otherwise. In those cases, the remote instance does not know about the older Follow activity `id`, so keeping that record serves no purpose, but knowing the most recent one is useful if the remote implementation at some point refers to it by `id` without inlining it. * Add tests --- app/lib/activitypub/activity/follow.rb | 13 +- spec/lib/activitypub/activity/follow_spec.rb | 171 ++++++++++++++++++++++----- 2 files changed, 151 insertions(+), 33 deletions(-) (limited to 'app') diff --git a/app/lib/activitypub/activity/follow.rb b/app/lib/activitypub/activity/follow.rb index 0beec68ab..4efb84b8c 100644 --- a/app/lib/activitypub/activity/follow.rb +++ b/app/lib/activitypub/activity/follow.rb @@ -6,7 +6,14 @@ class ActivityPub::Activity::Follow < ActivityPub::Activity def perform target_account = account_from_uri(object_uri) - return if target_account.nil? || !target_account.local? || delete_arrived_first?(@json['id']) || @account.requested?(target_account) + return if target_account.nil? || !target_account.local? || delete_arrived_first?(@json['id']) + + # Update id of already-existing follow requests + existing_follow_request = ::FollowRequest.find_by(account: @account, target_account: target_account) + unless existing_follow_request.nil? + existing_follow_request.update!(uri: @json['id']) + return + end if target_account.blocking?(@account) || target_account.domain_blocking?(@account.domain) || target_account.moved? || target_account.instance_actor? reject_follow_request!(target_account) @@ -14,7 +21,9 @@ class ActivityPub::Activity::Follow < ActivityPub::Activity end # Fast-forward repeat follow requests - if @account.following?(target_account) + existing_follow = ::Follow.find_by(account: @account, target_account: target_account) + unless existing_follow.nil? + existing_follow.update!(uri: @json['id']) AuthorizeFollowService.new.call(@account, target_account, skip_follow_request: true, follow_request_uri: @json['id']) return end diff --git a/spec/lib/activitypub/activity/follow_spec.rb b/spec/lib/activitypub/activity/follow_spec.rb index 05112cc18..fd4ede82b 100644 --- a/spec/lib/activitypub/activity/follow_spec.rb +++ b/spec/lib/activitypub/activity/follow_spec.rb @@ -17,62 +17,171 @@ RSpec.describe ActivityPub::Activity::Follow do describe '#perform' do subject { described_class.new(json, sender) } - context 'unlocked account' do - before do - subject.perform + context 'with no prior follow' do + context 'unlocked account' do + before do + subject.perform + end + + it 'creates a follow from sender to recipient' do + expect(sender.following?(recipient)).to be true + expect(sender.active_relationships.find_by(target_account: recipient).uri).to eq 'foo' + end + + it 'does not create a follow request' do + expect(sender.requested?(recipient)).to be false + end end - it 'creates a follow from sender to recipient' do - expect(sender.following?(recipient)).to be true + context 'silenced account following an unlocked account' do + before do + sender.touch(:silenced_at) + subject.perform + end + + it 'does not create a follow from sender to recipient' do + expect(sender.following?(recipient)).to be false + end + + it 'creates a follow request' do + expect(sender.requested?(recipient)).to be true + expect(sender.follow_requests.find_by(target_account: recipient).uri).to eq 'foo' + end end - it 'does not create a follow request' do - expect(sender.requested?(recipient)).to be false + context 'unlocked account muting the sender' do + before do + recipient.mute!(sender) + subject.perform + end + + it 'creates a follow from sender to recipient' do + expect(sender.following?(recipient)).to be true + expect(sender.active_relationships.find_by(target_account: recipient).uri).to eq 'foo' + end + + it 'does not create a follow request' do + expect(sender.requested?(recipient)).to be false + end + end + + context 'locked account' do + before do + recipient.update(locked: true) + subject.perform + end + + it 'does not create a follow from sender to recipient' do + expect(sender.following?(recipient)).to be false + end + + it 'creates a follow request' do + expect(sender.requested?(recipient)).to be true + expect(sender.follow_requests.find_by(target_account: recipient).uri).to eq 'foo' + end end end - context 'silenced account following an unlocked account' do + context 'when a follow relationship already exists' do before do - sender.touch(:silenced_at) - subject.perform + sender.active_relationships.create!(target_account: recipient, uri: 'bar') end - it 'does not create a follow from sender to recipient' do - expect(sender.following?(recipient)).to be false - end + context 'unlocked account' do + before do + subject.perform + end + + it 'correctly sets the new URI' do + expect(sender.active_relationships.find_by(target_account: recipient).uri).to eq 'foo' + end - it 'creates a follow request' do - expect(sender.requested?(recipient)).to be true + it 'does not create a follow request' do + expect(sender.requested?(recipient)).to be false + end end - end - context 'unlocked account muting the sender' do - before do - recipient.mute!(sender) - subject.perform + context 'silenced account following an unlocked account' do + before do + sender.touch(:silenced_at) + subject.perform + end + + it 'correctly sets the new URI' do + expect(sender.active_relationships.find_by(target_account: recipient).uri).to eq 'foo' + end + + it 'does not create a follow request' do + expect(sender.requested?(recipient)).to be false + end end - it 'creates a follow from sender to recipient' do - expect(sender.following?(recipient)).to be true + context 'unlocked account muting the sender' do + before do + recipient.mute!(sender) + subject.perform + end + + it 'correctly sets the new URI' do + expect(sender.active_relationships.find_by(target_account: recipient).uri).to eq 'foo' + end + + it 'does not create a follow request' do + expect(sender.requested?(recipient)).to be false + end end - it 'does not create a follow request' do - expect(sender.requested?(recipient)).to be false + context 'locked account' do + before do + recipient.update(locked: true) + subject.perform + end + + it 'correctly sets the new URI' do + expect(sender.active_relationships.find_by(target_account: recipient).uri).to eq 'foo' + end + + it 'does not create a follow request' do + expect(sender.requested?(recipient)).to be false + end end end - context 'locked account' do + context 'when a follow request already exists' do before do - recipient.update(locked: true) - subject.perform + sender.follow_requests.create!(target_account: recipient, uri: 'bar') end - it 'does not create a follow from sender to recipient' do - expect(sender.following?(recipient)).to be false + context 'silenced account following an unlocked account' do + before do + sender.touch(:silenced_at) + subject.perform + end + + it 'does not create a follow from sender to recipient' do + expect(sender.following?(recipient)).to be false + end + + it 'correctly sets the new URI' do + expect(sender.requested?(recipient)).to be true + expect(sender.follow_requests.find_by(target_account: recipient).uri).to eq 'foo' + end end - it 'creates a follow request' do - expect(sender.requested?(recipient)).to be true + context 'locked account' do + before do + recipient.update(locked: true) + subject.perform + end + + it 'does not create a follow from sender to recipient' do + expect(sender.following?(recipient)).to be false + end + + it 'correctly sets the new URI' do + expect(sender.requested?(recipient)).to be true + expect(sender.follow_requests.find_by(target_account: recipient).uri).to eq 'foo' + end end end end -- cgit From d499bb031f0d20a5f27facfd57cf4e00f89003d7 Mon Sep 17 00:00:00 2001 From: Jeong Arm Date: Thu, 11 Feb 2021 10:18:56 +0900 Subject: Use custom mascot on static share page (#15687) * Use custom mascot on static share page * Use full_asset_url --- app/helpers/mascot_helper.rb | 13 +++++++++++++ app/javascript/styles/mastodon/modal.scss | 13 +++++++++++-- app/views/layouts/modal.html.haml | 1 + 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 app/helpers/mascot_helper.rb (limited to 'app') diff --git a/app/helpers/mascot_helper.rb b/app/helpers/mascot_helper.rb new file mode 100644 index 000000000..0124c74f1 --- /dev/null +++ b/app/helpers/mascot_helper.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module MascotHelper + def mascot_url + full_asset_url(instance_presenter.mascot&.file&.url || asset_pack_path('media/images/elephant_ui_plane.svg')) + end + + private + + def instance_presenter + @instance_presenter ||= InstancePresenter.new + end +end diff --git a/app/javascript/styles/mastodon/modal.scss b/app/javascript/styles/mastodon/modal.scss index 962ed1ef5..6c6de4206 100644 --- a/app/javascript/styles/mastodon/modal.scss +++ b/app/javascript/styles/mastodon/modal.scss @@ -12,10 +12,19 @@ flex-direction: column; justify-content: flex-end; - > * { + > div { flex: 1; max-height: 235px; - background: url('../images/elephant_ui_plane.svg') no-repeat left bottom / contain; + position: relative; + + img { + max-height: 100%; + max-width: 100%; + height: 100%; + position: absolute; + bottom: 0; + left: 0; + } } } diff --git a/app/views/layouts/modal.html.haml b/app/views/layouts/modal.html.haml index e74e2c0e3..a2cd1193f 100644 --- a/app/views/layouts/modal.html.haml +++ b/app/views/layouts/modal.html.haml @@ -14,5 +14,6 @@ .container-alt= yield .modal-layout__mastodon %div + %img{alt:'', draggable:'false', src:"#{mascot_url}"} = render template: 'layouts/application' -- cgit From e79f8dd85cb63125185fdf711f470c298a0b5dbc Mon Sep 17 00:00:00 2001 From: Cecylia Bocovich Date: Wed, 10 Feb 2021 22:40:13 -0500 Subject: Onion service related changes to HTTPS handling (#15560) * Enable secure cookie flag for https only * Disable force_ssl for .onion hosts only Co-authored-by: Aiden McClelland --- Gemfile | 2 ++ Gemfile.lock | 4 ++++ app/controllers/application_controller.rb | 2 +- app/lib/webfinger.rb | 12 ++++++++++-- config/initializers/devise.rb | 6 ------ config/initializers/makara.rb | 1 - config/initializers/secureheaders.rb | 10 ++++++++++ config/initializers/session_store.rb | 1 - 8 files changed, 27 insertions(+), 11 deletions(-) create mode 100644 config/initializers/secureheaders.rb (limited to 'app') diff --git a/Gemfile b/Gemfile index 78cb44168..8d8542f83 100644 --- a/Gemfile +++ b/Gemfile @@ -161,3 +161,5 @@ gem 'connection_pool', require: false gem 'xorcist', '~> 1.1' gem 'pluck_each', '~> 0.1.3' + +gem 'secure_headers', '~> 3.5' diff --git a/Gemfile.lock b/Gemfile.lock index bd32f72a7..4237d6bba 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -571,6 +571,8 @@ GEM scenic (1.5.4) activerecord (>= 4.0.0) railties (>= 4.0.0) + secure_headers (3.9.0) + useragent securecompare (1.0.0) semantic_range (2.3.0) sidekiq (6.1.3) @@ -652,6 +654,7 @@ GEM unf_ext (0.0.7.7) unicode-display_width (1.7.0) uniform_notifier (1.13.2) + useragent (0.16.10) warden (1.2.9) rack (>= 2.0.9) webauthn (3.0.0.alpha1) @@ -795,6 +798,7 @@ DEPENDENCIES ruby-progressbar (~> 1.11) sanitize (~> 5.2) scenic (~> 1.5) + secure_headers (~> 3.5) sidekiq (~> 6.1) sidekiq-bulk (~> 0.2.0) sidekiq-scheduler (~> 3.0) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 44616d6e5..c9311c1b6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -43,7 +43,7 @@ class ApplicationController < ActionController::Base private def https_enabled? - Rails.env.production? && !request.path.start_with?('/health') + Rails.env.production? && !request.path.start_with?('/health') && !request.headers["Host"].ends_with?(".onion") end def authorized_fetch_mode? diff --git a/app/lib/webfinger.rb b/app/lib/webfinger.rb index 702365939..40795a7aa 100644 --- a/app/lib/webfinger.rb +++ b/app/lib/webfinger.rb @@ -88,10 +88,18 @@ class Webfinger end def standard_url - "https://#{@domain}/.well-known/webfinger?resource=#{@uri}" + if @domain.ends_with? ".onion" + "http://#{@domain}/.well-known/webfinger?resource=#{@uri}" + else + "https://#{@domain}/.well-known/webfinger?resource=#{@uri}" + end end def host_meta_url - "https://#{@domain}/.well-known/host-meta" + if @domain.ends_with? ".onion" + "http://#{@domain}/.well-known/host-meta" + else + "https://#{@domain}/.well-known/host-meta" + end end end diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index ef612e177..d3757b0d3 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -9,7 +9,6 @@ Warden::Manager.after_set_user except: :fetch do |user, warden| value: session_id, expires: 1.year.from_now, httponly: true, - secure: (Rails.env.production? || ENV['LOCAL_HTTPS'] == 'true'), same_site: :lax, } end @@ -20,7 +19,6 @@ Warden::Manager.after_fetch do |user, warden| value: warden.cookies.signed['_session_id'] || warden.raw_session['auth_id'], expires: 1.year.from_now, httponly: true, - secure: (Rails.env.production? || ENV['LOCAL_HTTPS'] == 'true'), same_site: :lax, } else @@ -229,10 +227,6 @@ Devise.setup do |config| # If true, extends the user's remember period when remembered via cookie. # config.extend_remember_period = false - # Options to be passed to the created cookie. For instance, you can set - # secure: true in order to force SSL only cookies. - config.rememberable_options = { secure: true } - # ==> Configuration for :validatable # Range for password length. config.password_length = 8..72 diff --git a/config/initializers/makara.rb b/config/initializers/makara.rb index dc88fa63c..afd29eda8 100644 --- a/config/initializers/makara.rb +++ b/config/initializers/makara.rb @@ -1,2 +1 @@ Makara::Cookie::DEFAULT_OPTIONS[:same_site] = :lax -Makara::Cookie::DEFAULT_OPTIONS[:secure] = Rails.env.production? || ENV['LOCAL_HTTPS'] == 'true' diff --git a/config/initializers/secureheaders.rb b/config/initializers/secureheaders.rb new file mode 100644 index 000000000..6c8ac7fbe --- /dev/null +++ b/config/initializers/secureheaders.rb @@ -0,0 +1,10 @@ +SecureHeaders::Configuration.default do |config| + config.cookies = { + secure: true, + httponly: true, + samesite: { + lax: true + } + } + config.csp = SecureHeaders::OPT_OUT +end diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index e5d1be4c6..7e3471ac4 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -2,6 +2,5 @@ Rails.application.config.session_store :cookie_store, { key: '_mastodon_session', - secure: (Rails.env.production? || ENV['LOCAL_HTTPS'] == 'true'), same_site: :lax, } -- cgit From 7927959d8fcef4fed17d94ae6585b5b65af686f2 Mon Sep 17 00:00:00 2001 From: Takeshi Umeda Date: Thu, 11 Feb 2021 14:22:11 +0900 Subject: fix typo (#15705) --- app/javascript/mastodon/features/compose/components/privacy_dropdown.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/javascript/mastodon/features/compose/components/privacy_dropdown.js b/app/javascript/mastodon/features/compose/components/privacy_dropdown.js index 936b14e9e..df59f46b3 100644 --- a/app/javascript/mastodon/features/compose/components/privacy_dropdown.js +++ b/app/javascript/mastodon/features/compose/components/privacy_dropdown.js @@ -157,7 +157,7 @@ class PrivacyDropdown extends React.PureComponent { onModalClose: PropTypes.func, value: PropTypes.string.isRequired, onChange: PropTypes.func.isRequired, - noDirect: PropTpes.bool, + noDirect: PropTypes.bool, container: PropTypes.func, intl: PropTypes.object.isRequired, }; -- cgit From 08ae116dc62c51988e9710b4f0cc9fdb2e9557b9 Mon Sep 17 00:00:00 2001 From: kaias1jp Date: Fri, 12 Feb 2021 03:59:47 +0900 Subject: Fixed WebUI crash when a status opened in the media modal is deleted (#15701) * Fixed picture in picture compatibility error in WebUI when status is deleted * Revert "Fixed picture in picture compatibility error in WebUI when status is deleted" This reverts commit f003b7d9d88688e9504f7dfae1545d7522fcfd98. * Close the modal display of the image when status is deleted * Fixed the case statement before the default statement * Removed unnecessary parts --- app/javascript/mastodon/reducers/modal.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'app') diff --git a/app/javascript/mastodon/reducers/modal.js b/app/javascript/mastodon/reducers/modal.js index a30da2db1..cb53887c7 100644 --- a/app/javascript/mastodon/reducers/modal.js +++ b/app/javascript/mastodon/reducers/modal.js @@ -1,4 +1,5 @@ import { MODAL_OPEN, MODAL_CLOSE } from '../actions/modal'; +import { TIMELINE_DELETE } from '../actions/timelines'; const initialState = { modalType: null, @@ -11,6 +12,8 @@ export default function modal(state = initialState, action) { return { modalType: action.modalType, modalProps: action.modalProps }; case MODAL_CLOSE: return (action.modalType === undefined || action.modalType === state.modalType) ? initialState : state; + case TIMELINE_DELETE: + return (state.modalProps.statusId === action.id) ? initialState : state; default: return state; } -- cgit From f8972d45032dce3f026a57cc3bdcafe4c0ab89d9 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 12 Feb 2021 05:45:38 +0100 Subject: Fix YouTube embeds failing due to YouTube serving wrong OEmbed URLs (#15716) --- app/services/fetch_oembed_service.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/services/fetch_oembed_service.rb b/app/services/fetch_oembed_service.rb index 67e33875c..60be9b9dc 100644 --- a/app/services/fetch_oembed_service.rb +++ b/app/services/fetch_oembed_service.rb @@ -38,7 +38,17 @@ class FetchOEmbedService return if @endpoint_url.blank? - @endpoint_url = (Addressable::URI.parse(@url) + @endpoint_url).to_s + @endpoint_url = begin + base_url = Addressable::URI.parse(@url) + + # If the OEmbed endpoint is given as http but the URL we opened + # was served over https, we can assume OEmbed will be available + # through https as well + + (base_url + @endpoint_url).tap do |absolute_url| + absolute_url.scheme = base_url.scheme if base_url.scheme == 'https' + end.to_s + end cache_endpoint! rescue Addressable::URI::InvalidURIError -- cgit From 15ced8728ff89932e3f8febf119f63c78ac9a960 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 12 Feb 2021 07:19:15 +0100 Subject: Refactor Api::Web::SettingsController (#15717) --- app/controllers/api/web/settings_controller.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'app') diff --git a/app/controllers/api/web/settings_controller.rb b/app/controllers/api/web/settings_controller.rb index 3d65e46ed..601e25e6e 100644 --- a/app/controllers/api/web/settings_controller.rb +++ b/app/controllers/api/web/settings_controller.rb @@ -2,17 +2,16 @@ class Api::Web::SettingsController < Api::Web::BaseController before_action :require_user! + before_action :set_setting def update - setting.data = params[:data] - setting.save! - + @setting.update!(data: params[:data]) render_empty end private - def setting - @_setting ||= ::Web::Setting.where(user: current_user).first_or_initialize(user: current_user) + def set_setting + @setting = ::Web::Setting.where(user: current_user).first_or_initialize(user: current_user) end end -- cgit From 28f533f37036d27d0e420cbcf24684fd5faadc17 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 9 Feb 2021 01:21:06 +0100 Subject: [Glitch] Change max. image dimensions to 1920x1080px (1080p) Port acf1842896682674d9ab4d0f87ec04c6174468fa to glitch-soc Signed-off-by: Claire --- app/javascript/flavours/glitch/util/resize_image.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/javascript/flavours/glitch/util/resize_image.js b/app/javascript/flavours/glitch/util/resize_image.js index 57fc6a6ec..fb8c3c11e 100644 --- a/app/javascript/flavours/glitch/util/resize_image.js +++ b/app/javascript/flavours/glitch/util/resize_image.js @@ -1,6 +1,6 @@ import EXIF from 'exif-js'; -const MAX_IMAGE_PIXELS = 1638400; // 1280x1280px +const MAX_IMAGE_PIXELS = 2073600; // 1920x1080px const _browser_quirks = {}; -- cgit From 0e7484209cf7633bacaed28172d718b3b5a27392 Mon Sep 17 00:00:00 2001 From: Mélanie Chauvel Date: Thu, 11 Feb 2021 01:05:04 +0100 Subject: [Glitch] Slightly reorder three dots menu on toots to make it more intuitive Port f5fefdc11aee24626d78480766fda878911f58b7 to glitch-soc Signed-off-by: Claire --- .../flavours/glitch/components/status_action_bar.js | 16 +++++++++------- .../glitch/features/status/components/action_bar.js | 7 ++++--- 2 files changed, 13 insertions(+), 10 deletions(-) (limited to 'app') diff --git a/app/javascript/flavours/glitch/components/status_action_bar.js b/app/javascript/flavours/glitch/components/status_action_bar.js index 2ccb02c62..74bfd948e 100644 --- a/app/javascript/flavours/glitch/components/status_action_bar.js +++ b/app/javascript/flavours/glitch/components/status_action_bar.js @@ -193,9 +193,10 @@ class StatusActionBar extends ImmutablePureComponent { render () { const { status, intl, withDismiss, showReplyCount, directMessage, scrollKey } = this.props; - const mutingConversation = status.get('muted'); const anonymousAccess = !me; + const mutingConversation = status.get('muted'); const publicStatus = ['public', 'unlisted'].includes(status.get('visibility')); + const writtenByMe = status.getIn(['account', 'id']) === me; let menu = []; let reblogIcon = 'retweet'; @@ -211,16 +212,17 @@ class StatusActionBar extends ImmutablePureComponent { menu.push(null); - if (status.getIn(['account', 'id']) === me || withDismiss) { - menu.push({ text: intl.formatMessage(mutingConversation ? messages.unmuteConversation : messages.muteConversation), action: this.handleConversationMuteClick }); + if (writtenByMe && publicStatus) { + menu.push({ text: intl.formatMessage(status.get('pinned') ? messages.unpin : messages.pin), action: this.handlePinClick }); menu.push(null); } - if (status.getIn(['account', 'id']) === me) { - if (publicStatus) { - menu.push({ text: intl.formatMessage(status.get('pinned') ? messages.unpin : messages.pin), action: this.handlePinClick }); - } + if (writtenByMe || withDismiss) { + menu.push({ text: intl.formatMessage(mutingConversation ? messages.unmuteConversation : messages.muteConversation), action: this.handleConversationMuteClick }); + menu.push(null); + } + if (writtenByMe) { menu.push({ text: intl.formatMessage(messages.delete), action: this.handleDeleteClick }); menu.push({ text: intl.formatMessage(messages.redraft), action: this.handleRedraftClick }); } else { diff --git a/app/javascript/flavours/glitch/features/status/components/action_bar.js b/app/javascript/flavours/glitch/features/status/components/action_bar.js index 0f16d93fe..6ed5f3865 100644 --- a/app/javascript/flavours/glitch/features/status/components/action_bar.js +++ b/app/javascript/flavours/glitch/features/status/components/action_bar.js @@ -145,8 +145,9 @@ class ActionBar extends React.PureComponent { render () { const { status, intl } = this.props; - const publicStatus = ['public', 'unlisted'].includes(status.get('visibility')); + const publicStatus = ['public', 'unlisted'].includes(status.get('visibility')); const mutingConversation = status.get('muted'); + const writtenByMe = status.getIn(['account', 'id']) === me; let menu = []; @@ -156,12 +157,12 @@ class ActionBar extends React.PureComponent { menu.push(null); } - if (me === status.getIn(['account', 'id'])) { + if (writtenByMe) { if (publicStatus) { menu.push({ text: intl.formatMessage(status.get('pinned') ? messages.unpin : messages.pin), action: this.handlePinClick }); + menu.push(null); } - menu.push(null); menu.push({ text: intl.formatMessage(mutingConversation ? messages.unmuteConversation : messages.muteConversation), action: this.handleConversationMuteClick }); menu.push(null); menu.push({ text: intl.formatMessage(messages.delete), action: this.handleDeleteClick }); -- cgit From 8f24f7626a46a48004ac15f2253efa30d4540e3a Mon Sep 17 00:00:00 2001 From: Jeong Arm Date: Thu, 11 Feb 2021 10:18:56 +0900 Subject: [Glitch] Use custom mascot on static share page Port d499bb031f0d20a5f27facfd57cf4e00f89003d7 to glitch-soc Signed-off-by: Claire --- app/javascript/flavours/glitch/styles/modal.scss | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/javascript/flavours/glitch/styles/modal.scss b/app/javascript/flavours/glitch/styles/modal.scss index 10de454c6..6c6de4206 100644 --- a/app/javascript/flavours/glitch/styles/modal.scss +++ b/app/javascript/flavours/glitch/styles/modal.scss @@ -12,10 +12,19 @@ flex-direction: column; justify-content: flex-end; - > * { + > div { flex: 1; max-height: 235px; - background: url('~images/elephant_ui_plane.svg') no-repeat left bottom / contain; + position: relative; + + img { + max-height: 100%; + max-width: 100%; + height: 100%; + position: absolute; + bottom: 0; + left: 0; + } } } -- cgit From 847779b1e48c14eb303204b1ced8617c42924d20 Mon Sep 17 00:00:00 2001 From: kaias1jp Date: Fri, 12 Feb 2021 03:59:47 +0900 Subject: [Glitch] Fixed WebUI crash when a status opened in the media modal is deleted Port 08ae116dc62c51988e9710b4f0cc9fdb2e9557b9 to glitch-soc Signed-off-by: Claire --- app/javascript/flavours/glitch/reducers/modal.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'app') diff --git a/app/javascript/flavours/glitch/reducers/modal.js b/app/javascript/flavours/glitch/reducers/modal.js index 7bd9d4b32..52b05d69b 100644 --- a/app/javascript/flavours/glitch/reducers/modal.js +++ b/app/javascript/flavours/glitch/reducers/modal.js @@ -1,4 +1,5 @@ import { MODAL_OPEN, MODAL_CLOSE } from 'flavours/glitch/actions/modal'; +import { TIMELINE_DELETE } from 'flavours/glitch/actions/timelines'; const initialState = { modalType: null, @@ -11,6 +12,8 @@ export default function modal(state = initialState, action) { return { modalType: action.modalType, modalProps: action.modalProps }; case MODAL_CLOSE: return (action.modalType === undefined || action.modalType === state.modalType) ? initialState : state; + case TIMELINE_DELETE: + return (state.modalProps.statusId === action.id) ? initialState : state; default: return state; } -- cgit From 9213b026565ff7da4c363b015c3aa46921ecdcc6 Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 12 Feb 2021 11:36:41 +0100 Subject: Refactor privacy dropdown to have an interface closer to upstream's --- .../glitch/features/compose/components/options.js | 76 +-------------- .../compose/components/privacy_dropdown.js | 108 +++++++++++++++++++++ 2 files changed, 110 insertions(+), 74 deletions(-) create mode 100644 app/javascript/flavours/glitch/features/compose/components/privacy_dropdown.js (limited to 'app') diff --git a/app/javascript/flavours/glitch/features/compose/components/options.js b/app/javascript/flavours/glitch/features/compose/components/options.js index 9e332aabd..f9212bbae 100644 --- a/app/javascript/flavours/glitch/features/compose/components/options.js +++ b/app/javascript/flavours/glitch/features/compose/components/options.js @@ -9,6 +9,7 @@ import spring from 'react-motion/lib/spring'; import IconButton from 'flavours/glitch/components/icon_button'; import TextIconButton from './text_icon_button'; import Dropdown from './dropdown'; +import PrivacyDropdown from './privacy_dropdown'; import ImmutablePureComponent from 'react-immutable-pure-component'; // Utils. @@ -25,22 +26,10 @@ const messages = defineMessages({ defaultMessage: 'Attach...', id: 'compose.attach', }, - change_privacy: { - defaultMessage: 'Adjust status privacy', - id: 'privacy.change', - }, content_type: { defaultMessage: 'Content type', id: 'content-type.change', }, - direct_long: { - defaultMessage: 'Visible for mentioned users only', - id: 'privacy.direct.long', - }, - direct_short: { - defaultMessage: 'Direct', - id: 'privacy.direct.short', - }, doodle: { defaultMessage: 'Draw something', id: 'compose.attach.doodle', @@ -65,22 +54,6 @@ const messages = defineMessages({ defaultMessage: 'Plain text', id: 'compose.content-type.plain', }, - private_long: { - defaultMessage: 'Visible for followers only', - id: 'privacy.private.long', - }, - private_short: { - defaultMessage: 'Followers-only', - id: 'privacy.private.short', - }, - public_long: { - defaultMessage: 'Visible for all, shown in public timelines', - id: 'privacy.public.long', - }, - public_short: { - defaultMessage: 'Public', - id: 'privacy.public.short', - }, spoiler: { defaultMessage: 'Hide text behind warning', id: 'compose_form.spoiler', @@ -93,14 +66,6 @@ const messages = defineMessages({ defaultMessage: 'Threaded mode', id: 'advanced_options.threaded_mode.short', }, - unlisted_long: { - defaultMessage: 'Visible for all, but not in public timelines', - id: 'privacy.unlisted.long', - }, - unlisted_short: { - defaultMessage: 'Unlisted', - id: 'privacy.unlisted.short', - }, upload: { defaultMessage: 'Upload a file', id: 'compose.attach.upload', @@ -201,35 +166,6 @@ class ComposerOptions extends ImmutablePureComponent { showContentTypeChoice, } = this.props; - // We predefine our privacy items so that we can easily pick the - // dropdown icon later. - const privacyItems = { - direct: { - icon: 'envelope', - meta: , - name: 'direct', - text: , - }, - private: { - icon: 'lock', - meta: , - name: 'private', - text: , - }, - public: { - icon: 'globe', - meta: , - name: 'public', - text: , - }, - unlisted: { - icon: 'unlock', - meta: , - name: 'unlisted', - text: , - }, - }; - const contentTypeItems = { plain: { icon: 'file-text', @@ -297,19 +233,11 @@ class ComposerOptions extends ImmutablePureComponent { /> )}
- {showContentTypeChoice && ( diff --git a/app/javascript/flavours/glitch/features/compose/components/privacy_dropdown.js b/app/javascript/flavours/glitch/features/compose/components/privacy_dropdown.js new file mode 100644 index 000000000..ec8d1378e --- /dev/null +++ b/app/javascript/flavours/glitch/features/compose/components/privacy_dropdown.js @@ -0,0 +1,108 @@ +import PropTypes from 'prop-types'; +import React from 'react'; +import ImmutablePropTypes from 'react-immutable-proptypes'; +import { FormattedMessage, defineMessages, injectIntl } from 'react-intl'; +import Dropdown from './dropdown'; + +const messages = defineMessages({ + change_privacy: { + defaultMessage: 'Adjust status privacy', + id: 'privacy.change', + }, + direct_long: { + defaultMessage: 'Visible for mentioned users only', + id: 'privacy.direct.long', + }, + direct_short: { + defaultMessage: 'Direct', + id: 'privacy.direct.short', + }, + private_long: { + defaultMessage: 'Visible for followers only', + id: 'privacy.private.long', + }, + private_short: { + defaultMessage: 'Followers-only', + id: 'privacy.private.short', + }, + public_long: { + defaultMessage: 'Visible for all, shown in public timelines', + id: 'privacy.public.long', + }, + public_short: { + defaultMessage: 'Public', + id: 'privacy.public.short', + }, + unlisted_long: { + defaultMessage: 'Visible for all, but not in public timelines', + id: 'privacy.unlisted.long', + }, + unlisted_short: { + defaultMessage: 'Unlisted', + id: 'privacy.unlisted.short', + }, +}); + +export default @injectIntl +class PrivacyDropdown extends React.PureComponent { + + static propTypes = { + isUserTouching: PropTypes.func, + onModalOpen: PropTypes.func, + onModalClose: PropTypes.func, + value: PropTypes.string.isRequired, + onChange: PropTypes.func.isRequired, + noDirect: PropTypes.bool, + container: PropTypes.func, + intl: PropTypes.object.isRequired, + }; + + render () { + const { value, onChange, onModalOpen, onModalClose, disabled, intl } = this.props; + + // We predefine our privacy items so that we can easily pick the + // dropdown icon later. + const privacyItems = { + direct: { + icon: 'envelope', + meta: , + name: 'direct', + text: , + }, + private: { + icon: 'lock', + meta: , + name: 'private', + text: , + }, + public: { + icon: 'globe', + meta: , + name: 'public', + text: , + }, + unlisted: { + icon: 'unlock', + meta: , + name: 'unlisted', + text: , + }, + }; + + const items = [privacyItems.public, privacyItems.unlisted, privacyItems.private, privacyItems.direct]; + + return ( + + ); + } + +} -- cgit From 49eef466b8274ca5768deca3309af31bfbf81184 Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 11 Feb 2021 00:53:12 +0100 Subject: [Glitch] Add dropdown for boost privacy in boost confirmation modal Port 07b46cb332ae197584e3ed3f23fe814b7793ec4c to glitch-soc Signed-off-by: Claire --- app/javascript/flavours/glitch/actions/boosts.js | 29 +++++++++++++++++ .../flavours/glitch/actions/interactions.js | 4 +-- .../flavours/glitch/components/dropdown_menu.js | 1 - .../glitch/containers/dropdown_menu_container.js | 1 - .../flavours/glitch/containers/status_container.js | 9 +++--- .../glitch/features/compose/components/dropdown.js | 8 +++-- .../compose/components/privacy_dropdown.js | 11 +++++-- .../picture_in_picture/components/footer.js | 7 ++-- .../status/containers/detailed_status_container.js | 7 ++-- .../flavours/glitch/features/status/index.js | 9 +++--- .../glitch/features/ui/components/boost_modal.js | 37 ++++++++++++++++++++-- app/javascript/flavours/glitch/reducers/boosts.js | 25 +++++++++++++++ app/javascript/flavours/glitch/reducers/index.js | 2 ++ .../flavours/glitch/styles/components/modal.scss | 9 ++++++ 14 files changed, 134 insertions(+), 25 deletions(-) create mode 100644 app/javascript/flavours/glitch/actions/boosts.js create mode 100644 app/javascript/flavours/glitch/reducers/boosts.js (limited to 'app') diff --git a/app/javascript/flavours/glitch/actions/boosts.js b/app/javascript/flavours/glitch/actions/boosts.js new file mode 100644 index 000000000..6e14065d6 --- /dev/null +++ b/app/javascript/flavours/glitch/actions/boosts.js @@ -0,0 +1,29 @@ +import { openModal } from './modal'; + +export const BOOSTS_INIT_MODAL = 'BOOSTS_INIT_MODAL'; +export const BOOSTS_CHANGE_PRIVACY = 'BOOSTS_CHANGE_PRIVACY'; + +export function initBoostModal(props) { + return (dispatch, getState) => { + const default_privacy = getState().getIn(['compose', 'default_privacy']); + + const privacy = props.status.get('visibility') === 'private' ? 'private' : default_privacy; + + dispatch({ + type: BOOSTS_INIT_MODAL, + privacy + }); + + dispatch(openModal('BOOST', props)); + }; +} + + +export function changeBoostPrivacy(privacy) { + return dispatch => { + dispatch({ + type: BOOSTS_CHANGE_PRIVACY, + privacy, + }); + }; +} diff --git a/app/javascript/flavours/glitch/actions/interactions.js b/app/javascript/flavours/glitch/actions/interactions.js index 4407f8b6e..336c8fa90 100644 --- a/app/javascript/flavours/glitch/actions/interactions.js +++ b/app/javascript/flavours/glitch/actions/interactions.js @@ -41,11 +41,11 @@ export const UNBOOKMARK_REQUEST = 'UNBOOKMARKED_REQUEST'; export const UNBOOKMARK_SUCCESS = 'UNBOOKMARKED_SUCCESS'; export const UNBOOKMARK_FAIL = 'UNBOOKMARKED_FAIL'; -export function reblog(status) { +export function reblog(status, visibility) { return function (dispatch, getState) { dispatch(reblogRequest(status)); - api(getState).post(`/api/v1/statuses/${status.get('id')}/reblog`).then(function (response) { + api(getState).post(`/api/v1/statuses/${status.get('id')}/reblog`, { visibility }).then(function (response) { // The reblog API method returns a new status wrapped around the original. In this case we are only // interested in how the original is modified, hence passing it skipping the wrapper dispatch(importFetchedStatus(response.data.reblog)); diff --git a/app/javascript/flavours/glitch/components/dropdown_menu.js b/app/javascript/flavours/glitch/components/dropdown_menu.js index d1aba691c..023fecb9a 100644 --- a/app/javascript/flavours/glitch/components/dropdown_menu.js +++ b/app/javascript/flavours/glitch/components/dropdown_menu.js @@ -177,7 +177,6 @@ export default class Dropdown extends React.PureComponent { disabled: PropTypes.bool, status: ImmutablePropTypes.map, isUserTouching: PropTypes.func, - isModalOpen: PropTypes.bool.isRequired, onOpen: PropTypes.func.isRequired, onClose: PropTypes.func.isRequired, dropdownPlacement: PropTypes.string, diff --git a/app/javascript/flavours/glitch/containers/dropdown_menu_container.js b/app/javascript/flavours/glitch/containers/dropdown_menu_container.js index e60ee814d..1c0385b74 100644 --- a/app/javascript/flavours/glitch/containers/dropdown_menu_container.js +++ b/app/javascript/flavours/glitch/containers/dropdown_menu_container.js @@ -5,7 +5,6 @@ import DropdownMenu from 'flavours/glitch/components/dropdown_menu'; import { isUserTouching } from 'flavours/glitch/util/is_mobile'; const mapStateToProps = state => ({ - isModalOpen: state.get('modal').modalType === 'ACTIONS', dropdownPlacement: state.getIn(['dropdown_menu', 'placement']), openDropdownId: state.getIn(['dropdown_menu', 'openId']), openedViaKeyboard: state.getIn(['dropdown_menu', 'keyboard']), diff --git a/app/javascript/flavours/glitch/containers/status_container.js b/app/javascript/flavours/glitch/containers/status_container.js index 7782246a6..6461bf805 100644 --- a/app/javascript/flavours/glitch/containers/status_container.js +++ b/app/javascript/flavours/glitch/containers/status_container.js @@ -21,6 +21,7 @@ import { muteStatus, unmuteStatus, deleteStatus } from 'flavours/glitch/actions/ import { initMuteModal } from 'flavours/glitch/actions/mutes'; import { initBlockModal } from 'flavours/glitch/actions/blocks'; import { initReport } from 'flavours/glitch/actions/reports'; +import { initBoostModal } from 'flavours/glitch/actions/boosts'; import { openModal } from 'flavours/glitch/actions/modal'; import { deployPictureInPicture } from 'flavours/glitch/actions/picture_in_picture'; import { changeLocalSetting } from 'flavours/glitch/actions/local_settings'; @@ -96,11 +97,11 @@ const mapDispatchToProps = (dispatch, { intl, contextType }) => ({ }); }, - onModalReblog (status) { + onModalReblog (status, privacy) { if (status.get('reblogged')) { dispatch(unreblog(status)); } else { - dispatch(reblog(status)); + dispatch(reblog(status, privacy)); } }, @@ -108,11 +109,11 @@ const mapDispatchToProps = (dispatch, { intl, contextType }) => ({ dispatch((_, getState) => { let state = getState(); if (state.getIn(['local_settings', 'confirm_boost_missing_media_description']) && status.get('media_attachments').some(item => !item.get('description')) && !status.get('reblogged')) { - dispatch(openModal('BOOST', { status, onReblog: this.onModalReblog, missingMediaDescription: true })); + dispatch(initBoostModal({ status, onReblog: this.onModalReblog, missingMediaDescription: true })); } else if (e.shiftKey || !boostModal) { this.onModalReblog(status); } else { - dispatch(openModal('BOOST', { status, onReblog: this.onModalReblog })); + dispatch(initBoostModal({ status, onReblog: this.onModalReblog })); } }); }, diff --git a/app/javascript/flavours/glitch/features/compose/components/dropdown.js b/app/javascript/flavours/glitch/features/compose/components/dropdown.js index 04ef3964b..abf7cbba1 100644 --- a/app/javascript/flavours/glitch/features/compose/components/dropdown.js +++ b/app/javascript/flavours/glitch/features/compose/components/dropdown.js @@ -31,6 +31,8 @@ export default class ComposerOptionsDropdown extends React.PureComponent { title: PropTypes.string, value: PropTypes.string, onChange: PropTypes.func, + noModal: PropTypes.bool, + container: PropTypes.func, }; state = { @@ -42,10 +44,10 @@ export default class ComposerOptionsDropdown extends React.PureComponent { // Toggles opening and closing the dropdown. handleToggle = ({ target, type }) => { - const { onModalOpen } = this.props; + const { onModalOpen, noModal } = this.props; const { open } = this.state; - if (isUserTouching()) { + if (!noModal && isUserTouching()) { if (this.state.open) { this.props.onModalClose(); } else { @@ -183,6 +185,7 @@ export default class ComposerOptionsDropdown extends React.PureComponent { items, onChange, value, + container, } = this.props; const { open, placement } = this.state; const computedClass = classNames('composer--options--dropdown', { @@ -219,6 +222,7 @@ export default class ComposerOptionsDropdown extends React.PureComponent { placement={placement} show={open} target={this} + container={container} > ); diff --git a/app/javascript/flavours/glitch/features/picture_in_picture/components/footer.js b/app/javascript/flavours/glitch/features/picture_in_picture/components/footer.js index 2ddba140e..d8989ec61 100644 --- a/app/javascript/flavours/glitch/features/picture_in_picture/components/footer.js +++ b/app/javascript/flavours/glitch/features/picture_in_picture/components/footer.js @@ -11,6 +11,7 @@ import { replyCompose } from 'flavours/glitch/actions/compose'; import { reblog, favourite, unreblog, unfavourite } from 'flavours/glitch/actions/interactions'; import { makeGetStatus } from 'flavours/glitch/selectors'; import { openModal } from 'flavours/glitch/actions/modal'; +import { initBoostModal } from 'flavours/glitch/actions/boosts'; const messages = defineMessages({ reply: { id: 'status.reply', defaultMessage: 'Reply' }, @@ -82,9 +83,9 @@ class Footer extends ImmutablePureComponent { } }; - _performReblog = () => { + _performReblog = (privacy) => { const { dispatch, status } = this.props; - dispatch(reblog(status)); + dispatch(reblog(status, privacy)); } handleReblogClick = e => { @@ -95,7 +96,7 @@ class Footer extends ImmutablePureComponent { } else if ((e && e.shiftKey) || !boostModal) { this._performReblog(); } else { - dispatch(openModal('BOOST', { status, onReblog: this._performReblog })); + dispatch(initBoostModal({ status, onReblog: this._performReblog })); } }; diff --git a/app/javascript/flavours/glitch/features/status/containers/detailed_status_container.js b/app/javascript/flavours/glitch/features/status/containers/detailed_status_container.js index 9d11f37e0..40e186569 100644 --- a/app/javascript/flavours/glitch/features/status/containers/detailed_status_container.js +++ b/app/javascript/flavours/glitch/features/status/containers/detailed_status_container.js @@ -24,6 +24,7 @@ import { import { initMuteModal } from 'flavours/glitch/actions/mutes'; import { initBlockModal } from 'flavours/glitch/actions/blocks'; import { initReport } from 'flavours/glitch/actions/reports'; +import { initBoostModal } from 'flavours/glitch/actions/boosts'; import { openModal } from 'flavours/glitch/actions/modal'; import { defineMessages, injectIntl } from 'react-intl'; import { boostModal, deleteModal } from 'flavours/glitch/util/initial_state'; @@ -67,8 +68,8 @@ const mapDispatchToProps = (dispatch, { intl }) => ({ }); }, - onModalReblog (status) { - dispatch(reblog(status)); + onModalReblog (status, privacy) { + dispatch(reblog(status, privacy)); }, onReblog (status, e) { @@ -78,7 +79,7 @@ const mapDispatchToProps = (dispatch, { intl }) => ({ if (e.shiftKey || !boostModal) { this.onModalReblog(status); } else { - dispatch(openModal('BOOST', { status, onReblog: this.onModalReblog })); + dispatch(initBoostModal({ status, onReblog: this.onModalReblog })); } } }, diff --git a/app/javascript/flavours/glitch/features/status/index.js b/app/javascript/flavours/glitch/features/status/index.js index b330adf3f..21e441407 100644 --- a/app/javascript/flavours/glitch/features/status/index.js +++ b/app/javascript/flavours/glitch/features/status/index.js @@ -30,6 +30,7 @@ import { muteStatus, unmuteStatus, deleteStatus } from 'flavours/glitch/actions/ import { initMuteModal } from 'flavours/glitch/actions/mutes'; import { initBlockModal } from 'flavours/glitch/actions/blocks'; import { initReport } from 'flavours/glitch/actions/reports'; +import { initBoostModal } from 'flavours/glitch/actions/boosts'; import { makeGetStatus } from 'flavours/glitch/selectors'; import { ScrollContainer } from 'react-router-scroll-4'; import ColumnBackButton from 'flavours/glitch/components/column_back_button'; @@ -262,13 +263,13 @@ class Status extends ImmutablePureComponent { } } - handleModalReblog = (status) => { + handleModalReblog = (status, privacy) => { const { dispatch } = this.props; if (status.get('reblogged')) { dispatch(unreblog(status)); } else { - dispatch(reblog(status)); + dispatch(reblog(status, privacy)); } } @@ -276,11 +277,11 @@ class Status extends ImmutablePureComponent { const { settings, dispatch } = this.props; if (settings.get('confirm_boost_missing_media_description') && status.get('media_attachments').some(item => !item.get('description')) && !status.get('reblogged')) { - dispatch(openModal('BOOST', { status, onReblog: this.handleModalReblog, missingMediaDescription: true })); + dispatch(initBoostModal({ status, onReblog: this.handleModalReblog, missingMediaDescription: true })); } else if ((e && e.shiftKey) || !boostModal) { this.handleModalReblog(status); } else { - dispatch(openModal('BOOST', { status, onReblog: this.handleModalReblog })); + dispatch(initBoostModal({ status, onReblog: this.handleModalReblog })); } } diff --git a/app/javascript/flavours/glitch/features/ui/components/boost_modal.js b/app/javascript/flavours/glitch/features/ui/components/boost_modal.js index 12ad426c8..c4af25599 100644 --- a/app/javascript/flavours/glitch/features/ui/components/boost_modal.js +++ b/app/javascript/flavours/glitch/features/ui/components/boost_modal.js @@ -1,4 +1,5 @@ import React from 'react'; +import { connect } from 'react-redux'; import ImmutablePropTypes from 'react-immutable-proptypes'; import PropTypes from 'prop-types'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; @@ -10,7 +11,9 @@ import DisplayName from 'flavours/glitch/components/display_name'; import AttachmentList from 'flavours/glitch/components/attachment_list'; import Icon from 'flavours/glitch/components/icon'; import ImmutablePureComponent from 'react-immutable-pure-component'; +import PrivacyDropdown from 'flavours/glitch/features/compose/components/privacy_dropdown'; import classNames from 'classnames'; +import { changeBoostPrivacy } from 'flavours/glitch/actions/boosts'; const messages = defineMessages({ cancel_reblog: { id: 'status.cancel_reblog_private', defaultMessage: 'Unboost' }, @@ -21,7 +24,22 @@ const messages = defineMessages({ direct_short: { id: 'privacy.direct.short', defaultMessage: 'Direct' }, }); -export default @injectIntl +const mapStateToProps = state => { + return { + privacy: state.getIn(['boosts', 'new', 'privacy']), + }; +}; + +const mapDispatchToProps = dispatch => { + return { + onChangeBoostPrivacy(value) { + dispatch(changeBoostPrivacy(value)); + }, + }; +}; + +export default @connect(mapStateToProps, mapDispatchToProps) +@injectIntl class BoostModal extends ImmutablePureComponent { static contextTypes = { @@ -41,7 +59,7 @@ class BoostModal extends ImmutablePureComponent { } handleReblog = () => { - this.props.onReblog(this.props.status); + this.props.onReblog(this.props.status, this.props.privacy); this.props.onClose(); } @@ -55,12 +73,16 @@ class BoostModal extends ImmutablePureComponent { } } + _findContainer = () => { + return document.getElementsByClassName('modal-root__container')[0]; + }; + setRef = (c) => { this.button = c; } render () { - const { status, missingMediaDescription, intl } = this.props; + const { status, missingMediaDescription, privacy, intl } = this.props; const buttonText = status.get('reblogged') ? messages.cancel_reblog : messages.reblog; const visibilityIconInfo = { @@ -111,6 +133,15 @@ class BoostModal extends ImmutablePureComponent { Shift + }} /> }
+ + {status.get('visibility') !== 'private' && !status.get('reblogged') && ( + + )}
diff --git a/app/javascript/flavours/glitch/reducers/boosts.js b/app/javascript/flavours/glitch/reducers/boosts.js new file mode 100644 index 000000000..3541ca0c2 --- /dev/null +++ b/app/javascript/flavours/glitch/reducers/boosts.js @@ -0,0 +1,25 @@ +import Immutable from 'immutable'; + +import { + BOOSTS_INIT_MODAL, + BOOSTS_CHANGE_PRIVACY, +} from 'flavours/glitch/actions/boosts'; + +const initialState = Immutable.Map({ + new: Immutable.Map({ + privacy: 'public', + }), +}); + +export default function mutes(state = initialState, action) { + switch (action.type) { + case BOOSTS_INIT_MODAL: + return state.withMutations((state) => { + state.setIn(['new', 'privacy'], action.privacy); + }); + case BOOSTS_CHANGE_PRIVACY: + return state.setIn(['new', 'privacy'], action.privacy); + default: + return state; + } +} diff --git a/app/javascript/flavours/glitch/reducers/index.js b/app/javascript/flavours/glitch/reducers/index.js index b1ddb769e..c452e834c 100644 --- a/app/javascript/flavours/glitch/reducers/index.js +++ b/app/javascript/flavours/glitch/reducers/index.js @@ -18,6 +18,7 @@ import status_lists from './status_lists'; import mutes from './mutes'; import blocks from './blocks'; import reports from './reports'; +import boosts from './boosts'; import contexts from './contexts'; import compose from './compose'; import search from './search'; @@ -61,6 +62,7 @@ const reducers = { mutes, blocks, reports, + boosts, contexts, compose, search, diff --git a/app/javascript/flavours/glitch/styles/components/modal.scss b/app/javascript/flavours/glitch/styles/components/modal.scss index 16c05bc3e..0bda305a8 100644 --- a/app/javascript/flavours/glitch/styles/components/modal.scss +++ b/app/javascript/flavours/glitch/styles/components/modal.scss @@ -1031,3 +1031,12 @@ } } } + +.modal-root__container .composer--options--dropdown { + flex-grow: 0; +} + +.modal-root__container .composer--options--dropdown--content { + pointer-events: auto; + z-index: 9999; +} -- cgit