]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add edit locally file action 34171/head
authorChristopher Ng <chrng8@gmail.com>
Tue, 20 Sep 2022 19:43:34 +0000 (19:43 +0000)
committerChristopher Ng <chrng8@gmail.com>
Tue, 20 Sep 2022 19:43:34 +0000 (19:43 +0000)
Signed-off-by: Christopher Ng <chrng8@gmail.com>
apps/files/js/fileactions.js
apps/files/js/filelist.js

index f342f21a4fb5c80e67c9147abec09139a377e573..4525da876e355c518c2ec2a92b36411e80dd663a 100644 (file)
                                }
                        });
 
+                       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',
index ee596dd417ecf30c00f24c3d5b86c1366499eb47..fff704b9283890bea0887563bdd761215b233c97 100644 (file)
                        });
                },
 
+               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
                 *