Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Fix fireContextChange by passing a dataModel: fix right-click instabi…
Browse files Browse the repository at this point in the history
…lities.

(cherry picked from commit 9d9851b)
  • Loading branch information
cdujeu committed Jul 4, 2016
1 parent 9562300 commit b5d2e58
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 24 deletions.
17 changes: 9 additions & 8 deletions core/src/plugins/gui.ajax/res/js/es6/model/Action.es6
Expand Up @@ -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");
Expand Down Expand Up @@ -284,7 +284,8 @@ class Action extends Observable{
if(!this.context.root && crtIsRoot){
return this.hideForContext();
}
this.showForContext();

this.showForContext(dataModel);

}

Expand Down Expand Up @@ -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);
}
}

Expand Down
14 changes: 5 additions & 9 deletions core/src/plugins/gui.ajax/res/js/es6/model/Controller.es6
Expand Up @@ -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{
Expand All @@ -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");
Expand Down
8 changes: 8 additions & 0 deletions core/src/plugins/gui.ajax/res/js/es6/model/PydioDataModel.es6
Expand Up @@ -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)){
Expand Down
Expand Up @@ -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();
Expand Down
Expand Up @@ -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();
Expand Down Expand Up @@ -1551,8 +1551,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();
Expand All @@ -1568,8 +1568,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)
) {
Expand Down

0 comments on commit b5d2e58

Please sign in to comment.