summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-10-15 19:59:37 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2015-10-15 19:59:37 +0200
commite4528c3bf7cbf9627b8b05e3012aff867537d3c0 (patch)
treed2a073c3cfc4141d6a24fa6ac6a84f7327010aa4 /apps
parent08cc60acbae3d8ca2372fa7198a4a1d0c197cd74 (diff)
parent204b3ca189b21c214a9d20595f60d4434de30757 (diff)
downloadnextcloud-server-e4528c3bf7cbf9627b8b05e3012aff867537d3c0.tar.gz
nextcloud-server-e4528c3bf7cbf9627b8b05e3012aff867537d3c0.zip
Merge pull request #19814 from owncloud/filelist-preventerrorwhennosidebar
Do not register sidebar panels when no sidebar
Diffstat (limited to 'apps')
-rw-r--r--apps/files/js/filelist.js8
-rw-r--r--apps/files/js/mainfileinfodetailview.js4
-rw-r--r--apps/files/tests/js/filelistSpec.js43
3 files changed, 49 insertions, 6 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 7ad2e1952e2..4f5fdf242d9 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -2614,14 +2614,18 @@
* Register a tab view to be added to all views
*/
registerTabView: function(tabView) {
- this._detailsView.addTabView(tabView);
+ if (this._detailsView) {
+ this._detailsView.addTabView(tabView);
+ }
},
/**
* Register a detail view to be added to all views
*/
registerDetailView: function(detailView) {
- this._detailsView.addDetailView(detailView);
+ if (this._detailsView) {
+ this._detailsView.addDetailView(detailView);
+ }
}
};
diff --git a/apps/files/js/mainfileinfodetailview.js b/apps/files/js/mainfileinfodetailview.js
index 4eaff7adc8f..abf7da52ff4 100644
--- a/apps/files/js/mainfileinfodetailview.js
+++ b/apps/files/js/mainfileinfodetailview.js
@@ -65,10 +65,10 @@
this._fileList = options.fileList;
this._fileActions = options.fileActions;
if (!this._fileList) {
- throw 'Missing requird parameter "fileList"';
+ throw 'Missing required parameter "fileList"';
}
if (!this._fileActions) {
- throw 'Missing requird parameter "fileActions"';
+ throw 'Missing required parameter "fileActions"';
}
},
diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js
index 96018917c85..994e1d32844 100644
--- a/apps/files/tests/js/filelistSpec.js
+++ b/apps/files/tests/js/filelistSpec.js
@@ -1879,15 +1879,54 @@ describe('OCA.Files.FileList tests', function() {
$tr2.find('td.filename .name').trigger(e);
expect(fileList.getSelectedFiles().length).toEqual(0);
});
- })
+ });
});
describe('Details sidebar', function() {
beforeEach(function() {
fileList.setFiles(testFiles);
fileList.showDetailsView('Two.jpg');
});
+ describe('registering', function() {
+ var addTabStub;
+ var addDetailStub;
+
+ beforeEach(function() {
+ addTabStub = sinon.stub(OCA.Files.DetailsView.prototype, 'addTabView');
+ addDetailStub = sinon.stub(OCA.Files.DetailsView.prototype, 'addDetailView');
+ });
+ afterEach(function() {
+ addTabStub.restore();
+ addDetailStub.restore();
+ });
+ it('forward the registered views to the underlying DetailsView', function() {
+ fileList.destroy();
+ fileList = new OCA.Files.FileList($('#app-content-files'), {
+ detailsViewEnabled: true
+ });
+ fileList.registerTabView(new OCA.Files.DetailTabView());
+ fileList.registerDetailView(new OCA.Files.DetailFileInfoView());
+
+ expect(addTabStub.calledOnce).toEqual(true);
+ // twice because the filelist already registers one by default
+ expect(addDetailStub.calledTwice).toEqual(true);
+ });
+ it('does not error when registering panels when not details view configured', function() {
+ fileList.destroy();
+ fileList = new OCA.Files.FileList($('#app-content-files'), {
+ detailsViewEnabled: false
+ });
+ fileList.registerTabView(new OCA.Files.DetailTabView());
+ fileList.registerDetailView(new OCA.Files.DetailFileInfoView());
+
+ expect(addTabStub.notCalled).toEqual(true);
+ expect(addDetailStub.notCalled).toEqual(true);
+ });
+ });
it('triggers file action when clicking on row if no details view configured', function() {
- fileList._detailsView = null;
+ fileList.destroy();
+ fileList = new OCA.Files.FileList($('#app-content-files'), {
+ detailsViewEnabled: false
+ });
var updateDetailsViewStub = sinon.stub(fileList, '_updateDetailsView');
var actionStub = sinon.stub();
fileList.setFiles(testFiles);