Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove legacy #dir element in files list #33373

Merged
merged 1 commit into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions apps/files/js/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@
* @param options.dragOptions drag options, disabled by default
* @param options.folderDropOptions folder drop options, disabled by default
* @param options.scrollTo name of file to scroll to after the first load
* @param [options.dir='/'] current directory
* @param {OC.Files.Client} [options.filesClient] files API client
* @param {OC.Backbone.Model} [options.filesConfig] files app configuration
* @private
Expand Down Expand Up @@ -414,6 +415,10 @@
});
}

if (!_.isUndefined(options.dir)) {
this._setCurrentDir(options.dir || '/', false);
}

if(options.openFile) {
// Wait for some initialisation process to be over before triggering the default action.
_.defer(() => {
Expand Down Expand Up @@ -2049,7 +2054,7 @@
* @return current directory
*/
getCurrentDirectory: function(){
return this._currentDirectory || this.$el.find('#dir').val() || '/';
return this._currentDirectory || '/';
},
/**
* Returns the directory permissions
Expand Down Expand Up @@ -2131,9 +2136,6 @@
}
this._currentDirectory = targetDir;

// legacy stuff
this.$el.find('#dir').val(targetDir);

if (changeUrl !== false) {
var params = {
dir: targetDir,
Expand Down
1 change: 0 additions & 1 deletion apps/files/templates/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
</tfoot>
</table>
<div class="filelist-footer"></div>
<input type="hidden" name="dir" id="dir" value="" />
<div class="hiddenuploadfield">
<input type="file" id="file_upload_start" class="hiddenuploadfield" name="files[]" />
</div>
Expand Down
2 changes: 0 additions & 2 deletions apps/files/templates/recentlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

<div class="emptyfilelist emptycontent hidden"></div>

<input type="hidden" name="dir" value="" id="dir">

<div class="nofilterresults emptycontent hidden">
<div class="icon-search"></div>
<h2><?php p($l->t('No entries found in this folder')); ?></h2>
Expand Down
2 changes: 0 additions & 2 deletions apps/files/templates/simplelist.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
<p><?php p($l->t('Files and folders you mark as favorite will show up here')); ?></p>
</div>

<input type="hidden" name="dir" value="" id="dir">

<div class="nofilterresults emptycontent hidden">
<div class="icon-search"></div>
<h2><?php p($l->t('No entries found in this folder')); ?></h2>
Expand Down
1 change: 0 additions & 1 deletion apps/files/tests/js/favoritesfilelistspec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ describe('OCA.Files.FavoritesFileList tests', function() {
$('#testArea').append(
'<div id="app-content-container">' +
// init horrible parameters
'<input type="hidden" id="dir" value="/"></input>' +
'<input type="hidden" id="permissions" value="31"></input>' +
// dummy controls
'<div class="files-controls">' +
Expand Down
4 changes: 2 additions & 2 deletions apps/files/tests/js/fileactionsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ describe('OCA.Files.FileActions tests', function() {
clock = sinon.useFakeTimers();
// init horrible parameters
var $body = $('#testArea');
$body.append('<input type="hidden" id="dir" value="/subdir"></input>');
$body.append('<input type="hidden" id="permissions" value="31"></input>');
$body.append('<table class="files-filestable list-container view-grid"><tbody class="files-fileList"></tbody></table>');
// dummy files table
Expand Down Expand Up @@ -66,13 +65,14 @@ describe('OCA.Files.FileActions tests', function() {
fileList = new OCA.Files.FileList($body, {
fileActions: fileActions
});
fileList.changeDirectory('/subdir', false, true);
});
afterEach(function() {
fileActions = null;
fileList.destroy();
fileList = undefined;
clock.restore();
$('#dir, #permissions, .files-filestable').remove();
$('#permissions, .files-filestable').remove();
});
it('calling clear() clears file actions', function() {
fileActions.clear();
Expand Down
4 changes: 2 additions & 2 deletions apps/files/tests/js/fileactionsmenuSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ describe('OCA.Files.FileActionsMenu tests', function() {
beforeEach(function() {
// init horrible parameters
var $body = $('#testArea');
$body.append('<input type="hidden" id="dir" value="/subdir"></input>');
$body.append('<input type="hidden" id="permissions" value="31"></input>');
// dummy files table
actionStub = sinon.stub();
fileActions = new OCA.Files.FileActions();
fileList = new OCA.Files.FileList($body, {
fileActions: fileActions
});
fileList.changeDirectory('/subdir', false, true);

fileActions.registerAction({
name: 'Testdropdown',
Expand Down Expand Up @@ -100,7 +100,7 @@ describe('OCA.Files.FileActionsMenu tests', function() {
fileList.destroy();
fileList = undefined;
menu.remove();
$('#dir, #permissions, .files-filestable').remove();
$('#permissions, .files-filestable').remove();
});

describe('rendering', function() {
Expand Down
30 changes: 15 additions & 15 deletions apps/files/tests/js/filelistSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ describe('OCA.Files.FileList tests', function() {
$('#testArea').append(
'<div id="app-content-files">' +
// init horrible parameters
'<input type="hidden" id="dir" value="/subdir"/>' +
'<input type="hidden" id="permissions" value="31"/>' +
// dummy controls
'<div class="files-controls">' +
Expand Down Expand Up @@ -186,6 +185,7 @@ describe('OCA.Files.FileList tests', function() {
fileList = new OCA.Files.FileList($('#app-content-files'), {
filesClient: filesClient,
config: filesConfig,
dir: '/subdir',
enableUpload: true,
multiSelectMenu: [{
name: 'copyMove',
Expand Down Expand Up @@ -218,7 +218,7 @@ describe('OCA.Files.FileList tests', function() {
});
describe('Getters', function() {
it('Returns the current directory', function() {
$('#dir').val('/one/two/three');
fileList.changeDirectory('/one/two/three', false, true);
expect(fileList.getCurrentDirectory()).toEqual('/one/two/three');
});
it('Returns the directory permissions as int', function() {
Expand Down Expand Up @@ -553,7 +553,7 @@ describe('OCA.Files.FileList tests', function() {
$summary = $('.files-filestable .summary');
expect($summary.hasClass('hidden')).toEqual(true);
expect($('.files-filestable thead th').hasClass('hidden')).toEqual(true);
expect($('.emptycontent').hasClass('hidden')).toEqual(false);
expect($('.emptyfilelist.emptycontent').hasClass('hidden')).toEqual(false);
expect(fileList.isEmpty).toEqual(true);
});
});
Expand Down Expand Up @@ -612,7 +612,7 @@ describe('OCA.Files.FileList tests', function() {
expect($summary.find('.filesize').text()).toEqual('57 KB');
expect(fileList.isEmpty).toEqual(false);
expect($('.files-filestable thead th').hasClass('hidden')).toEqual(false);
expect($('.emptycontent').hasClass('hidden')).toEqual(true);
expect($('.emptyfilelist.emptycontent').hasClass('hidden')).toEqual(true);

expect(notificationStub.notCalled).toEqual(true);
}).then(done, done);
Expand Down Expand Up @@ -682,7 +682,7 @@ describe('OCA.Files.FileList tests', function() {
expect(fileList.isEmpty).toEqual(true);
expect(fileList.files.length).toEqual(0);
expect($('.files-filestable thead th').hasClass('hidden')).toEqual(true);
expect($('.emptycontent').hasClass('hidden')).toEqual(false);
expect($('.emptyfilelist.emptycontent').hasClass('hidden')).toEqual(false);
}).then(done, done);
});
it('bring back deleted item when delete call failed', function(done) {
Expand Down Expand Up @@ -1143,22 +1143,22 @@ describe('OCA.Files.FileList tests', function() {
it('shows headers, summary and hide empty content message after setting files', function(){
fileList.setFiles(testFiles);
expect($('.files-filestable thead th').hasClass('hidden')).toEqual(false);
expect($('.emptycontent').hasClass('hidden')).toEqual(true);
expect($('.emptyfilelist.emptycontent').hasClass('hidden')).toEqual(true);
expect(fileList.$el.find('.summary').hasClass('hidden')).toEqual(false);
});
it('hides headers, summary and show empty content message after setting empty file list', function(){
fileList.setFiles([]);
expect($('.files-filestable thead th').hasClass('hidden')).toEqual(true);
expect($('.emptycontent').hasClass('hidden')).toEqual(false);
expect($('.emptycontent .uploadmessage').hasClass('hidden')).toEqual(false);
expect($('.emptyfilelist.emptycontent').hasClass('hidden')).toEqual(false);
expect($('.emptyfilelist.emptycontent .uploadmessage').hasClass('hidden')).toEqual(false);
expect(fileList.$el.find('.summary').hasClass('hidden')).toEqual(true);
});
it('hides headers, upload message, and summary when list is empty and user has no creation permission', function(){
$('#permissions').val(0);
fileList.setFiles([]);
expect($('.files-filestable thead th').hasClass('hidden')).toEqual(true);
expect($('.emptycontent').hasClass('hidden')).toEqual(false);
expect($('.emptycontent .uploadmessage').hasClass('hidden')).toEqual(true);
expect($('.emptyfilelist.emptycontent').hasClass('hidden')).toEqual(false);
expect($('.emptyfilelist.emptycontent .uploadmessage').hasClass('hidden')).toEqual(true);
expect(fileList.$el.find('.summary').hasClass('hidden')).toEqual(true);
});
it('calling findFileEl() can find existing file element', function() {
Expand All @@ -1170,7 +1170,7 @@ describe('OCA.Files.FileList tests', function() {
expect(fileList.findFileEl('unexist.dat').length).toEqual(0);
});
it('only add file if in same current directory', function() {
$('#dir').val('/current dir');
fileList.changeDirectory('/current dir', false, true);
var fileData = {
type: 'file',
name: 'testFile.txt',
Expand Down Expand Up @@ -1313,7 +1313,7 @@ describe('OCA.Files.FileList tests', function() {
expect(fileList.files).toEqual([]);
fileList.setFiles([]);
var $summary = $('.files-filestable .summary');
var $emptycontent = fileList.$el.find(".emptycontent");
var $emptycontent = fileList.$el.find(".emptyfilelist.emptycontent");
var $nofilterresults = fileList.$el.find(".nofilterresults");
expect($emptycontent.length).toEqual(1);
expect($nofilterresults.length).toEqual(1);
Expand Down Expand Up @@ -1343,7 +1343,7 @@ describe('OCA.Files.FileList tests', function() {
expect(fileList.files).toEqual([]);
fileList.showMask();
fileList.setFiles(testFiles);
var $emptycontent = fileList.$el.find(".emptycontent");
var $emptycontent = fileList.$el.find(".emptyfilelist.emptycontent");
var $nofilterresults = fileList.$el.find(".nofilterresults");
expect($emptycontent.length).toEqual(1);
expect($nofilterresults.length).toEqual(1);
Expand Down Expand Up @@ -1942,7 +1942,7 @@ describe('OCA.Files.FileList tests', function() {
.toEqual(OC.getRootPath() + '/remote.php/webdav/subdir/some%20file.txt');
expect(fileList.getDownloadUrl('some file.txt', '/anotherpath/abc'))
.toEqual(OC.getRootPath() + '/remote.php/webdav/anotherpath/abc/some%20file.txt');
$('#dir').val('/');
fileList.changeDirectory('/', false, true);
expect(fileList.getDownloadUrl('some file.txt'))
.toEqual(OC.getRootPath() + '/remote.php/webdav/some%20file.txt');
});
Expand Down Expand Up @@ -2346,7 +2346,7 @@ describe('OCA.Files.FileList tests', function() {
redirectStub.restore();
});
it('Downloads root folder when all selected in root folder', function() {
$('#dir').val('/');
fileList.changeDirectory('/', false, true);
$('.select-all').click();
$('.selectedActions .filesSelectMenu .download').click();
expect(redirectStub.calledOnce).toEqual(true);
Expand Down
2 changes: 1 addition & 1 deletion apps/files_external/js/statusmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ OCA.Files_External.StatusManager.Utils = {
isCorrectViewAndRootFolder: function () {
// correct views = files & extstoragemounts
if (OCA.Files.App.getActiveView() === 'files' || OCA.Files.App.getActiveView() === 'extstoragemounts') {
return OCA.Files.App.getCurrentAppContainer().find('#dir').val() === '/';
return OCA.Files.App.currentFileList.getCurrentDirectory() === '/';
}
return false;
},
Expand Down
2 changes: 0 additions & 2 deletions apps/files_external/templates/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
<h2><?php p($l->t('No external storage configured or you don\'t have the permission to configure them')); ?></h2>
</div>

<input type="hidden" name="dir" value="" id="dir">

<table class="files-filestable list-container <?php p($_['showgridview'] ? 'view-grid' : '') ?>">
<thead>
<tr>
Expand Down
1 change: 0 additions & 1 deletion apps/files_external/tests/js/mountsfilelistSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ describe('OCA.Files_External.FileList tests', function() {
$('#testArea').append(
'<div id="app-content-container">' +
// init horrible parameters
'<input type="hidden" id="dir" value="/"></input>' +
'<input type="hidden" id="permissions" value="31"></input>' +
// dummy controls
'<div class="files-controls">' +
Expand Down
3 changes: 2 additions & 1 deletion apps/files_sharing/js/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ OCA.Sharing.PublicApp = {
OCA.Files.fileActions = fileActions;

this._initialized = true;
this.initialDir = $('#dir').val();
var urlParams = OC.Util.History.parseUrlQuery();
this.initialDir = urlParams.path || '/';

var token = $('#sharingToken').val();
var hideDownload = $('#hideDownload').val();
Expand Down
2 changes: 0 additions & 2 deletions apps/files_sharing/templates/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

<div class="emptyfilelist emptycontent hidden"></div>

<input type="hidden" name="dir" value="" id="dir">

<div class="nofilterresults emptycontent hidden">
<div class="icon-search"></div>
<h2><?php p($l->t('No entries found in this folder')); ?></h2>
Expand Down
2 changes: 0 additions & 2 deletions apps/files_sharing/templates/public.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<input type="hidden" id="sharingUserId" value="<?php p($_['owner']) ?>">
<input type="hidden" id="filesApp" name="filesApp" value="1">
<input type="hidden" id="isPublic" name="isPublic" value="1">
<input type="hidden" name="dir" value="<?php p($_['dir']) ?>" id="dir">
<?php if (!$_['hideDownload']): ?>
<input type="hidden" name="downloadURL" value="<?php p($_['downloadURL']) ?>" id="downloadURL">
<?php endif; ?>
Expand Down Expand Up @@ -140,7 +139,6 @@ class="emptycontent <?php if (!empty($_['note'])) { ?>has-note<?php } ?>">
<?php } ?>

<?php if (!isset($_['hideFileList']) || (isset($_['hideFileList']) && $_['hideFileList'] !== true)): ?>
<input type="hidden" name="dir" id="dir" value="" />
<div class="hiddenuploadfield">
<input type="file" id="file_upload_start" class="hiddenuploadfield" name="files[]"
data-url="<?php p(\OC::$server->getURLGenerator()->linkTo('files', 'ajax/upload.php')); ?>" />
Expand Down
5 changes: 4 additions & 1 deletion apps/files_sharing/tests/js/publicAppSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ describe('OCA.Sharing.PublicApp tests', function() {
});

describe('File list', function() {
var parseUrlQueryStub
// TODO: this should be moved to a separate file once the PublicFileList is extracted from public.js
beforeEach(function() {
$preview.append(
'<div id="app-content-files">' +
// init horrible parameters
'<input type="hidden" id="dir" value="/subdir"/>' +
'<input type="hidden" id="permissions" value="31"/>' +
// dummy controls
'<div class="files-controls">' +
Expand Down Expand Up @@ -88,10 +88,13 @@ describe('OCA.Sharing.PublicApp tests', function() {
'</div>'
);

parseUrlQueryStub = sinon.stub(OC.Util.History, 'parseUrlQuery');
parseUrlQueryStub.returns({path: '/subdir'});
App.initialize($('#preview'));
});
afterEach(function() {
App._initialized = false;
parseUrlQueryStub.restore();
});

it('Uses public webdav endpoint', function() {
Expand Down
2 changes: 0 additions & 2 deletions apps/files_trashbin/templates/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
<p><?php p($l->t('You will be able to recover deleted files from here')); ?></p>
</div>

<input type="hidden" name="dir" value="" id="dir">

<div class="nofilterresults emptycontent hidden">
<div class="icon-search"></div>
<h2><?php p($l->t('No entries found in this folder')); ?></h2>
Expand Down
8 changes: 0 additions & 8 deletions apps/files_trashbin/tests/js/filelistSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ describe('OCA.Trashbin.FileList tests', function () {
// init parameters and test table elements
$('#testArea').append(
'<div id="app-content-trashbin">' +
// init horrible parameters
'<input type="hidden" id="dir" value="/"></input>' +
// set this but it shouldn't be used (could be the one from the
// files app)
'<input type="hidden" id="permissions" value="31"></input>' +
Expand Down Expand Up @@ -129,7 +127,6 @@ describe('OCA.Trashbin.FileList tests', function () {
fileList.destroy();
fileList = undefined;

$('#dir').remove();
notificationStub.restore();
alertStub.restore();
});
Expand Down Expand Up @@ -174,7 +171,6 @@ describe('OCA.Trashbin.FileList tests', function () {
describe('Rendering rows', function () {
it('renders rows with the correct data when in root', function () {
// dir listing is false when in root
$('#dir').val('/');
fileList.setFiles(testFiles);
var $rows = fileList.$el.find('tbody tr');
var $tr = $rows.eq(0);
Expand All @@ -195,7 +191,6 @@ describe('OCA.Trashbin.FileList tests', function () {
});
it('renders rows with the correct data when in root after calling setFiles with the same data set', function () {
// dir listing is false when in root
$('#dir').val('/');
fileList.setFiles(testFiles);
fileList.setFiles(fileList.files);
var $rows = fileList.$el.find('tbody tr');
Expand All @@ -216,9 +211,6 @@ describe('OCA.Trashbin.FileList tests', function () {
expect(fileList.findFileEl('One.txt.d11111')[0]).toEqual($tr[0]);
});
it('renders rows with the correct data when in subdirectory', function () {
// dir listing is true when in a subdir
$('#dir').val('/subdir');

fileList.setFiles(testFiles.map(function (file) {
file.name = file.displayName;
return file;
Expand Down
1 change: 0 additions & 1 deletion apps/systemtags/templates/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,4 @@
<tfoot>
</tfoot>
</table>
<input type="hidden" name="dir" id="dir" value="" />

Loading