Remove fancy block info popups (move to MobileFrontend)

We only used them for registered users, but MobileFrontend's
EditorOverlay code can use them for anonymous users as well.

Remove code for looking up block details in wgMinervaUserBlockInfo,
now we only care whether the user is blocked at all to display a
different icon. MobileFrontend looks up the same information via API
already.

Remove unused message 'mobile-frontend-editor-blocked-info-loggedin',
it was only used by non-fancy popups, which were removed in favor of
the new ones in f51cf7db7b.

Bug: T193754
Bug: T198765
Depends-On: I80564c3e6e2d0f4d7eae754f206780fb4054f254
Change-Id: I64be24845b4fee76d6b4a8e481a218f2160fced6
This commit is contained in:
Bartosz Dziewoński 2018-07-10 04:45:15 +02:00
parent 28b9517dcb
commit f114f81d42
9 changed files with 11 additions and 237 deletions

View File

@ -5,7 +5,6 @@
"minerva-last-modified-date": "Last edited on $1, at $2",
"minerva-talk-add-topic": "Add discussion",
"mobile-frontend-cookies-required": "Cookies are required to switch view modes. Please enable them and try again.",
"mobile-frontend-editor-blocked-info-loggedin": "Your account is blocked from editing. The block was made by {{GENDER:$2|$2}} for the following reason: $1",
"mobile-frontend-editor-cta": "Help improve this page!",
"minerva-pointer-dismiss": "Dismiss",
"mobile-frontend-editor-disabled": "This page is protected to prevent vandalism.",
@ -61,9 +60,5 @@
"skin-minerva-mobile-option-MinervaShowCategoriesButton": "Categories",
"skin-minerva-mobile-option-MinervaShowCategoriesButton-description": "View categories of pages",
"skin-minerva-mobile-option-MinervaEnableBackToTop": "Jump to top",
"skin-minerva-mobile-option-MinervaEnableBackToTop-description": "Jump to top of the current page using a floating button",
"skin-minerva-blocked-drawer-title": "Your account has been blocked from editing {{SITENAME}}",
"skin-minerva-blocked-drawer-reason-header": "Reason for the block",
"skin-minerva-blocked-drawer-creator-header": "{{GENDER:$1|Blocked}} by",
"skin-minerva-blocked-drawer-expiry-header": "Block will expire in"
"skin-minerva-mobile-option-MinervaEnableBackToTop-description": "Jump to top of the current page using a floating button"
}

View File

@ -14,7 +14,6 @@
"minerva-last-modified-date": "Text that displays the date the page was last modified. Parameters:\n* $1 - date\n* $2 - time\n{{Related|Mobile-frontend-last-modified}}",
"minerva-talk-add-topic": "Label for button which shows at bottom of talk pages in mobile view prompting addition of topic",
"mobile-frontend-cookies-required": "Error message shown when user attempts to switch site modes and cookies are not enabled.",
"mobile-frontend-editor-blocked-info-loggedin": "Toast message for logged in users that appears (before the user see the editor) when a user tries to edit a page, but is blocked from editing with reason and blocked by information.\n\nParameters:\n* $1 - blocked by information (Username of the user who crated this block)\n* $2 - Reason for this block, if any",
"mobile-frontend-editor-cta": "Caption for call to action when an anonymous user clicks on edit icon. (Note the mobile site currently doesn't allow anonymous editing.)\n{{Identical|Help improve this page}}",
"minerva-pointer-dismiss": "Label of button that dismisses overlay pointing at a particular new feature.",
"mobile-frontend-editor-disabled": "Toast message that appears when a user is unable to edit a page and clicks edit icon.",
@ -70,9 +69,5 @@
"skin-minerva-mobile-option-MinervaShowCategoriesButton": "Label for categories mobile web beta feature.\n{{Identical|Category}}",
"skin-minerva-mobile-option-MinervaShowCategoriesButton-description": "Description label for categories mobile web beta feature.",
"skin-minerva-mobile-option-MinervaEnableBackToTop": "Label for jump to top mobile web beta feature",
"skin-minerva-mobile-option-MinervaEnableBackToTop-description": "Description label for jump to top mobile web beta feature",
"skin-minerva-blocked-drawer-title": "Title for the drawer that appears when a blocked user attempts to edit.",
"skin-minerva-blocked-drawer-reason-header": "Header for the block reason message that appears when a blocked user attempts to edit.",
"skin-minerva-blocked-drawer-creator-header": "Header for the block creator that appears when a blocked user attempts to edit. \nParameters:\n* $1 - user's gender",
"skin-minerva-blocked-drawer-expiry-header": "Header for the block expiry that appears when a blocked user attempts to edit."
"skin-minerva-mobile-option-MinervaEnableBackToTop-description": "Description label for jump to top mobile web beta feature"
}

View File

