]> source.dussan.org Git - nextcloud-server.git/commitdiff
Use actual file path on rename/delete
authorVincent Petry <pvince81@owncloud.com>
Fri, 6 Jun 2014 13:13:02 +0000 (15:13 +0200)
committerVincent Petry <pvince81@owncloud.com>
Fri, 6 Jun 2014 13:17:55 +0000 (15:17 +0200)
When renaming or deleting a file that is in a subdirectory, performing
the action from the sharing overview or another file list view, the
actual directory of the file must be used instead of the current
directory.

apps/files/js/fileactions.js
apps/files/js/filelist.js
apps/files/tests/js/fileactionsSpec.js
apps/files/tests/js/filelistSpec.js

index de02bf5e730c6d0efb8d4b65414ace6fd6c9ef3a..04078d257063b13723236446490efc54266222fa 100644 (file)
                        this.register('all', 'Delete', OC.PERMISSION_DELETE, function () {
                                return OC.imagePath('core', 'actions/delete');
                        }, function (filename, context) {
-                               context.fileList.do_delete(filename);
+                               context.fileList.do_delete(filename, context.dir);
                                $('.tipsy').remove();
                        });
 
index 4229988b171a52e3ef4fee652c0325370a17a357..c291c560589c3d9106f888fc975d98317f5c06db 100644 (file)
                                                $.ajax({
                                                        url: OC.filePath('files','ajax','rename.php'),
                                                        data: {
-                                                               dir : self.getCurrentDirectory(),
+                                                               dir : tr.attr('data-path') || self.getCurrentDirectory(),
                                                                newname: newName,
                                                                file: oldname
                                                        },
index 490594a17739f274c7fa6bfa3c1c485a3f618d42..355761afa0115023bdcf3b53257fe791e793c496 100644 (file)
@@ -140,6 +140,7 @@ describe('OCA.Files.FileActions tests', function() {
                        id: 18,
                        type: 'file',
                        name: 'testName.txt',
+                       path: '/somepath/dir',
                        mimetype: 'text/plain',
                        size: '1234',
                        etag: 'a01234c',
@@ -151,6 +152,8 @@ describe('OCA.Files.FileActions tests', function() {
                $tr.find('.action.delete').click();
 
                expect(deleteStub.calledOnce).toEqual(true);
+               expect(deleteStub.getCall(0).args[0]).toEqual('testName.txt');
+               expect(deleteStub.getCall(0).args[1]).toEqual('/somepath/dir');
                deleteStub.restore();
        });
        it('passes context to action handler', function() {
index 7d3bc946dd3a6793375a0988b4ea001b4c86361b..e1a374146fe12455beb87d810533d7480b2d92af 100644 (file)
@@ -485,7 +485,9 @@ describe('OCA.Files.FileList tests', function() {
                        var $input, request;
 
                        for (var i = 0; i < testFiles.length; i++) {
-                               fileList.add(testFiles[i], {silent: true});
+                               var file = testFiles[i];
+                               file.path = '/some/subdir';
+                               fileList.add(file, {silent: true});
                        }
 
                        // trigger rename prompt
@@ -498,7 +500,7 @@ describe('OCA.Files.FileList tests', function() {
                        expect(fakeServer.requests.length).toEqual(1);
                        request = fakeServer.requests[0];
                        expect(request.url.substr(0, request.url.indexOf('?'))).toEqual(OC.webroot + '/index.php/apps/files/ajax/rename.php');
-                       expect(OC.parseQueryString(request.url)).toEqual({'dir': '/subdir', newname: 'Tu_after_three.txt', file: 'One.txt'});
+                       expect(OC.parseQueryString(request.url)).toEqual({'dir': '/some/subdir', newname: 'Tu_after_three.txt', file: 'One.txt'});
                }
                it('Inserts renamed file entry at correct position if rename ajax call suceeded', function() {
                        doRename();