diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2018-01-11 02:47:11 +0100 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2018-01-11 13:25:41 +0100 |
commit | 217b711dbb01500377d734e44d1e0cd5be25e500 (patch) | |
tree | 43ac1cc45897eee0350e1c66aff8e150da0226d9 | |
parent | 65bba286b6a2b6942839865216f6bcb332e3d1c7 (diff) | |
download | nextcloud-server-217b711dbb01500377d734e44d1e0cd5be25e500.tar.gz nextcloud-server-217b711dbb01500377d734e44d1e0cd5be25e500.zip |
Fix empty details view after renaming a file
"FileList._updateDetailsView" expects either a file name (as a string)
or a file model (as an "OCA.File.FileInfoModel"), but when called
through "updateInList" an "OC.Files.FileInfo" object was given instead.
As the given attribute was not a model "_updateDetailsView" treated it
as a file name and tried to get the model for that file, which failed
and caused the details view to be emptied.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
-rw-r--r-- | apps/files/js/filelist.js | 2 | ||||
-rw-r--r-- | apps/files/tests/js/filelistSpec.js | 30 |
2 files changed, 31 insertions, 1 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index bdd4a6ffc37..0359ccb7124 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -2071,7 +2071,7 @@ function updateInList(fileInfo) { self.updateRow(tr, fileInfo); - self._updateDetailsView(fileInfo, false); + self._updateDetailsView(fileInfo.name, false); } // TODO: too many nested blocks, move parts into functions diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js index 3442e794f05..7ae01195b11 100644 --- a/apps/files/tests/js/filelistSpec.js +++ b/apps/files/tests/js/filelistSpec.js @@ -651,6 +651,36 @@ describe('OCA.Files.FileList tests', function() { expect(notificationStub.calledOnce).toEqual(true); }); + it('Shows renamed file details if rename ajax call suceeded', function() { + fileList.showDetailsView('One.txt'); + + expect($('#app-sidebar').hasClass('disappear')).toEqual(false); + expect(fileList._detailsView.getFileInfo().get('id')).toEqual(1); + expect(fileList._detailsView.getFileInfo().get('name')).toEqual('One.txt'); + + doRename(); + + deferredRename.resolve(201); + + expect($('#app-sidebar').hasClass('disappear')).toEqual(false); + expect(fileList._detailsView.getFileInfo().get('id')).toEqual(1); + expect(fileList._detailsView.getFileInfo().get('name')).toEqual('Tu_after_three.txt'); + }); + it('Shows again file details if rename ajax call failed', function() { + fileList.showDetailsView('One.txt'); + + expect($('#app-sidebar').hasClass('disappear')).toEqual(false); + expect(fileList._detailsView.getFileInfo().get('id')).toEqual(1); + expect(fileList._detailsView.getFileInfo().get('name')).toEqual('One.txt'); + + doRename(); + + deferredRename.reject(403); + + expect($('#app-sidebar').hasClass('disappear')).toEqual(false); + expect(fileList._detailsView.getFileInfo().get('id')).toEqual(1); + expect(fileList._detailsView.getFileInfo().get('name')).toEqual('One.txt'); + }); it('Correctly updates file link after rename', function() { var $tr; doRename(); |