Skip to content

Commit 1f48f6c

Browse files
authored
Merge pull request #312 from nextcloud/files-other-lists-goto
Add "goto" links for files in non-default file lists
2 parents 1c55340 + 8761b20 commit 1f48f6c

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed

apps/files/js/filelist.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,7 @@
13871387
return;
13881388
}
13891389
this._setCurrentDir(targetDir, changeUrl, fileId);
1390-
this.reload().then(function(success){
1390+
return this.reload().then(function(success){
13911391
if (!success) {
13921392
self.changeDirectory(currentDir, true);
13931393
}

apps/files/js/gotoplugin.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright (c) 2016 Robin Appelman <[email protected]>
3+
*
4+
* This file is licensed under the Affero General Public License version 3
5+
* or later.
6+
*
7+
* See the COPYING-README file.
8+
*
9+
*/
10+
11+
12+
(function (OCA) {
13+
14+
OCA.Files = OCA.Files || {};
15+
16+
/**
17+
* @namespace OCA.Files.GotoPlugin
18+
*
19+
*/
20+
OCA.Files.GotoPlugin = {
21+
name: 'Goto',
22+
23+
disallowedLists: [
24+
'files',
25+
'trashbin'
26+
],
27+
28+
attach: function (fileList) {
29+
if (this.disallowedLists.indexOf(fileList.id) !== -1) {
30+
return;
31+
}
32+
var fileActions = fileList.fileActions;
33+
34+
fileActions.registerAction({
35+
name: 'Goto',
36+
displayName: t('files', 'View in folder'),
37+
mime: 'all',
38+
permissions: OC.PERMISSION_ALL,
39+
iconClass: 'icon-goto nav-icon-extstoragemounts',
40+
type: OCA.Files.FileActions.TYPE_DROPDOWN,
41+
actionHandler: function (fileName, context) {
42+
var fileModel = context.fileInfoModel;
43+
OCA.Files.App.setActiveView('files', {silent: true});
44+
OCA.Files.App.fileList.changeDirectory(fileModel.get('path'), true, true).then(function() {
45+
OCA.Files.App.fileList.scrollTo(fileModel.get('name'));
46+
});
47+
},
48+
render: function (actionSpec, isDefault, context) {
49+
return fileActions._defaultRenderAction.call(fileActions, actionSpec, isDefault, context)
50+
.removeClass('permanent');
51+
}
52+
});
53+
}
54+
};
55+
})(OCA);
56+
57+
OC.Plugins.register('OCA.Files.FileList', OCA.Files.GotoPlugin);
58+

apps/files/lib/Controller/ViewController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ public function index($dir = '', $view = '', $fileid = null) {
171171

172172
\OCP\Util::addScript('files', 'favoritesfilelist');
173173
\OCP\Util::addScript('files', 'tagsplugin');
174+
\OCP\Util::addScript('files', 'gotoplugin');
174175
\OCP\Util::addScript('files', 'favoritesplugin');
175176

176177
\OCP\Util::addScript('files', 'detailfileinfoview');

0 commit comments

Comments
 (0)