From 6f6abc369f113b174fe191cf562098fe01c2eeec Mon Sep 17 00:00:00 2001 From: Aditoo17 <42938951+Aditoo17@users.noreply.github.com> Date: Tue, 26 Mar 2019 17:33:07 +0100 Subject: [PATCH 1/3] Make clicking on avatar open public profile in new tab (#10387) --- app/javascript/mastodon/features/account/components/header.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/javascript/mastodon/features/account/components/header.js b/app/javascript/mastodon/features/account/components/header.js index 41e3945854..fd7ad5e07d 100644 --- a/app/javascript/mastodon/features/account/components/header.js +++ b/app/javascript/mastodon/features/account/components/header.js @@ -212,7 +212,7 @@ class Header extends ImmutablePureComponent {
- + From 0c46bd11aa3dd5613ba49dfeed6971dc92587956 Mon Sep 17 00:00:00 2001 From: ThibG Date: Tue, 26 Mar 2019 17:33:26 +0100 Subject: [PATCH 2/3] Fix HTML validation (#10354) * Fix HTML validation * Report first HTML error instead on validation error --- app/validators/html_validator.rb | 10 +++++++--- config/locales/en.yml | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/validators/html_validator.rb b/app/validators/html_validator.rb index 882c35d413..b7caee5a9e 100644 --- a/app/validators/html_validator.rb +++ b/app/validators/html_validator.rb @@ -3,12 +3,16 @@ class HtmlValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) return if value.blank? - record.errors.add(attribute, I18n.t('html_validator.invalid_markup')) unless valid_html?(value) + errors = html_errors(value) + unless errors.empty? + record.errors.add(attribute, I18n.t('html_validator.invalid_markup', error: errors.first.to_s)) + end end private - def valid_html?(str) - Nokogiri::HTML.fragment(str).to_s == str + def html_errors(str) + fragment = Nokogiri::HTML.fragment(str) + fragment.errors end end diff --git a/config/locales/en.yml b/config/locales/en.yml index ad1332fd2b..42ba4e35e8 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -638,7 +638,7 @@ en: one: Something isn't quite right yet! Please review the error below other: Something isn't quite right yet! Please review %{count} errors below html_validator: - invalid_markup: contains invalid HTML markup + invalid_markup: 'contains invalid HTML markup: %{error}' identity_proofs: active: Active authorize: Yes, authorize From 6df4a8296996181d56a22535b86830c0ab56086e Mon Sep 17 00:00:00 2001 From: ThibG Date: Tue, 26 Mar 2019 17:34:02 +0100 Subject: [PATCH 3/3] =?UTF-8?q?Add=20a=20=E2=80=9CBlock=20&=20Report?= =?UTF-8?q?=E2=80=9D=20button=20to=20the=20block=20confirmation=20dialog?= =?UTF-8?q?=20(#10360)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mastodon/components/status_action_bar.js | 2 +- .../mastodon/containers/status_container.js | 9 ++++++++- .../account_timeline/containers/header_container.js | 6 ++++++ .../features/status/components/action_bar.js | 2 +- .../status/containers/detailed_status_container.js | 9 ++++++++- app/javascript/mastodon/features/status/index.js | 9 ++++++++- .../features/ui/components/confirmation_modal.js | 12 +++++++++++- app/javascript/styles/mastodon/components.scss | 1 + 8 files changed, 44 insertions(+), 6 deletions(-) diff --git a/app/javascript/mastodon/components/status_action_bar.js b/app/javascript/mastodon/components/status_action_bar.js index 53d17d4180..0bfbd88794 100644 --- a/app/javascript/mastodon/components/status_action_bar.js +++ b/app/javascript/mastodon/components/status_action_bar.js @@ -139,7 +139,7 @@ class StatusActionBar extends ImmutablePureComponent { } handleBlockClick = () => { - this.props.onBlock(this.props.status.get('account')); + this.props.onBlock(this.props.status); } handleOpen = () => { diff --git a/app/javascript/mastodon/containers/status_container.js b/app/javascript/mastodon/containers/status_container.js index b3555c76e5..0fce674e20 100644 --- a/app/javascript/mastodon/containers/status_container.js +++ b/app/javascript/mastodon/containers/status_container.js @@ -38,6 +38,7 @@ const messages = defineMessages({ blockConfirm: { id: 'confirmations.block.confirm', defaultMessage: 'Block' }, replyConfirm: { id: 'confirmations.reply.confirm', defaultMessage: 'Reply' }, replyMessage: { id: 'confirmations.reply.message', defaultMessage: 'Replying now will overwrite the message you are currently composing. Are you sure you want to proceed?' }, + blockAndReport: { id: 'confirmations.block.block_and_report', defaultMessage: 'Block & Report' }, }); const makeMapStateToProps = () => { @@ -134,11 +135,17 @@ const mapDispatchToProps = (dispatch, { intl }) => ({ dispatch(openModal('VIDEO', { media, time })); }, - onBlock (account) { + onBlock (status) { + const account = status.get('account'); dispatch(openModal('CONFIRM', { message: @{account.get('acct')} }} />, confirm: intl.formatMessage(messages.blockConfirm), onConfirm: () => dispatch(blockAccount(account.get('id'))), + secondary: intl.formatMessage(messages.blockAndReport), + onSecondary: () => { + dispatch(blockAccount(account.get('id'))); + dispatch(initReport(account, status)); + }, })); }, diff --git a/app/javascript/mastodon/features/account_timeline/containers/header_container.js b/app/javascript/mastodon/features/account_timeline/containers/header_container.js index df742f9ece..a06a0b095e 100644 --- a/app/javascript/mastodon/features/account_timeline/containers/header_container.js +++ b/app/javascript/mastodon/features/account_timeline/containers/header_container.js @@ -26,6 +26,7 @@ const messages = defineMessages({ unfollowConfirm: { id: 'confirmations.unfollow.confirm', defaultMessage: 'Unfollow' }, blockConfirm: { id: 'confirmations.block.confirm', defaultMessage: 'Block' }, blockDomainConfirm: { id: 'confirmations.domain_block.confirm', defaultMessage: 'Hide entire domain' }, + blockAndReport: { id: 'confirmations.block.block_and_report', defaultMessage: 'Block & Report' }, }); const makeMapStateToProps = () => { @@ -65,6 +66,11 @@ const mapDispatchToProps = (dispatch, { intl }) => ({ message: @{account.get('acct')} }} />, confirm: intl.formatMessage(messages.blockConfirm), onConfirm: () => dispatch(blockAccount(account.get('id'))), + secondary: intl.formatMessage(messages.blockAndReport), + onSecondary: () => { + dispatch(blockAccount(account.get('id'))); + dispatch(initReport(account)); + }, })); } }, diff --git a/app/javascript/mastodon/features/status/components/action_bar.js b/app/javascript/mastodon/features/status/components/action_bar.js index 73be1fc5f8..3e511b7a64 100644 --- a/app/javascript/mastodon/features/status/components/action_bar.js +++ b/app/javascript/mastodon/features/status/components/action_bar.js @@ -92,7 +92,7 @@ class ActionBar extends React.PureComponent { } handleBlockClick = () => { - this.props.onBlock(this.props.status.get('account')); + this.props.onBlock(this.props.status); } handleReport = () => { 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 2c0db0a6b2..61e0c428a1 100644 --- a/app/javascript/mastodon/features/status/containers/detailed_status_container.js +++ b/app/javascript/mastodon/features/status/containers/detailed_status_container.js @@ -38,6 +38,7 @@ const messages = defineMessages({ blockConfirm: { id: 'confirmations.block.confirm', defaultMessage: 'Block' }, replyConfirm: { id: 'confirmations.reply.confirm', defaultMessage: 'Reply' }, replyMessage: { id: 'confirmations.reply.message', defaultMessage: 'Replying now will overwrite the message you are currently composing. Are you sure you want to proceed?' }, + blockAndReport: { id: 'confirmations.block.block_and_report', defaultMessage: 'Block & Report' }, }); const makeMapStateToProps = () => { @@ -135,11 +136,17 @@ const mapDispatchToProps = (dispatch, { intl }) => ({ dispatch(openModal('VIDEO', { media, time })); }, - onBlock (account) { + onBlock (status) { + const account = status.get('account'); dispatch(openModal('CONFIRM', { message: @{account.get('acct')} }} />, confirm: intl.formatMessage(messages.blockConfirm), onConfirm: () => dispatch(blockAccount(account.get('id'))), + secondary: intl.formatMessage(messages.blockAndReport), + onSecondary: () => { + dispatch(blockAccount(account.get('id'))); + dispatch(initReport(account, status)); + }, })); }, diff --git a/app/javascript/mastodon/features/status/index.js b/app/javascript/mastodon/features/status/index.js index 3b5febcac4..c0ea460e8b 100644 --- a/app/javascript/mastodon/features/status/index.js +++ b/app/javascript/mastodon/features/status/index.js @@ -57,6 +57,7 @@ const messages = defineMessages({ detailedStatus: { id: 'status.detailed_status', defaultMessage: 'Detailed conversation view' }, replyConfirm: { id: 'confirmations.reply.confirm', defaultMessage: 'Reply' }, replyMessage: { id: 'confirmations.reply.message', defaultMessage: 'Replying now will overwrite the message you are currently composing. Are you sure you want to proceed?' }, + blockAndReport: { id: 'confirmations.block.block_and_report', defaultMessage: 'Block & Report' }, }); const makeMapStateToProps = () => { @@ -253,13 +254,19 @@ class Status extends ImmutablePureComponent { } } - handleBlockClick = (account) => { + handleBlockClick = (status) => { const { dispatch, intl } = this.props; + const account = status.get('account'); dispatch(openModal('CONFIRM', { message: @{account.get('acct')} }} />, confirm: intl.formatMessage(messages.blockConfirm), onConfirm: () => dispatch(blockAccount(account.get('id'))), + secondary: intl.formatMessage(messages.blockAndReport), + onSecondary: () => { + dispatch(blockAccount(account.get('id'))); + dispatch(initReport(account, status)); + }, })); } diff --git a/app/javascript/mastodon/features/ui/components/confirmation_modal.js b/app/javascript/mastodon/features/ui/components/confirmation_modal.js index f0f3ad134d..1227fa453e 100644 --- a/app/javascript/mastodon/features/ui/components/confirmation_modal.js +++ b/app/javascript/mastodon/features/ui/components/confirmation_modal.js @@ -11,6 +11,8 @@ class ConfirmationModal extends React.PureComponent { confirm: PropTypes.string.isRequired, onClose: PropTypes.func.isRequired, onConfirm: PropTypes.func.isRequired, + secondary: PropTypes.string, + onSecondary: PropTypes.func, intl: PropTypes.object.isRequired, }; @@ -23,6 +25,11 @@ class ConfirmationModal extends React.PureComponent { this.props.onConfirm(); } + handleSecondary = () => { + this.props.onClose(); + this.props.onSecondary(); + } + handleCancel = () => { this.props.onClose(); } @@ -32,7 +39,7 @@ class ConfirmationModal extends React.PureComponent { } render () { - const { message, confirm } = this.props; + const { message, confirm, secondary } = this.props; return (
@@ -44,6 +51,9 @@ class ConfirmationModal extends React.PureComponent { + {secondary !== undefined && ( +
diff --git a/app/javascript/styles/mastodon/components.scss b/app/javascript/styles/mastodon/components.scss index be48378f6a..3feb623313 100644 --- a/app/javascript/styles/mastodon/components.scss +++ b/app/javascript/styles/mastodon/components.scss @@ -4128,6 +4128,7 @@ a.status-card.compact:hover { .confirmation-modal__action-bar, .mute-modal__action-bar { + .confirmation-modal__secondary-button, .confirmation-modal__cancel-button, .mute-modal__cancel-button { background-color: transparent;