summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJulius Härtl <github@jus.li>2018-01-11 12:27:07 +0100
committerGitHub <noreply@github.com>2018-01-11 12:27:07 +0100
commit7de3cced7a4d137ee0eeaecf7d5a1010c5589369 (patch)
tree6261459b97de43c5bda58ad91098e45543dbaec5 /apps
parent7e48344eb145f79602ace8d0210d49a57de8ed00 (diff)
parentdab4a70bcf75878cf1542d010f5894e5c7e272ea (diff)
downloadnextcloud-server-7de3cced7a4d137ee0eeaecf7d5a1010c5589369.tar.gz
nextcloud-server-7de3cced7a4d137ee0eeaecf7d5a1010c5589369.zip
Merge pull request #7783 from nextcloud/fix-empty-details-view-after-renaming-a-file
Fix empty details view after renaming a file
Diffstat (limited to 'apps')
-rw-r--r--apps/files/js/filelist.js2
-rw-r--r--apps/files/tests/js/filelistSpec.js49
2 files changed, 37 insertions, 14 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 7a4ea492752..e50b402dea8 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -2266,7 +2266,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 fc5a6c18f95..08da15b8a88 100644
--- a/apps/files/tests/js/filelistSpec.js
+++ b/apps/files/tests/js/filelistSpec.js
@@ -612,6 +612,12 @@ describe('OCA.Files.FileList tests', function() {
beforeEach(function() {
deferredRename = $.Deferred();
renameStub = sinon.stub(filesClient, 'move').returns(deferredRename.promise());
+
+ for (var i = 0; i < testFiles.length; i++) {
+ var file = testFiles[i];
+ file.path = '/some/subdir';
+ fileList.add(file, {silent: true});
+ }
});
afterEach(function() {
renameStub.restore();
@@ -619,9 +625,6 @@ describe('OCA.Files.FileList tests', function() {
function doCancelRename() {
var $input;
- for (var i = 0; i < testFiles.length; i++) {
- fileList.add(testFiles[i]);
- }
// trigger rename prompt
fileList.rename('One.txt');
@@ -636,12 +639,6 @@ describe('OCA.Files.FileList tests', function() {
function doRename() {
var $input;
- for (var i = 0; i < testFiles.length; i++) {
- var file = testFiles[i];
- file.path = '/some/subdir';
- fileList.add(file, {silent: true});
- }
-
// trigger rename prompt
fileList.rename('One.txt');
$input = fileList.$fileList.find('input.filename');
@@ -677,6 +674,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();
@@ -731,10 +758,6 @@ describe('OCA.Files.FileList tests', function() {
it('Validates the file name', function() {
var $input, $tr;
- for (var i = 0; i < testFiles.length; i++) {
- fileList.add(testFiles[i], {silent: true});
- }
-
$tr = fileList.findFileEl('One.txt');
expect($tr.find('a.name').css('display')).not.toEqual('none');