Merge "Rebaser: Generate random doc name if none provided"

This commit is contained in:
jenkins-bot 2018-02-21 16:37:36 +00:00 committed by Gerrit Code Review
commit 5de7185687

View file

@ -80,10 +80,13 @@
function onSubmit() {
documentNameInput.getValidity().then( function () {
var title = mw.Title.newFromText( documentNameInput.getValue() ),
specialTitle = mw.Title.newFromText( 'Special:CollabPad/' + title.toString() );
var specialTitle,
title = mw.Title.newFromText(
documentNameInput.getValue().trim() || Math.random().toString( 36 ).slice( 2 )
);
if ( title ) {
specialTitle = mw.Title.newFromText( 'Special:CollabPad/' + title.toString() );
if ( history.pushState ) {
// TODO: Handle popstate
history.pushState( { tag: 'collabTarget', title: title.toString() }, title.getMain(), specialTitle.getUrl() );
@ -98,8 +101,8 @@
}
documentNameInput.setValidation( function ( value ) {
var title = mw.Title.newFromText( value );
return !!title;
// Empty input will create a random document name, otherwise must be valid
return value === '' || !!mw.Title.newFromText( value );
} );
submitButton.setDisabled( false );