@ -1272,45 +1272,7 @@ class SkinMinerva extends SkinTemplate implements ICustomizableSkin {
];
if ( $this->isAuthenticatedUser() ) {
$blockInfo = false;
if ( $user->isBlockedFrom( $title, true ) ) {
$block = $user->getBlock();
$blockReason = $block->mReason ?
Linker::formatComment( $block->mReason ) :
false;
$blockCreator = User::newFromName( $block->getByName() );
$blockExpiry = null;
$blockDuration = null;
if ( !wfIsInfinity( $block->getExpiry() ) ) {
$blockExpiry = $this->getLanguage()->translateBlockExpiry(
$block->getExpiry(),
$this->getUser(),
time()
);
// Use the largest unit returned from Language::formatDuraiton() since
// we do not need to display the level of percision that the method
// returns.
list( $blockDuration ) = explode(
', ',
$this->getLanguage()->formatDuration( wfTimestamp( TS_UNIX, $block->getExpiry() ) - time() )
);
}
$blockInfo = [
'creator' => [
'name' => $blockCreator->getName(),
'url' => $blockCreator->getUserPage()->getLinkURL(),
'gender' => $blockCreator->getOption( 'gender' ),
],
'expiry' => $blockExpiry,
'duration' => $blockDuration,
// check, if a reason for this block is saved, otherwise use "no reason given" msg
'reason' => $blockReason,
];
}
$vars['wgMinervaUserBlockInfo'] = $blockInfo;
$vars['wgMinervaUserBlockInfo'] = $user->isBlockedFrom( $title, true );
}
return $vars;

View File

