summaryrefslogtreecommitdiffstats
path: root/apps/files
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-05-21 12:54:34 +0200
committerVincent Petry <pvince81@owncloud.com>2014-05-30 10:06:29 +0200
commit1d9129eac35b49a4e8d0d642a68d7d634f31c905 (patch)
tree513bdd46bb2e557bbac678aff73d1766b8e3c9c6 /apps/files
parent6fbf4d8548133dff4419e5e2e0c649f49e177669 (diff)
downloadnextcloud-server-1d9129eac35b49a4e8d0d642a68d7d634f31c905.tar.gz
nextcloud-server-1d9129eac35b49a4e8d0d642a68d7d634f31c905.zip
Sharing overview fixes and unit tests
- Fixed renaming and fileActionsReady event - Added unit tests for shares list - Fixed public page with defer - Fixed file actions in sharing overview - Fixed sharing counterpart list (10 entries max) - Fixed file path attribute to be used in download action - Fix sharing list headers - OC.Share icons now operate on fileList instance - Fix OC.Share.updateIcon when more than one list in DOM
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/js/app.js8
-rw-r--r--apps/files/js/fileactions.js15
-rw-r--r--apps/files/js/filelist.js19
-rw-r--r--apps/files/tests/js/fileactionsSpec.js29
-rw-r--r--apps/files/tests/js/filelistSpec.js2
5 files changed, 58 insertions, 15 deletions
diff --git a/apps/files/js/app.js b/apps/files/js/app.js
index 6ccf5135000..71802948a5c 100644
--- a/apps/files/js/app.js
+++ b/apps/files/js/app.js
@@ -73,6 +73,14 @@
},
/**
+ * Returns the view id of the currently active view
+ * @return view id
+ */
+ getActiveView: function() {
+ return this.navigation.getActiveItem();
+ },
+
+ /**
* Setup events based on URL changes
*/
_setupEvents: function() {
diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js
index 8cee037e294..3df62f37518 100644
--- a/apps/files/js/fileactions.js
+++ b/apps/files/js/fileactions.js
@@ -232,7 +232,7 @@
}
if (triggerEvent){
- fileList.$fileList.trigger(jQuery.Event("fileActionsReady"));
+ fileList.$fileList.trigger(jQuery.Event("fileActionsReady", {fileList: fileList}));
}
},
getCurrentFile: function () {
@@ -252,8 +252,6 @@
* Register the actions that are used by default for the files app.
*/
registerDefaultActions: function() {
- // TODO: try to find a way to not make it depend on fileList,
- // maybe get a handler or listener to trigger events on
this.register('all', 'Delete', OC.PERMISSION_DELETE, function () {
return OC.imagePath('core', 'actions/delete');
}, function (filename, context) {
@@ -287,7 +285,8 @@
this.register(downloadScope, 'Download', OC.PERMISSION_READ, function () {
return OC.imagePath('core', 'actions/download');
}, function (filename, context) {
- var url = context.fileList.getDownloadUrl(filename, context.fileList.getCurrentDirectory());
+ var dir = context.dir || context.fileList.getCurrentDirectory();
+ var url = context.fileList.getDownloadUrl(filename, dir);
if (url) {
OC.redirect(url);
}
@@ -309,11 +308,13 @@
// through window.FileActions will be limited to the main file list.
window.FileActions = OCA.Files.legacyFileActions;
window.FileActions.register = function (mime, name, permissions, icon, action, displayName) {
- console.warn('FileActions.register() is deprecated, please use OCA.Files.fileActions.register() instead');
- OCA.Files.FileActions.prototype.register.call(window.FileActions, mime, name, permissions, icon, action, displayName);
+ console.warn('FileActions.register() is deprecated, please use OCA.Files.fileActions.register() instead', arguments);
+ OCA.Files.FileActions.prototype.register.call(
+ window.FileActions, mime, name, permissions, icon, action, displayName
+ );
};
window.FileActions.setDefault = function (mime, name) {
- console.warn('FileActions.setDefault() is deprecated, please use OCA.Files.fileActions.setDefault() instead');
+ console.warn('FileActions.setDefault() is deprecated, please use OCA.Files.fileActions.setDefault() instead', mime, name);
OCA.Files.FileActions.prototype.setDefault.call(window.FileActions, mime, name);
};
})();
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 52d4c8ba3fe..68b22207144 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -508,7 +508,7 @@
this.$el.find('thead').after(this.$fileList);
this.updateEmptyContent();
- this.$fileList.trigger(jQuery.Event("fileActionsReady"));
+ this.$fileList.trigger($.Event('fileActionsReady', {fileList: this}));
this.fileSummary.calculate(filesArray);
@@ -530,7 +530,7 @@
type = fileData.type || 'file',
mtime = parseInt(fileData.mtime, 10) || new Date().getTime(),
mime = fileData.mimetype,
- path = fileData.path || this.getCurrentDirectory(),
+ path = fileData.path,
linkUrl;
options = options || {};
@@ -550,6 +550,13 @@
"data-permissions": fileData.permissions || this.getDirectoryPermissions()
});
+ if (!_.isUndefined(path)) {
+ tr.attr('data-path', path);
+ }
+ else {
+ path = this.getCurrentDirectory();
+ }
+
if (type === 'dir') {
// use default folder icon
icon = icon || OC.imagePath('core', 'filetypes/folder');
@@ -1224,16 +1231,16 @@
// reinsert row
self.files.splice(tr.index(), 1);
tr.remove();
- self.add(fileInfo, {updateSummary: false});
- self.$fileList.trigger($.Event('fileActionsReady'));
+ self.add(fileInfo, {updateSummary: false, silent: true});
+ self.$fileList.trigger($.Event('fileActionsReady', {fileList: self}));
}
});
} else {
// add back the old file info when cancelled
self.files.splice(tr.index(), 1);
tr.remove();
- self.add(oldFileInfo, {updateSummary: false});
- self.$fileList.trigger($.Event('fileActionsReady'));
+ self.add(oldFileInfo, {updateSummary: false, silent: true});
+ self.$fileList.trigger($.Event('fileActionsReady', {fileList: self}));
}
} catch (error) {
input.attr('title', error);
diff --git a/apps/files/tests/js/fileactionsSpec.js b/apps/files/tests/js/fileactionsSpec.js
index fa634da08a2..490594a1773 100644
--- a/apps/files/tests/js/fileactionsSpec.js
+++ b/apps/files/tests/js/fileactionsSpec.js
@@ -104,7 +104,34 @@ describe('OCA.Files.FileActions tests', function() {
$tr.find('.action-download').click();
expect(redirectStub.calledOnce).toEqual(true);
- expect(redirectStub.getCall(0).args[0]).toEqual(OC.webroot + '/index.php/apps/files/ajax/download.php?dir=%2Fsubdir&files=testName.txt');
+ expect(redirectStub.getCall(0).args[0]).toEqual(
+ OC.webroot +
+ '/index.php/apps/files/ajax/download.php' +
+ '?dir=%2Fsubdir&files=testName.txt');
+ redirectStub.restore();
+ });
+ it('takes the file\'s path into account when clicking download', function() {
+ var redirectStub = sinon.stub(OC, 'redirect');
+ var fileData = {
+ id: 18,
+ type: 'file',
+ name: 'testName.txt',
+ path: '/anotherpath/there',
+ mimetype: 'text/plain',
+ size: '1234',
+ etag: 'a01234c',
+ mtime: '123456'
+ };
+ var $tr = fileList.add(fileData);
+ FileActions.display($tr.find('td.filename'), true, fileList);
+
+ $tr.find('.action-download').click();
+
+ expect(redirectStub.calledOnce).toEqual(true);
+ expect(redirectStub.getCall(0).args[0]).toEqual(
+ OC.webroot + '/index.php/apps/files/ajax/download.php' +
+ '?dir=%2Fanotherpath%2Fthere&files=testName.txt'
+ );
redirectStub.restore();
});
it('deletes file when clicking delete', function() {
diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js
index a197fd5722c..3e9950dfe19 100644
--- a/apps/files/tests/js/filelistSpec.js
+++ b/apps/files/tests/js/filelistSpec.js
@@ -483,7 +483,7 @@ describe('OCA.Files.FileList tests', function() {
var $input, request;
for (var i = 0; i < testFiles.length; i++) {
- fileList.add(testFiles[i]);
+ fileList.add(testFiles[i], {silent: true});
}
// trigger rename prompt