Show anon warning

Message copied from Flow.

Change-Id: Id003a1e57447b3087cd973964b3a88886d2cb7d6
This commit is contained in:
Ed Sanders 2019-11-19 14:33:14 -05:00
parent 763450db24
commit 83ddc3d627
5 changed files with 30 additions and 1 deletions

View file

@ -85,6 +85,7 @@
"dt.ui.ReplyWidget.less"
],
"messages": [
"discussiontools-replywidget-anon-warning",
"discussiontools-replywidget-cancel",
"discussiontools-replywidget-reply"
],
@ -92,7 +93,8 @@
"ext.discussionTools.controller",
"oojs-ui-core",
"mediawiki.editfont.styles",
"mediawiki.user"
"mediawiki.user",
"mediawiki.jqueryMsg"
]
}
},

View file

@ -6,6 +6,7 @@
"discussiontools-defaultsummary-reply": "Reply",
"discussiontools-desc": "Tools to enhance discussion pages.",
"discussiontools-replylink": "Reply",
"discussiontools-replywidget-anon-warning": "<strong>You are not logged in.</strong> To receive attribution with your name instead of your IP address, you can [$1 log in] or [$2 create an account].",
"discussiontools-replywidget-cancel": "Cancel",
"discussiontools-replywidget-loading": "Loading…",
"discussiontools-replywidget-reply": "Reply"

View file

@ -8,6 +8,7 @@
"discussiontools-defaultsummary-reply": "Default edit summary for a reply",
"discussiontools-desc": "{{desc|name=DiscussionTools|url=}}",
"discussiontools-replylink": "Label for the reply link added after each comment",
"discussiontools-replywidget-anon-warning": "Warning message to be displayed when anonymous user starts writing a new topic or reply.\n* $1 is a URL to log in.\n* $2 is a URL to register an account.",
"discussiontools-replywidget-cancel": "Label for the cancel button in the reply widget",
"discussiontools-replywidget-loading": "Message shown while the reply widget is loading",
"discussiontools-replywidget-reply": "Label for the button to submit a reply in the reply widget"

View file

@ -10,6 +10,8 @@ var controller = require( 'ext.discussionTools.controller' );
* @param {Object} [config] Configuration options
*/
function ReplyWidget( comment, config ) {
var returnTo;
// Parent constructor
ReplyWidget.super.call( this, config );
@ -46,6 +48,25 @@ function ReplyWidget( comment, config ) {
this.replyButton.$element
)
);
if ( mw.user.isAnon() ) {
returnTo = {
returntoquery: encodeURIComponent( window.location.search ),
returnto: mw.config.get( 'wgPageName' )
};
this.$element.prepend(
new OO.ui.MessageWidget( {
classes: [ 'dt-ui-replyWidget-anonWarning' ],
type: 'warning',
label: mw.message( 'discussiontools-replywidget-anon-warning' )
.params( [
mw.util.getUrl( 'Special:Userlogin', returnTo ),
mw.util.getUrl( 'Special:Userlogin/signup', returnTo )
] )
.parseDom()
} ).$element
);
}
}
/* Inheritance */

View file

@ -7,4 +7,8 @@
margin-top: 0.5em;
text-align: right;
}
&-anonWarning {
margin-bottom: 0.5em;
}
}