Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XWIKI-22830: CreateWiki: Next step button remains disabled if one fills the wiki identifier before the pretty name #3852

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,7 @@ $xwiki.getURL('XWiki.XWikiPreferences', 'admin', "editor=globaladmin&section
var isWikiNameSet = false;
var isAliasSet = false;
var lastWikiName;
var lastPrettyName;

## Error messages
#set ($MSG_ERROR_WIKIALREADYEXISTS = "$services.localization.render('platform.wiki.create.error.wikiname.wikialreadyexists')")
Expand Down Expand Up @@ -857,6 +858,7 @@ $xwiki.getURL('XWiki.XWikiPreferences', 'admin', "editor=globaladmin&section
if(prettyName.value.blank()){
$('wikiprettynamevalidation').innerHTML = "$MSG_ERROR_WIKIPRETTYNAMEEMPTY";
prettyName.addClassName('xErrorField');
$('wizard-next').disabled = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wiki name validation is asynchronous, which means we can have this case:

  • the user types a valid wiki name, which triggers a validation HTTP request
  • the network is slow, so the user can clear the wiki pretty name before the validation response is received; this disables the Next button
  • the validation response is received, and the Next button is enabled => the user can move to the next step with an empty wiki pretty name

}else{
$('wikiprettynamevalidation').innerHTML = '';
prettyName.removeClassName('xErrorField');
Expand All @@ -866,6 +868,11 @@ $xwiki.getURL('XWiki.XWikiPreferences', 'admin', "editor=globaladmin&section
wikiName.value = prettyName.value.replace(/[^a-zA-Z0-9]/g,'_').toLowerCase();
validateWikiName();
}
// No matter the path, at this point, the wikiName has been already validated.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not true, because the wiki name validation is asynchronous. We can have this case:

  • the user types an invalid wiki name, which triggers a validation HTTP request
  • the network is slow, so the user can type the wiki pretty name before the validation response is received; this enables the Next button => the user can move to the next step with an invalid wiki name

// If it's valid and the pretty name is not blank, we make sure that the user can continue to the next step.
if ($('wikinamevalidation').innerHTML=='') {
$('wizard-next').disabled = false;
}
if(!isAliasSet){
var wikiAlias = $('wikialias');
if (wikiAlias) {
Expand Down Expand Up @@ -900,10 +907,12 @@ $xwiki.getURL('XWiki.XWikiPreferences', 'admin', "editor=globaladmin&section
wikiNameElement.value = filteredWikiName;
wikiname = filteredWikiName;
}
if (lastWikiName == wikiname){
var prettyName = $('prettyname').value
if (lastWikiName === wikiname && lastPrettyName === prettyName){
return;
}
lastWikiName = wikiname;
lastPrettyName = prettyName;
if (wikiname && !wikiname.blank()) {
var surl = "$ISWIKINAMEAVAILABLE" + "?xpage=plain&outputSyntax=plain&ajax=1&wikiname=" + escape(wikiname);
surl += "&form_token=$!{services.csrf.getToken()}";
Expand Down