Permalink
Browse files

Fix fireContextChange by passing a dataModel: fix right-click instabi…

…lities.
  • Loading branch information...
1 parent 2b676dc commit 9d9851bfe55bd5e0898f3011d040a869cae6cfad @cdujeu cdujeu committed Jun 29, 2016
@@ -209,20 +209,20 @@ class Action extends Observable{
/**
* Updates the action status on context change
+ * @param PydioDataModel dataModel
+ * @param boolean usersEnabled
+ * @param string crtUser
* @returns void
*/
- fireContextChange(){
- if(arguments.length < 3) return;
- var usersEnabled = arguments[0];
- var crtUser = arguments[1];
+ fireContextChange(dataModel, usersEnabled, crtUser){
var crtIsRecycle = false;
var crtInZip = false;
var crtIsRoot = false;
var crtAjxpMime = '';
var crtIsReadOnly = false;
- var crtNode = arguments[2];
+ var crtNode = dataModel.getContextNode();
if(crtNode){
crtIsRecycle = (crtNode.getAjxpMime() == "ajxp_recycle");
crtInZip = crtNode.hasAjxpMimeInBranch("ajxp_browsable_archive");
@@ -284,7 +284,8 @@ class Action extends Observable{
if(!this.context.root && crtIsRoot){
return this.hideForContext();
}
- this.showForContext();
+
+ this.showForContext(dataModel);
}
@@ -663,11 +664,11 @@ class Action extends Observable{
/**
* Changes show/hide state
*/
- showForContext(){
+ showForContext(dataModel){
this.contextHidden = false;
this.show();
if(this.selectionContext){
- this.fireSelectionChange();
+ this.fireSelectionChange(dataModel);
}
}
@@ -441,12 +441,9 @@ class Controller extends Observable{
* by triggering ajaxplorer:actions_refreshed event.
*/
fireSelectionChange(){
- var userSelection = null;
- userSelection = this._dataModel;
- if(userSelection.isEmpty()) userSelection = null;
this.actions.forEach(function(action){
- action.fireSelectionChange(userSelection);
- });
+ action.fireSelectionChange(this._dataModel);
+ }.bind(this));
if(this.localDataModel){
this.notify("actions_refreshed");
}else{
@@ -459,11 +456,10 @@ class Controller extends Observable{
* by triggering ajaxplorer:actions_refreshed event.
*/
fireContextChange(){
- var crtNode = this._dataModel.getContextNode();
this.actions.forEach(function(action){
- action.fireContextChange(this.usersEnabled,
- this.oUser,
- crtNode);
+ action.fireContextChange(this._dataModel,
+ this.usersEnabled,
+ this.oUser);
}.bind(this));
if(this.localDataModel){
this.notify("actions_refreshed");
@@ -391,6 +391,14 @@ class PydioDataModel extends Observable{
parent.addChild(node);
}
}else{
+ if(node.getMetadata().get("original_path") === "/" && node.getPath() === "/"){
+ n = this.getRootNode();
+ n._metadata = node.getMetadata();
+ if(setSelectedAfterUpdate && this.getContextNode() == n) {
+ this.setSelectedNodes([n], {});
+ }
+ return;
+ }
fake = new AjxpNode(original);
n = fake.findInArbo(this.getRootNode(), undefined);
if(n && !n.isMoreRecentThan(node)){
@@ -423,9 +423,10 @@ Class.create("ActionsToolbar", AjxpPane, {
attachListeners : function(button, action){
if(this.options.attachToNode){
- action.fireContextChange(ajaxplorer.usersEnabled, ajaxplorer.user, this.options.attachToNode.getParent());
var fakeDm = new PydioDataModel();
+ fakeDm.setContextNode(this.options.attachToNode.getParent());
fakeDm.setSelectedNodes([this.options.attachToNode]);
+ action.fireContextChange(fakeDm, pydio.usersEnabled, pydio.user);
action.fireSelectionChange(fakeDm);
if(action.deny) {
button.hideButton();
@@ -716,8 +716,8 @@
var actionName = event.currentTarget.getAttribute("data-action");
this.props.dataModel.setSelectedNodes([this.props.node]);
var a = global.pydio.Controller.getActionByName(actionName);
- a.fireContextChange(true, global.pydio.user, this.props.dataModel.getContextNode());
- a.fireSelectionChange(this.props.dataModel);
+ a.fireContextChange(this.props.dataModel, true, global.pydio.user);
+ //a.fireSelectionChange(this.props.dataModel);
a.apply([this.props.dataModel]);
event.stopPropagation();
event.preventDefault();
@@ -1558,8 +1558,8 @@
});
dm.setSelectedNodes(selNodes);
var a = global.pydio.Controller.getActionByName(actionName);
- a.fireContextChange(true, global.pydio.user, dm.getContextNode());
- a.fireSelectionChange(dm);
+ a.fireContextChange(dm, true, global.pydio.user);
+ //a.fireSelectionChange(dm);
a.apply([dm]);
ev.stopPropagation();
@@ -1575,8 +1575,8 @@
}else{
dm.setSelectedNodes([node]);
global.pydio.Controller.actions.forEach(function(a){
- a.fireContextChange(true, global.pydio.user, dm.getContextNode());
- a.fireSelectionChange(dm);
+ a.fireContextChange(dm, true, global.pydio.user);
+ //a.fireSelectionChange(dm);
if(a.context.selection && a.context.actionBar && a.selectionContext[cacheKey] && !a.deny && a.options.icon_class
&& (!this.props.actionBarGroups || this.props.actionBarGroups.indexOf(a.context.actionBarGroup) !== -1)
) {

0 comments on commit 9d9851b

Please sign in to comment.