Updated config file documentation for shared storage and While doing save as operation, ensure the error message is shown if access is restricted in shared storage #5014

This commit is contained in:
Nikhil Mohite 2023-03-29 13:49:32 +05:30 committed by GitHub
parent 36d18ba5cb
commit 48839983fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 9 deletions

View File

@ -56,7 +56,7 @@ Shared Storage
In the storage manager, ``My Storage`` is the pgAdmin users storage directory, and other listed directories are shared
storages set by the pgAdmin server administrator. Using these, pgAdmin users can have common storages to share files.
pgAdmin server administrator can configure the shared storages using the <link>config file</link>. Storages can be
pgAdmin server administrator can configure the shared storages using the :ref:`config file <config_py>`. Storages can be
marked as restricted to give read-only access to non-admin pgAdmin users.

View File

@ -791,12 +791,9 @@ class Filemanager():
if selectedDir:
if selectedDir[
'restricted_access'] and not current_user.has_role(
'restricted_access'] and not current_user.has_role(
"Administrator"):
return make_json_response(success=0,
errormsg=ACCESS_DENIED_MESSAGE,
info='ACCESS_DENIED',
status=403)
raise PermissionError(ACCESS_DENIED_MESSAGE)
def rename(self, old=None, new=None):
"""
@ -1140,7 +1137,8 @@ def file_manager(trans_id):
ss = kwargs['storage_folder'] if 'storage_folder' in kwargs else None
my_fm = Filemanager(trans_id, ss)
if ss and mode in ['upload', 'rename', 'delete', 'addfolder', 'add']:
if ss and mode in ['upload', 'rename', 'delete', 'addfolder', 'add',
'permission']:
my_fm.check_access(ss, mode)
func = getattr(my_fm, mode)
try:

View File

@ -327,11 +327,12 @@ export class FileManagerUtils {
});
}
async checkPermission(path) {
async checkPermission(path, selectedStorage=MY_STORAGE) {
try {
let res = await this.api.post(this.fileConnectorUrl, {
'path': path,
'mode': 'permission',
'storage_folder': selectedStorage
});
if (res.data.data.result.Code === 1) {
return null;
@ -589,7 +590,7 @@ export default function FileManager({params, closeModal, onOK, onCancel, sharedS
newFileName += `.${fileType}`;
}
onOkPath = fmUtilsObj.join(fmUtilsObj.currPath, newFileName);
let error = await fmUtilsObj.checkPermission(onOkPath);
let error = await fmUtilsObj.checkPermission(onOkPath, selectedSS);
if(error) {
setErrorMsg(error);
setLoaderText('');