Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/js/fileactions.js')
-rw-r--r--apps/files/js/fileactions.js44
1 files changed, 32 insertions, 12 deletions
diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js
index 5d9e8578e19..d413bf7471b 100644
--- a/apps/files/js/fileactions.js
+++ b/apps/files/js/fileactions.js
@@ -142,6 +142,7 @@
name: name,
displayName: action.displayName,
mime: mime,
+ filename: action.filename,
order: action.order || 0,
icon: action.icon,
iconClass: action.iconClass,
@@ -191,11 +192,12 @@
* @param {string} mime mime type
* @param {string} type "dir" or "file"
* @param {int} permissions permissions
+ * @param {string} filename filename
*
* @return {Object.<string,OCA.Files.FileActions~actionHandler>} map of action name to action spec
*/
- get: function (mime, type, permissions) {
- var actions = this.getActions(mime, type, permissions);
+ get: function(mime, type, permissions, filename) {
+ var actions = this.getActions(mime, type, permissions, filename);
var filteredActions = {};
$.each(actions, function (name, action) {
filteredActions[name] = action.action;
@@ -209,10 +211,11 @@
* @param {string} mime mime type
* @param {string} type "dir" or "file"
* @param {int} permissions permissions
+ * @param {string} filename filename
*
* @return {Array.<OCA.Files.FileAction>} array of action specs
*/
- getActions: function (mime, type, permissions) {
+ getActions: function(mime, type, permissions, filename) {
var actions = {};
if (this.actions.all) {
actions = $.extend(actions, this.actions.all);
@@ -231,15 +234,29 @@
actions = $.extend(actions, this.actions[mime]);
}
}
+
var filteredActions = {};
- $.each(actions, function (name, action) {
- if ((action.permissions === OC.PERMISSION_NONE) || (action.permissions & permissions)) {
+ var self = this;
+ $.each(actions, function(name, action) {
+ if (self.allowedPermissions(action.permissions, permissions) &&
+ self.allowedFilename(action.filename, filename)) {
filteredActions[name] = action;
}
});
+
return filteredActions;
},
+
+ allowedPermissions: function(actionPermissions, permissions) {
+ return (actionPermissions === OC.PERMISSION_NONE || (actionPermissions & permissions));
+ },
+
+ allowedFilename: function(actionFilename, filename) {
+ return (!filename || filename === '' || !actionFilename
+ || actionFilename === '' || actionFilename === filename);
+ },
+
/**
* Returns the default file action handler for the given conditions
*
@@ -470,7 +487,8 @@
var actions = this.get(
fileInfoModel.get('mimetype'),
fileInfoModel.isDirectory() ? 'dir' : 'file',
- fileInfoModel.get('permissions')
+ fileInfoModel.get('permissions'),
+ fileInfoModel.get('name')
);
if (actionName) {
@@ -528,7 +546,8 @@
var actions = this.getActions(
this.getCurrentMimeType(),
this.getCurrentType(),
- this.getCurrentPermissions()
+ this.getCurrentPermissions(),
+ this.getCurrentFile()
);
var nameLinks;
if ($tr.data('renaming')) {
@@ -673,11 +692,11 @@
if (type === OC.dialogs.FILEPICKER_TYPE_COPY) {
context.fileList.copy(filename, targetPath, false, context.dir);
}
- if (type === OC.dialogs.FILEPICKER_TYPE_MOVE) {
- context.fileList.move(filename, targetPath, false, context.dir);
- }
- context.fileList.dirInfo.dirLastCopiedTo = targetPath;
- }, false, "httpd/unix-directory", true, actions, dialogDir);
+ if (type === OC.dialogs.FILEPICKER_TYPE_MOVE) {
+ context.fileList.move(filename, targetPath, false, context.dir);
+ }
+ context.fileList.dirInfo.dirLastCopiedTo = targetPath;
+ }, false, "httpd/unix-directory", true, actions, dialogDir);
}
});
@@ -777,6 +796,7 @@
* display name string for the action, or function that returns the display name.
* Defaults to the name given in name property
* @property {String} mime mime type
+ * @property {String} filename filename
* @property {int} permissions permissions
* @property {(Function|String)} icon icon path to the icon or function that returns it (deprecated, use iconClass instead)
* @property {(String|OCA.Files.FileActions~iconClassFunction)} iconClass class name of the icon (recommended for theming)