mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Prevent attempts to select directories as files in the file dialogue. Fixes #2937
This commit is contained in:
parent
c5d1fc8189
commit
96a2987ef6
@ -1102,7 +1102,9 @@ class Filemanager(object):
|
|||||||
# Remove root storage path from error message
|
# Remove root storage path from error message
|
||||||
# when running in Server mode
|
# when running in Server mode
|
||||||
if not status and not current_app.PGADMIN_RUNTIME:
|
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
|
return status, err_msg, is_binary, is_startswith_bom, enc
|
||||||
|
|
||||||
|
@ -1026,8 +1026,8 @@ var getFolderInfo = function(path, file_type) {
|
|||||||
var path = $('td:first-child', this).attr('title');
|
var path = $('td:first-child', this).attr('title');
|
||||||
|
|
||||||
if (path.lastIndexOf('/') == path.length - 1 || path.lastIndexOf('\\') == path.length - 1) {
|
if (path.lastIndexOf('/') == path.length - 1 || path.lastIndexOf('\\') == path.length - 1) {
|
||||||
$('.file_manager_ok').removeClass('disabled');
|
$('.file_manager_ok').addClass('disabled');
|
||||||
$('.file_manager_ok').attr('disabled', false);
|
$('.file_manager_ok').attr('disabled', true);
|
||||||
$('.file_manager button.download').attr('disabled', 'disabled');
|
$('.file_manager button.download').attr('disabled', 'disabled');
|
||||||
$('.file_manager button.delete, .file_manager button.rename').attr('disabled', 'disabled');
|
$('.file_manager button.delete, .file_manager button.rename').attr('disabled', 'disabled');
|
||||||
getFolderInfo(path);
|
getFolderInfo(path);
|
||||||
@ -1133,9 +1133,9 @@ pgAdmin.FileUtils = {
|
|||||||
|
|
||||||
var select_box = "<div class='change_file_types'>" +
|
var select_box = "<div class='change_file_types'>" +
|
||||||
gettext("Show hidden files and folders") +
|
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>" +
|
"<span></span>" +
|
||||||
"<select name='type'>";
|
"<select name='type' tabindex='12'>";
|
||||||
|
|
||||||
while(i < types_len) {
|
while(i < types_len) {
|
||||||
t = allowed_types[i];
|
t = allowed_types[i];
|
||||||
@ -1315,7 +1315,6 @@ pgAdmin.FileUtils = {
|
|||||||
check_obj = function(path, check) {
|
check_obj = function(path, check) {
|
||||||
|
|
||||||
var path = decodeURI(path);
|
var path = decodeURI(path);
|
||||||
|
|
||||||
if (path.lastIndexOf('/') == path.length - 1 || path.lastIndexOf('\\') == path.length - 1) {
|
if (path.lastIndexOf('/') == path.length - 1 || path.lastIndexOf('\\') == path.length - 1) {
|
||||||
if (
|
if (
|
||||||
has_capability(self.data_cap, 'select_folder')
|
has_capability(self.data_cap, 'select_folder')
|
||||||
@ -1417,12 +1416,12 @@ pgAdmin.FileUtils = {
|
|||||||
// we remove simple file upload element
|
// we remove simple file upload element
|
||||||
$('.file-input-container').remove();
|
$('.file-input-container').remove();
|
||||||
$('.upload').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() {
|
$('#uploader .upload').unbind().click(function() {
|
||||||
// we create prompt
|
// we create prompt
|
||||||
var msg = '<div id="dropzone-container">' +
|
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 id="multiple-uploads" class="dropzone"></div>' +
|
||||||
'<div class="prompt-info">' + lg.file_size_limit +
|
'<div class="prompt-info">' + lg.file_size_limit +
|
||||||
config.upload.fileSizeLimit + ' ' + lg.mb + '.</div>',
|
config.upload.fileSizeLimit + ' ' + lg.mb + '.</div>',
|
||||||
|
@ -6,28 +6,33 @@
|
|||||||
<div class="file_manager">
|
<div class="file_manager">
|
||||||
<div id="uploader" class='col-xs-12'>
|
<div id="uploader" class='col-xs-12'>
|
||||||
<div class="btn-group filemanager-path-group col-sm-7 col-xs-12" role="group">
|
<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>
|
||||||
<button name="level-up" type="button" title="{{ _('Back') }}" value="LevelUp" class="btn fa fa-level-up level-up"
|
<button name="level-up" type="button" title="{{ _('Back') }}" value="LevelUp" class="btn fa fa-level-up level-up"
|
||||||
disabled><span></span></button>
|
disabled tabindex="2"><span></span></button>
|
||||||
<input class='input-path' title='' type="text"/>
|
<input id='file-input-path' class='input-path' title='' type="text" tabindex="3" autofocus/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="btn-group filemanager-btn-group" role="group">
|
<div class="btn-group filemanager-btn-group" role="group">
|
||||||
<div class="uploadresponse"></div>
|
<div class="uploadresponse"></div>
|
||||||
<input class="mode" name="mode" type="hidden" value="add"/>
|
<input class="mode" name="mode" type="hidden" value="add"/>
|
||||||
<input class="currentpath" name="currentpath" type="hidden"/>
|
<input class="currentpath" name="currentpath" type="hidden"/>
|
||||||
<button type="button" title="{{ _('Refresh') }}" class="btn fa fa-refresh refresh"></button>
|
<button type="button" title="{{ _('Refresh') }}" class="btn fa fa-refresh refresh"
|
||||||
<button type="button" title="{{ _('Download File') }}" class="btn fa fa-download download" disabled><span></span>
|
tabindex="4"></button>
|
||||||
|
<button type="button" title="{{ _('Download File') }}" class="btn fa fa-download download"
|
||||||
|
disabled><span></span>
|
||||||
</button>
|
</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>
|
<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>
|
<span></span></button>
|
||||||
<button name="newfolder" type="button" title="{{ _('Create new folder') }}" value="New Folder"
|
<button name="newfolder" type="button" title="{{ _('Create new folder') }}" value="New Folder"
|
||||||
class="btn fa fa-folder-open create"><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') }}"><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') }}"><span></span></button>
|
<button type="button" class="btn fa fa-list list" title="{{ _('View as table') }}" tabindex="10"><span></span></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="fileinfo">
|
<div class="fileinfo">
|
||||||
@ -41,15 +46,15 @@
|
|||||||
<div class='delete_item'>
|
<div class='delete_item'>
|
||||||
<span>{{ _('Are you sure you want to delete this item?') }}</span>
|
<span>{{ _('Are you sure you want to delete this item?') }}</span>
|
||||||
<span class="pull-right">
|
<span class="pull-right">
|
||||||
<button type='button' class='btn btn_yes'>{{ _('Yes') }}</button>
|
<button type='button' class='btn btn_yes' tabindex="13">{{ _('Yes') }}</button>
|
||||||
<button type='button' class='btn btn_no'>{{ _('No') }}</button>
|
<button type='button' class='btn btn_no' tabindex="14">{{ _('No') }}</button>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class='replace_file'>
|
<div class='replace_file'>
|
||||||
<span>{{ _('Are you sure you want to replace this file?') }}</span>
|
<span>{{ _('Are you sure you want to replace this file?') }}</span>
|
||||||
<span class="pull-right">
|
<span class="pull-right">
|
||||||
<button type='button' class='btn btn_yes'>{{ _('Yes') }}</button>
|
<button type='button' class='btn btn_yes' tabindex="15">{{ _('Yes') }}</button>
|
||||||
<button type='button' class='btn btn_no'>{{ _('No') }}</button>
|
<button type='button' class='btn btn_no' tabindex="16">{{ _('No') }}</button>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -57,6 +62,7 @@
|
|||||||
require(['sources/generated/file_utils'], function() {
|
require(['sources/generated/file_utils'], function() {
|
||||||
pgAdmin.FileUtils.init();
|
pgAdmin.FileUtils.init();
|
||||||
});
|
});
|
||||||
|
setTimeout(function(){ $('#file-input-path').focus(); }, 1000);
|
||||||
</script>
|
</script>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
Loading…
Reference in New Issue
Block a user