From: Christopher Ng Date: Tue, 20 Sep 2022 19:43:34 +0000 (+0000) Subject: Add edit locally file action X-Git-Tag: v25.0.0rc1~12^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d415c656f6b1815ab6a7229bc5268abd5ea97a57;p=nextcloud-server.git Add edit locally file action Signed-off-by: Christopher Ng --- diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js index f342f21a4fb..4525da876e3 100644 --- a/apps/files/js/fileactions.js +++ b/apps/files/js/fileactions.js @@ -710,6 +710,30 @@ } }); + this.registerAction({ + name: 'EditLocally', + displayName: function(context) { + var locked = context.$file.data('locked'); + if (!locked) { + return t('files', 'Edit locally'); + } + }, + mime: 'all', + order: -23, + iconClass: function(filename, context) { + var locked = context.$file.data('locked'); + if (!locked) { + return 'icon-rename'; + } + }, + permissions: OC.PERMISSION_UPDATE, + actionHandler: function (filename, context) { + var dir = context.dir || context.fileList.getCurrentDirectory(); + var path = dir === '/' ? dir + filename : dir + '/' + filename; + context.fileList.openLocalClient(path); + }, + }); + this.registerAction({ name: 'Open', mime: 'dir', diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index ee596dd417e..fff704b9283 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -2807,6 +2807,15 @@ }); }, + openLocalClient: function(path) { + var scheme = 'nc://'; + var command = 'open'; + var uid = OC.getCurrentUser().uid; + var url = scheme + command + '/' + uid + '@' + window.location.host + (window.location.port ? `:${window.location.port}` : '') + OC.encodePath(path); + + window.location.href = url; + }, + /** * Updates the given row with the given file info *