XWiki 9.8 : Dashboard add gadget button does not work?

I have just upgraded to 9.8, and when I edit a dashboard with inline mode the add gadget button does not work anymore. It’s ok for add column though.

dashboard.js seems to be responsible with the error wysiwyg not defined.

Extract of the IE debogger for the js file :

var XWiki=(function(b){b.Dashboard=Class.create({initialize:function©{this.element=c;this.gadgetsClass=“XWiki.GadgetClass”;this.readMetadata();this.displayWarning();this.edited=false;this.removed=new Array();this.element.addClassName(“dashboard-edit”);this.containers=c.select(".gadget-container");this.createDragAndDrops();this.addGadgetsHandlers();this.addNewGadgetHandler();this.addNewContainerHandler();document.observe(“xwiki:actions:save”,this.saveChanges.bindAsEventListener(this))},readMetadata:function(){this.editURL=this.element.down(".metadata .editurl").readAttribute(“href”);this.removeURL=this.element.down(".metadata .removeurl").readAttribute(“href”);this.addURL=this.element.down(".metadata .addurl").readAttribute(“href”);this.sourcePage=this.element.down(".metadata .sourcepage").innerHTML;this.sourceSpace=this.element.down(".metadata .sourcespace").innerHTML;this.sourceWiki=this.element.down(".metadata .sourcewiki").innerHTML;this.sourceURL=this.element.down(".metadata .sourceurl").readAttribute(“href”)},displayWarning:function(){if(b.currentDocument.page!=this.sourcePage||b.currentDocument.space!=this.sourceSpace||b.currentDocument.wiki!=this.sourceWiki){var f=new Element(“div”,{“class”:“box warningmessage differentsource”});var d=“Vous \u00EAtes en train de modifier un tableau de bord d\u00E9fini dans un document diff\u00E9rent,”;var c=". Vos changements auront un impact sur toutes les pages incluant cette configuration de tableau de bord. Si vous souhaitez personnaliser cette page, \u00E9ditez-la en mode WYSIWYG et configurez la macro “tableau de bord” avec un param\u00E8tre source vide.";var e=new Element(“a”,{href:this.sourceURL});e.update(this.sourceWiki+":"+this.sourceSpace+"."+this.sourcePage);f.insert(d);f.insert(e);f.insert©;this.element.insert({top:f})}},_getContainerId:function©{return c.readAttribute(“id”).substring(16)},_getGadgetId:function©{return c.readAttribute(“id”).substring(7)},_getMacroCallComment:function©{return""},_parseMacroCallComment:function(d){var c=d.indexOf("–>");if(d.startsWith("<!–startmacro:")&&c>0){return d.substr(4,c-4)}else{return null}},_insertPlaceholder:function©{if(c.down(".gadget")||c.down(".gadget-placeholder")){return}var d=new Element(“div”,{“class”:“gadget-placeholder”}).update(“Vous pouvez d\u00E9poser des gadget ici”);c.insert(d)},_removePlaceholder:function(d){var c=d.select(".gadget-placeholder");c.each(function(e){e.remove()})},_doOnStartDrag:function(){this.containers.each(this._insertPlaceholder)},_doOnEndDrag:function(){this.containers.each(this._removePlaceholder)},createDragAndDrops:function(){var c=new Array();this.containers.each(function(d){c.push(d.readAttribute(“id”))});c.each(function(d){this.makeSortable(d,c,this.onMoveGadget.bind(this))}.bind(this));Draggables.addObserver({onStart:this._doOnStartDrag.bind(this),onEnd:this._doOnEndDrag.bind(this)})},makeSortable:function(c,d,e){Sortable.create(c,{tag:“div”,only:“gadget”,handle:“gadget-title”,overlap:“vertical”,scroll:window,containment:d,dropOnEmpty:true,constraint:false,ghosting:false,hoverclass:“gadget-container-hover-highlight”,onUpdate:e})},addGadgetsHandlers:function(){this.element.select(".gadget").each(this.addGadgetHandlers.bind(this))},addGadgetHandlers:function(f){var e=new Element(“span”,{“class”:“remove action”,title:“Supprimer ce gadget du tableau de bord”});e.observe(“click”,this.onRemoveGadget.bindAsEventListener(this));var c=new Element(“span”,{“class”:“edit action”,title:"\u00C9ditez les param\u00E8tres de ce gadget"});c.observe(“click”,this.onEditGadgetClick.bindAsEventListener(this));var d=new Element(“div”,{“class”:“gadget-actions”});d.insert©;d.insert(e);f.insert(d)},addNewGadgetHandler:function(){var c=new Element(“div”,{“class”:“addgadget”,title:“Ajouter un gadget \u00E0 ce tableau de bord”});c.update(“Ajouter un Gadget”);c.observe(“click”,this.onAddGadgetClick.bindAsEventListener(this));var d=this.element.down(".differentsource");if(d){d.insert({after:c})}else{this.element.insert({top:c})}c.insert({after:new Element(“div”,{“class”:“clearfloats”})})},onAddGadgetClick:function©{Wysiwyg.onModuleLoad(function(){if(!this.gadgetWizard){this.gadgetWizard=new b.GadgetWizard(this.createGadgetWizardConfig())}this.gadgetWizard.add(this.onAddGadgetComplete.bind(this))}.bind(this))},createGadgetWizardConfig:function(){var c={wiki:document.documentElement.getAttribute(“data-xwiki-wiki”),space:document.documentElement.getAttribute(“data-xwiki-space”),page:document.documentElement.getAttribute(“data-xwiki-page”),syntax:b.docsyntax,soureceWiki:this.sourceWiki,sourceSpace:this.sourceSpace,sourcePage:this.sourcePage};return c}.bind(this),onAddGadgetComplete:function(g){var f=this._getMacroCallComment(g.content);var c=this.containers.length;var h=this.containers.last().select(".gadget").length+1;var d=new Hash();d.set(“classname”,this.gadgetsClass);d.set(this.gadgetsClass+"_title",g.title);d.set(this.gadgetsClass+"_content",f);d.set(“RequiresHTMLConversion”,this.gadgetsClass+"_content");d.set(this.gadgetsClass+"_content_syntax",“xwiki/2.0”);d.set(this.gadgetsClass+"_position",c+", “+h);var e=this.getFormToken();d.set(“form_token”,e);this._x_notification=new b.widgets.Notification(“Ajout du gadget en cours”,“inprogress”);new Ajax.Request(this.addURL,{parameters:d,onSuccess:function(i){window.location.reload()}.bind(this),onFailure:function(i){var j=i.statusText;if(i.statusText==”"||i.status==12031){j=“Server not responding”}this._x_notification.replace(new b.widgets.Notification("\u00C9chec lors de l’ajout de gadget"+j,“error”,{timeout:5}))}.bind(this),on0:function(i){i.request.options.onFailure(i)}.bind(this)})},onEditGadgetClick:function©{var h=c.element().up(".gadget");if(h){var d=h.down(".metadata");if(!d){return}var k=d.down(".isMacro");if(k&&k.innerHTML==“true”){var e=this._getGadgetId(h);var l,f;var i=d.down(".title");if(i){l=i.innerHTML}var m=d.down(".content");if(m){var g=m.innerHTML;f=this._parseMacroCallComment(g)}Wysiwyg.onModuleLoad(function(){if(!this.gadgetWizard){this.gadgetWizard=new b.GadgetWizard(this.createGadgetWizardConfig())}this.gadgetWizard.edit(f,l,function(n){this.onEditGadgetComplete(e,n)}.bind(this))}.bind(this))}else{var j=new b.widgets.ModalPopup(“Les param\u00E8tres de ce gadget ne peuvent pas \u00EAtre \u00E9dit\u00E9s avec l’\u00E9diteur visuel. Vous pouvez cependant mettre \u00E0 jour les param\u00E8tres en utilisant l’\u00E9diteur objet.”,{},{title:“Modifier les param\u00E8tres”});j.showDialog()}}},onEditGadgetComplete:function(c,g){var f=this.getMacroCallComment(g.content);var e=new Hash();e.set(this.gadgetsClass+""+c+“title",g.title);e.set(this.gadgetsClass+"”+c+“content",f);e.set(“RequiresHTMLConversion”,this.gadgetsClass+"”+c+“content");e.set(this.gadgetsClass+"”+c+"_content_syntax",“xwiki/2.0”);e.set(“ajax”,“1”);var d=this.getFormToken();e.set(“form_token”,d);this._x_notification=new b.widgets.Notification(“Sauvegarde de la configuration du gadget”,“inprogress”);new Ajax.Request(this.editURL,{parameters:e,onSuccess:function(h){window.location.reload()}.bind(this),onFailure:function(h){var i=h.statusText;if(h.statusText==""||h.status==12031){i=“Server not responding”}this._x_notification.replace(new b.widgets.Notification("\u00C9chec de la sauvegarde de la configuration du gadget"+i,“error”,{timeout:5}))}.bind(this),on0:function(h){h.request.options.onFailure(h)}.bind(this)})},onRemoveGadget:function(e){var d=e.element();var f=d.up(".gadget");if(!f){return}var c=this._getGadgetId(f);this.removed.push©;new b.widgets.ConfirmedAjaxRequest(this.removeURL,{parameters:{classname:encodeURIComponent(this.gadgetsClass),classid:encodeURIComponent©,ajax:“1”,form_token:this.getFormToken()},onCreate:function(){d.disabled=true},onSuccess:function(g){f.remove()}.bind(this)},{confirmationText:"\u00CAtes-vous s\u00FBr de vouloir supprimer ce gadget?",progressMessageText:“Suppression en cours”,successMessageText:“Gadget supprim\u00E9”,failureMessageText:"\u00C9chec lors de la suppression du gadget"})},addNewContainerHandler:function(){var c=new Element(“div”,{“class”:“addcontainer”,title:“Ajouter une colonne au tableau de bord”});c.update(“Ajouter une colonne”);c.observe(“click”,this.onAddColumn.bindAsEventListener(this));var d=this.element.down(".addgadget");d.insert({before:c})},onAddColumn:function(d){var i=this.containers.last();var f=this.getContainerId(i);var m=1+parseInt(f,10);var e="gadgetcontainer"+m;var c=new Element(“div”,{“class”:i.readAttribute(“class”),id:e});i.removeClassName(“last-column”);i.insert({after:c});this.containers.push©;var j=“container-columns-”+(this.containers.length-1);var h=“container-columns-”+this.containers.length;var k=i.parentNode;k.addClassName(h);k.removeClassName(j);var l=new Array();this.containers.each(function(n){l.push(n.readAttribute(“id”))});this.createDragAndDrops();var g=$(document.getElementsByTagName(“head”)[0]);g.insert(linkElement)},doEditGadgets:function(e){var d=this.prepareEditParameters();d.set(“ajax”,“1”);var c=this.getFormToken();d.set(“form_token”,c);new Ajax.Request(this.editURL,{parameters:d,onSuccess:function(f){this.edited=false;if(e){e()}}.bind(this),onFailure:function(f){var g=f.statusText;if(f.statusText==""||f.status==12031){g=“Server not responding”}this._x_notification=new b.widgets.Notification("\u00C9chec \u00E0 l’enregistrement de la configuration du tableau de bord :"+g,“error”,{timeout:5});if(e){e()}}.bind(this),on0:function(f){f.request.options.onFailure(f)}.bind(this)})},onMoveGadget:function©{this.edited=true},saveChanges:function(d){if(!this.edited){return}d.stop();d.memo.originalEvent.stop();var c=d.memo.originalEvent.element();this._x_edit_notification=new b.widgets.Notification(“Sauvegarde en cours…”,“inprogress”);this.doEditGadgets(function(){if(!this.edited){c.click()}if(this._x_edit_notification){this._x_edit_notification.hide()}}.bind(this))},prepareEditParameters:function(){var c=new Hash();this.containers.each(function(e){var d=this._getContainerId(e);e.select(".gadget").each(function(i,h){var f=this.getGadgetId(i);var g=this.gadgetsClass+""+f+"_position";var j=d+", “+(h+1);c.set(g,j)},this)},this);return c},getFormToken:function(){var c=this.element.up(“form”);if©{var d=c.form_token;if(d){return d.value}}return”"}});function a(){if(b.contextaction==“inline”||(b.contextaction==“edit”&&$(“inline”))){var c=$$(".dashboard")[0];if©{new b.Dashboard©}}return true}(b.domIsLoaded&&a())||document.observe(“xwiki:dom:loaded”,a);return b}(XWiki||{}));

Try to clear your browser’s cache and reload the page. The gadget wizard has been updated recently (http://www.xwiki.org/xwiki/bin/view/ReleaseNotes/Data/XWiki/9.7/#HGadgetWizardUpdate) and you may be using cached resources that don’t work anymore with the new version.

Hope this helps,
Marius

Hello Marius thanks for your message. Actually I did it after the upgrade, but I dit it again after reading your message, then performed a CTRL+F5 with the same result. I finally did a show code source, clicked on the link of the dashboard.js file, reloaded the page and then it worked.
Clearly a cache problem, so thanks for pointing me in the right direction.

Yann