Merge pull request #19814 from owncloud/filelist-preventerrorwhennosidebar
Do not register sidebar panels when no sidebar
This commit is contained in:
commit
e4528c3bf7
3 changed files with 49 additions and 6 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -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"';
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue