diff options
author | Azul <azul@riseup.net> | 2020-04-06 09:41:36 +0200 |
---|---|---|
committer | Azul <azul@riseup.net> | 2020-04-08 18:19:58 +0200 |
commit | d2728cbdc13e89f11dc2b8c48b6148d6e89d0c83 (patch) | |
tree | 38decca5dc041c9f31d2233f4b6d13cd87549d9c /apps/files | |
parent | cb2b38516f2a5e98400e5ed2cbcd17ceeb269b9b (diff) | |
download | nextcloud-server-d2728cbdc13e89f11dc2b8c48b6148d6e89d0c83.tar.gz nextcloud-server-d2728cbdc13e89f11dc2b8c48b6148d6e89d0c83.zip |
refactor: fileActions.getCurrentDefaultFileAction()
fileActions.getCurrentDefaultFileAction() returns the default file action
for the currently selected file.
There were a number of places querying for the mime, type and permissions
of that file first to then query for the default action.
Signed-off-by: Azul <azul@riseup.net>
Diffstat (limited to 'apps/files')
-rw-r--r-- | apps/files/js/fileactions.js | 15 | ||||
-rw-r--r-- | apps/files/js/fileactionsmenu.js | 6 | ||||
-rw-r--r-- | apps/files/js/filelist.js | 9 |
3 files changed, 18 insertions, 12 deletions
diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js index 24f8279116d..404b6f1877e 100644 --- a/apps/files/js/fileactions.js +++ b/apps/files/js/fileactions.js @@ -257,13 +257,26 @@ }, /** + * Returns the default file action handler for the current file + * + * @return {OCA.Files.FileActions~actionSpec} action spec + * @since 8.2 + */ + getCurrentDefaultFileAction: function() { + var mime = this.getCurrentMimeType(); + var type = this.getCurrentType(); + var permissions = this.getCurrentPermissions(); + return this.getDefaultFileAction(mime,type, permissions); + }, + + /** * Returns the default file action handler for the given conditions * * @param {string} mime mime type * @param {string} type "dir" or "file" * @param {int} permissions permissions * - * @return {OCA.Files.FileActions~actionHandler} action handler + * @return {OCA.Files.FileActions~actionSpec} action spec * @since 8.2 */ getDefaultFileAction: function(mime, type, permissions) { diff --git a/apps/files/js/fileactionsmenu.js b/apps/files/js/fileactionsmenu.js index 16c4cc0d784..53dec693c1c 100644 --- a/apps/files/js/fileactionsmenu.js +++ b/apps/files/js/fileactionsmenu.js @@ -77,11 +77,7 @@ fileActions.getCurrentPermissions() ); - var defaultAction = fileActions.getDefaultFileAction( - fileActions.getCurrentMimeType(), - fileActions.getCurrentType(), - fileActions.getCurrentPermissions() - ); + var defaultAction = fileActions.getCurrentDefaultFileAction(); var items = _.filter(actions, function(actionSpec) { return !defaultAction || actionSpec.name !== defaultAction.name; diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 9973c92c8ec..ce428064337 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -892,13 +892,10 @@ event.preventDefault(); } else if (!renaming) { this.fileActions.currentFile = $tr.find('td'); - var mime = this.fileActions.getCurrentMimeType(); - var type = this.fileActions.getCurrentType(); - var permissions = this.fileActions.getCurrentPermissions(); - var action = this.fileActions.getDefault(mime,type, permissions); - if (action) { + var spec = this.fileActions.getCurrentDefaultFileAction(); + if (spec && spec.action) { event.preventDefault(); - action(filename, { + spec.action(filename, { $file: $tr, fileList: this, fileActions: this.fileActions, |