Skip to content

Commit

Permalink
Cernbox prod 8.2.2 improve share limitation (#118)
Browse files Browse the repository at this point in the history
* Improve user experience when throwing errors

* Improve user exp on creating shares
  • Loading branch information
labkode authored May 11, 2017
1 parent 65a49ad commit 2917041
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 13 deletions.
18 changes: 11 additions & 7 deletions core/js/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,14 +410,15 @@ OC.Share = _.extend(OC.Share || {}, {
callback(result.data);
}
} else {
var msg = t('core', 'Error');
if (result.data && result.data.message) {
msg = result.data.message;
}

if (_.isUndefined(errorCallback)) {
var msg = t('core', 'Error');
if (result.data && result.data.message) {
msg = result.data.message;
}
OC.dialogs.alert(msg, t('core', 'Error while sharing'));
} else {
errorCallback(result);
OC.dialogs.alert(msg, t('core', 'Error while sharing'));
errorCallback(true);
}
}
}
Expand All @@ -438,14 +439,17 @@ OC.Share = _.extend(OC.Share || {}, {
}
});
},
setPermissions:function(itemType, itemSource, shareType, shareWith, permissions) {
setPermissions:function(itemType, itemSource, shareType, shareWith, permissions, callback) {
$.post(OC.filePath('core', 'ajax', 'share.php'), { action: 'setPermissions', itemType: itemType, itemSource: itemSource, shareType: shareType, shareWith: shareWith, permissions: permissions }, function(result) {
if (!result || result.status !== 'success') {
var msg = t('core', 'Error while unsharing');
if (result.data && result.data.message) {
msg = result.data.message;
}
OC.dialogs.alert(msg, t('core', 'Error'));
if(callback) {
callback(true);
}
}
});
},
Expand Down
7 changes: 6 additions & 1 deletion core/js/sharedialogshareelistview.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@
var shareWith = $li.attr('data-share-with');

this.model.removeShare(shareType, shareWith);
$loading.addClass('hidden');

return false;
},
Expand Down Expand Up @@ -297,7 +298,11 @@
permissions |= $(checkbox).data('permissions');
});*/
/** PATCH END */
this.model.setPermissions(shareType, shareWith, permissions);
this.model.setPermissions(shareType, shareWith, permissions, function(errored) {
if(errored) {
$('input[name="edit"]', $li).attr('checked', !checked);
}
});
},

onCrudsToggle: function(event) {
Expand Down
6 changes: 5 additions & 1 deletion core/js/sharedialogview.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,11 @@

var options = {};
options.notifyByEmail = _self.$el.find('#shareNotifyByEmail').is(":checked");
_self.model.addShareList(shareRequestData, options);
_self.model.addShareList(shareRequestData, options, function(errored) {
if(errored) {
_self._toggleLoading(false);
}
});

_self.shareRecipientList.length = 0;
_self.$el.find('#recipentList').addClass('hidden');
Expand Down
8 changes: 5 additions & 3 deletions core/js/shareitemmodel.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
},

/** CERNBOX SHARE USER LIST PR PATCH */
addShareList: function(shareWith, options)
addShareList: function(shareWith, options, callback)
{
var fileName = this.fileInfoModel.get('name');
options = options || {};
Expand All @@ -246,6 +246,8 @@
var itemSource = this.get('itemSource');
OC.Share.shareList(itemType, itemSource, null, shareWith, permissions, fileName, options.expiration, options.notifyByEmail, function() {
model.fetch();
}, function(errored) {
callback(errored);
});
},

Expand Down Expand Up @@ -283,12 +285,12 @@
});
},

setPermissions: function(shareType, shareWith, permissions) {
setPermissions: function(shareType, shareWith, permissions, callback) {
var itemType = this.get('itemType');
var itemSource = this.get('itemSource');

// TODO: in the future, only set the permissions on the model but don't save directly
OC.Share.setPermissions(itemType, itemSource, shareType, shareWith, permissions);
OC.Share.setPermissions(itemType, itemSource, shareType, shareWith, permissions, callback);
},

removeShare: function(shareType, shareWith) {
Expand Down
2 changes: 1 addition & 1 deletion lib/private/shareutil.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static function checkParentDirShared(array $eosMeta, $isShareByLink) {

$sharedFolderPath = self::childrenFoldersHaveBeenShared($allPaths, $currentPath);
if ($sharedFolderPath) {
$msg = "Unable to modify share information because it will cause the lost of share information in the already shared folder '$sharedFolderPath'";
$msg = "Currently not allowed. See KB at http://cern.ch/go/R7np";
throw new \Exception($msg);
}
}
Expand Down

0 comments on commit 2917041

Please sign in to comment.