@ -1,34 +0,0 @@
{{#collapseIcon}}{{>icon}}{{/collapseIcon}}
<div class="block-message">
<div class="block-message-icon">
{{#stopHandIcon}}{{>icon}}{{/stopHandIcon}}
</div>
<div class="block-message-info">
<div class="block-message-item block-message-title">
<h5>{{ title }}</h5>
</div>
<div class="block-message-data">
{{#reason}}
<div class="block-message-item">
<h6>{{ reasonHeader }}</h6>
<div><strong>{{{ reason }}}</strong></div>
</div>
{{/reason}}
<div class="block-message-item block-message-creator">
<h6>{{ creatorHeader }}</h6>
<div><strong><a href="{{ creator.url }}">{{#userIcon}}{{>icon}}{{/userIcon}}{{ creator.name }}</a></strong></div>
</div>
{{#expiry}}
<div class="block-message-item">
<h6>{{ expiryHeader }}</h6>
<div><strong>{{#duration}}{{ duration }} / {{/duration}}{{ expiry }}</strong></div>
</div>
{{/expiry}}
</div>
{{#okButton}}
<div class="block-message-item block-message-buttons">
{{>button}}
</div>
{{/okButton}}
</div>
</div>

View File

@ -1,53 +0,0 @@
( function ( M ) {
'use strict';
var Drawer = M.require( 'mobile.startup/Drawer' ),
Button = M.require( 'mobile.startup/Button' ),
Icon = M.require( 'mobile.startup/Icon' ),
util = M.require( 'mobile.startup/util' );
/**
* This creates the drawer at the bottom of the screen that appears when a
* blocked user tries to edit.
* @class BlockReason
* @extends Drawer
*/
function BlockMessage() {
Drawer.apply( this, arguments );
}
OO.mfExtend( BlockMessage, Drawer, {
defaults: util.extend( {}, Drawer.prototype.defaults, {
stopHandIcon: new Icon( {
glyphPrefix: 'minerva',
name: 'stop-hand'
} ).options,
userIcon: new Icon( {
tagName: 'span',
glyphPrefix: 'minerva',
name: 'profile'
} ).options,
okButton: new Button( {
label: mw.msg( 'ok' ),
tagName: 'button',
progressive: true,
additionalClassNames: 'cancel'
} ).options,
title: mw.msg( 'skin-minerva-blocked-drawer-title' ),
reasonHeader: mw.msg( 'skin-minerva-blocked-drawer-reason-header' ),
creatorHeader: function () {
return mw.msg( 'skin-minerva-blocked-drawer-creator-header',
this.creator.gender || 'unknown' );
},
expiryHeader: mw.msg( 'skin-minerva-blocked-drawer-expiry-header' )
} ),
templatePartials: util.extend( {}, Drawer.prototype.templatePartials, {
button: Button.prototype.template,
icon: Icon.prototype.template
} ),
template: mw.template.get( 'skins.minerva.editor.blockMessage', 'BlockMessage.hogan' )
} );
M.define( 'skins.minerva.editor/BlockMessage', BlockMessage );
}( mw.mobileFrontend ) );

View File

@ -1,52 +0,0 @@
@import 'mediawiki.ui/variables';
.block-message {
h5 {
font-weight: bold;
}
h6 {
margin-bottom: 0.187em;
}
}
.block-message-icon {
float: left;
width: 20%;
margin-top: 0.3em;
}
.block-message-info {
float: left;
width: 80%;
text-align: left;
}
.block-message-item {
margin-bottom: 1em;
}
.block-message-data {
margin-bottom: 1.875em;
}
.block-message-buttons button.cancel {
margin: 0;
}
.block-message-creator {
a {
color: inherit;
&:hover {
text-decoration: none;
}
}
.mw-ui-icon {
display: inline-block;
vertical-align: top;
margin: 0 -@iconGutterWidth;
}
}
.block-message-title {
color: @colorDestructive;
}

View File

@ -10,7 +10,6 @@
Icon = M.require( 'mobile.startup/Icon' ),
Button = M.require( 'mobile.startup/Button' ),
Anchor = M.require( 'mobile.startup/Anchor' ),
BlockMessage = M.require( 'skins.minerva.editor/BlockMessage' ),
skin = M.require( 'skins.minerva.scripts/skin' ),
currentPage = M.getCurrentPage(),
// TODO: create a utility method to generate class names instead of
@ -48,10 +47,8 @@
if ( user.isAnon() ) {
blockInfo = false;
} else if ( isEditable ) {
// for logged in users check if they are blocked from editing this page
isEditable = !blockInfo;
}
// TODO: rename addEditSectionButton and evaluate whether the page edit button
// can leverage the same code. Also: change the CSS class name to use
// the word "section" instead of "page".
@ -333,6 +330,10 @@
router.navigate( fragment );
}
}
if ( blockInfo ) {
updateEditPageButton( false );
}
}
/**
@ -341,23 +342,12 @@
* @ignore
*/
function init() {
var message;
if ( isEditable ) {
// Edit button updated in setupEditor.
setupEditor( currentPage );
} else {
updateEditPageButton( false );
if ( blockInfo ) {
message = new BlockMessage( blockInfo );
$( '#ca-edit' ).on( 'click', function ( ev ) {
message.toggle();
ev.preventDefault();
} );
$( '.edit-page' ).detach();
} else {
showSorryToast( mw.msg( 'mobile-frontend-editor-disabled' ) );
}
showSorryToast( mw.msg( 'mobile-frontend-editor-disabled' ) );
}
}

View File

@ -1 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><title>stop hand</title><path fill="#e03b3b" d="M13.2 11.8c0-.2-.4-.6-.7-.8V1.9c0-.5-.5-.9-1-.9s-.9.4-.9.9v8c-.3 0-.6-.1-.9-.1V1c0-.5-.4-.9-.9-.9s-.9.4-.9.9v8.8H7V1.7c0-.5-.4-.9-.9-.9s-.9.4-.9.9V10c-.3 0-.7.1-.9.1V4.7c0-.5-.3-.9-.7-.9-.4 0-.7.4-.7.9v7.5c0 8.9 5.8 7.7 5.8 7.7 5 0 6.2-6.2 6.2-6.2.2-1.1 2.4-4.2 2.4-4.2-1.9-2.3-4.1 2.3-4.1 2.3"/></svg>

Before

Width:  |  Height:  |  Size: 448 B

View File

@ -261,8 +261,7 @@
"class": "ResourceLoaderImageModule",
"selector": ".mw-ui-icon-minerva-{name}:before",
"images": {
"download": "resources/skins.minerva.icons.images.scripts.misc/download.svg",
"stop-hand": "resources/skins.minerva.icons.images.scripts.misc/stop-hand.svg"
"download": "resources/skins.minerva.icons.images.scripts.misc/download.svg"
}
},
"skins.minerva.icons.page.issues.uncolored": {
@ -501,31 +500,6 @@
"desktop"
]
},
"skins.minerva.editor.blockMessage": {
"dependencies": [
"skins.minerva.scripts"
],
"messages": [
"ok",
"skin-minerva-blocked-drawer-title",
"skin-minerva-blocked-drawer-reason-header",
"skin-minerva-blocked-drawer-creator-header",
"skin-minerva-blocked-drawer-expiry-header"
],
"templates": {
"BlockMessage.hogan": "resources/skins.minerva.editor/BlockMessage.hogan"
},
"scripts": [
"resources/skins.minerva.editor/BlockMessage.js"
],
"styles": [
"resources/skins.minerva.editor/BlockMessage.less"
],
"targets": [
"mobile",
"desktop"
]
},
"skins.minerva.editor": {
"targets": [
"mobile",
@ -539,14 +513,12 @@
"mediawiki.ui.input",
"mobile.startup",
"skins.minerva.toggling",
"mediawiki.jqueryMsg",
"skins.minerva.editor.blockMessage"
"mediawiki.jqueryMsg"
],
"messages": [
"mobile-frontend-editor-disabled",
"mobile-frontend-editor-unavailable",
"mobile-frontend-editor-uploadenable",
"mobile-frontend-editor-blocked-info-loggedin",
"mobile-frontend-editor-cta",
"mobile-frontend-editor-undo-unsupported",
"mobile-frontend-editor-edit",