Skip to content

Commit d415c65

Browse files
committed
Add edit locally file action
Signed-off-by: Christopher Ng <chrng8@gmail.com>
1 parent ea08fab commit d415c65

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

apps/files/js/fileactions.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,30 @@
710710
}
711711
});
712712

713+
this.registerAction({
714+
name: 'EditLocally',
715+
displayName: function(context) {
716+
var locked = context.$file.data('locked');
717+
if (!locked) {
718+
return t('files', 'Edit locally');
719+
}
720+
},
721+
mime: 'all',
722+
order: -23,
723+
iconClass: function(filename, context) {
724+
var locked = context.$file.data('locked');
725+
if (!locked) {
726+
return 'icon-rename';
727+
}
728+
},
729+
permissions: OC.PERMISSION_UPDATE,
730+
actionHandler: function (filename, context) {
731+
var dir = context.dir || context.fileList.getCurrentDirectory();
732+
var path = dir === '/' ? dir + filename : dir + '/' + filename;
733+
context.fileList.openLocalClient(path);
734+
},
735+
});
736+
713737
this.registerAction({
714738
name: 'Open',
715739
mime: 'dir',

apps/files/js/filelist.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2807,6 +2807,15 @@
28072807
});
28082808
},
28092809

2810+
openLocalClient: function(path) {
2811+
var scheme = 'nc://';
2812+
var command = 'open';
2813+
var uid = OC.getCurrentUser().uid;
2814+
var url = scheme + command + '/' + uid + '@' + window.location.host + (window.location.port ? `:${window.location.port}` : '') + OC.encodePath(path);
2815+
2816+
window.location.href = url;
2817+
},
2818+
28102819
/**
28112820
* Updates the given row with the given file info
28122821
*

0 commit comments

Comments
 (0)