Prevent attempts to select directories as files in the file dialogue. Fixes #2937

This commit is contained in:
Murtuza Zabuawala 2017-12-13 15:35:08 +00:00 committed by Dave Page
parent c5d1fc8189
commit 96a2987ef6
3 changed files with 29 additions and 22 deletions

View File

@ -1102,7 +1102,9 @@ class Filemanager(object):
# Remove root storage path from error message
# when running in Server mode
if not status and not current_app.PGADMIN_RUNTIME:
err_msg = err_msg.replace(get_storage_directory(), '')
storage_directory = get_storage_directory()
if storage_directory:
err_msg = err_msg.replace(storage_directory, '')
return status, err_msg, is_binary, is_startswith_bom, enc

View File

@ -1026,8 +1026,8 @@ var getFolderInfo = function(path, file_type) {
var path = $('td:first-child', this).attr('title');
if (path.lastIndexOf('/') == path.length - 1 || path.lastIndexOf('\\') == path.length - 1) {
$('.file_manager_ok').removeClass('disabled');
$('.file_manager_ok').attr('disabled', false);
$('.file_manager_ok').addClass('disabled');
$('.file_manager_ok').attr('disabled', true);
$('.file_manager button.download').attr('disabled', 'disabled');
$('.file_manager button.delete, .file_manager button.rename').attr('disabled', 'disabled');
getFolderInfo(path);
@ -1133,9 +1133,9 @@ pgAdmin.FileUtils = {
var select_box = "<div class='change_file_types'>" +
gettext("Show hidden files and folders") +
"? <input type='checkbox' id='show_hidden' onclick='pgAdmin.FileUtils.handleClick(this)'>" +
"? <input type='checkbox' id='show_hidden' onclick='pgAdmin.FileUtils.handleClick(this)' tabindex='11'>" +
"<span></span>" +
"<select name='type'>";
"<select name='type' tabindex='12'>";
while(i < types_len) {
t = allowed_types[i];
@ -1315,7 +1315,6 @@ pgAdmin.FileUtils = {
check_obj = function(path, check) {
var path = decodeURI(path);
if (path.lastIndexOf('/') == path.length - 1 || path.lastIndexOf('\\') == path.length - 1) {
if (
has_capability(self.data_cap, 'select_folder')
@ -1417,12 +1416,12 @@ pgAdmin.FileUtils = {
// we remove simple file upload element
$('.file-input-container').remove();
$('.upload').remove();
$( ".create" ).before( '<button value="Upload" type="button" title="Upload File" name="upload" id="upload" class="btn fa fa-upload upload"><span></span></button> ' );
$( ".create" ).before( '<button value="Upload" type="button" title="Upload File" name="upload" id="upload" class="btn fa fa-upload upload" tabindex="6"><span></span></button> ' );
$('#uploader .upload').unbind().click(function() {
// we create prompt
var msg = '<div id="dropzone-container">' +
'<button class="fa fa-times dz_cross_btn"></button>' +
'<button class="fa fa-times dz_cross_btn" tabindex="7"></button>' +
'<div id="multiple-uploads" class="dropzone"></div>' +
'<div class="prompt-info">' + lg.file_size_limit +
config.upload.fileSizeLimit + ' ' + lg.mb + '.</div>',

View File

@ -6,28 +6,33 @@
<div class="file_manager">
<div id="uploader" class='col-xs-12'>
<div class="btn-group filemanager-path-group col-sm-7 col-xs-12" role="group">
<button name="home" type="button" value="Home" title="{{ _('Home') }}" class="fa fa-home btn home"><span></span>
<button name="home" type="button" value="Home" title="{{ _('Home') }}" class="fa fa-home btn home"
tabindex="1"><span></span>
</button>
<button name="level-up" type="button" title="{{ _('Back') }}" value="LevelUp" class="btn fa fa-level-up level-up"
disabled><span></span></button>
<input class='input-path' title='' type="text"/>
disabled tabindex="2"><span></span></button>
<input id='file-input-path' class='input-path' title='' type="text" tabindex="3" autofocus/>
</div>
<div class="btn-group filemanager-btn-group" role="group">
<div class="uploadresponse"></div>
<input class="mode" name="mode" type="hidden" value="add"/>
<input class="currentpath" name="currentpath" type="hidden"/>
<button type="button" title="{{ _('Refresh') }}" class="btn fa fa-refresh refresh"></button>
<button type="button" title="{{ _('Download File') }}" class="btn fa fa-download download" disabled><span></span>
<button type="button" title="{{ _('Refresh') }}" class="btn fa fa-refresh refresh"
tabindex="4"></button>
<button type="button" title="{{ _('Download File') }}" class="btn fa fa-download download"
disabled><span></span>
</button>
<button name="delete" type="button" title="{{ _('Delete File/Folder') }}" class="btn fa fa-trash delete" disabled>
<button name="delete" type="button" title="{{ _('Delete File/Folder') }}" class="btn fa fa-trash delete"
disabled>
<span></span></button>
<button name="rename" type="button" title="{{ _('Rename File/Folder') }}" class="btn fa fa-pencil-square-o rename">
<button name="rename" type="button" title="{{ _('Rename File/Folder') }}" class="btn fa fa-pencil-square-o rename"
tabindex="5">
<span></span></button>
<button name="newfolder" type="button" title="{{ _('Create new folder') }}" value="New Folder"
class="btn fa fa-folder-open create"><span></span></button>
<button class="ON fa fa-th btn grid" type="button" title="{{ _('View as grid') }}"><span></span></button>
<button type="button" class="btn fa fa-list list" title="{{ _('View as table') }}"><span></span></button>
class="btn fa fa-folder-open create" tabindex="8"><span></span></button>
<button class="ON fa fa-th btn grid" type="button" title="{{ _('View as grid') }}" tabindex="9"><span></span></button>
<button type="button" class="btn fa fa-list list" title="{{ _('View as table') }}" tabindex="10"><span></span></button>
</div>
</div>
<div class="fileinfo">
@ -41,15 +46,15 @@
<div class='delete_item'>
<span>{{ _('Are you sure you want to delete this item?') }}</span>
<span class="pull-right">
<button type='button' class='btn btn_yes'>{{ _('Yes') }}</button>
<button type='button' class='btn btn_no'>{{ _('No') }}</button>
<button type='button' class='btn btn_yes' tabindex="13">{{ _('Yes') }}</button>
<button type='button' class='btn btn_no' tabindex="14">{{ _('No') }}</button>
</span>
</div>
<div class='replace_file'>
<span>{{ _('Are you sure you want to replace this file?') }}</span>
<span class="pull-right">
<button type='button' class='btn btn_yes'>{{ _('Yes') }}</button>
<button type='button' class='btn btn_no'>{{ _('No') }}</button>
<button type='button' class='btn btn_yes' tabindex="15">{{ _('Yes') }}</button>
<button type='button' class='btn btn_no' tabindex="16">{{ _('No') }}</button>
</span>
</div>
</div>
@ -57,6 +62,7 @@
require(['sources/generated/file_utils'], function() {
pgAdmin.FileUtils.init();
});
setTimeout(function(){ $('#file-input-path').focus(); }, 1000);
</script>
</div>
</body>