mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-23 15:03:26 -06:00
Fix SonarQube code smells:
1) String literals should not be duplicated. 2) Prefer using an optional chain expression instead, as it's more concise and easier to read. 3) Expected the Promise rejection reason to be an Error.
This commit is contained in:
parent
2d2aa45ec5
commit
8857f0d179
@ -11,6 +11,7 @@ import secrets
|
||||
import string
|
||||
import urllib3
|
||||
import ipaddress
|
||||
from pgadmin.utils.constants import IP_ADDRESS_STRING
|
||||
|
||||
|
||||
def get_my_ip():
|
||||
@ -29,11 +30,11 @@ def get_my_ip():
|
||||
|
||||
ip = ipaddress.ip_address(external_ip)
|
||||
if isinstance(ip, ipaddress.IPv4Address):
|
||||
return '{}/{}'.format(external_ip, 32)
|
||||
return IP_ADDRESS_STRING.format(external_ip, 32)
|
||||
elif isinstance(ip, ipaddress.IPv6Address):
|
||||
return '{}/{}'.format(external_ip, 128)
|
||||
return IP_ADDRESS_STRING.format(external_ip, 128)
|
||||
|
||||
return '{}/{}'.format(external_ip, 32)
|
||||
return IP_ADDRESS_STRING.format(external_ip, 32)
|
||||
|
||||
|
||||
def get_random_id():
|
||||
|
@ -35,6 +35,7 @@ from pgadmin.tools.sqleditor.utils.query_history import QueryHistory
|
||||
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
||||
from pgadmin.model import db, Server, Database
|
||||
from pgadmin.browser.utils import underscore_escape
|
||||
from pgadmin.utils.constants import TWO_PARAM_STRING
|
||||
|
||||
|
||||
class DatabaseModule(CollectionNodeModule):
|
||||
@ -586,7 +587,7 @@ class DatabaseView(PGChildNodeView):
|
||||
'icon': 'pg-icon-database',
|
||||
'already_connected': already_connected,
|
||||
'connected': True,
|
||||
'info_prefix': '{0}/{1}'.
|
||||
'info_prefix': TWO_PARAM_STRING.
|
||||
format(Server.query.filter_by(id=sid)[0].name, conn.db)
|
||||
}
|
||||
)
|
||||
@ -609,7 +610,7 @@ class DatabaseView(PGChildNodeView):
|
||||
data={
|
||||
'icon': 'icon-database-not-connected',
|
||||
'connected': False,
|
||||
'info_prefix': '{0}/{1}'.
|
||||
'info_prefix': TWO_PARAM_STRING.
|
||||
format(Server.query.filter_by(id=sid)[0].name, conn.db)
|
||||
}
|
||||
)
|
||||
|
@ -91,7 +91,7 @@ define('pgadmin.node.cast', [
|
||||
resolve(data);
|
||||
})
|
||||
.catch((err)=>{
|
||||
reject(err);
|
||||
reject(new Error(err));
|
||||
});
|
||||
} else {
|
||||
data = [];
|
||||
|
@ -20,7 +20,7 @@ export function enableTriggers(tree, generateUrl, args) {
|
||||
function setTriggers(tree, generateUrl, args, params) {
|
||||
const treeNode = retrieveTreeNode(args, tree);
|
||||
|
||||
if (!treeNode || treeNode.getData() === null || treeNode.getData() === undefined)
|
||||
if (!treeNode?.getData())
|
||||
return false;
|
||||
|
||||
axios.put(
|
||||
|
@ -100,7 +100,7 @@ function getRangeSchema(nodeObj, treeNodeInfo, itemNodeData) {
|
||||
data = res.data.data;
|
||||
resolve(data);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
reject(new Error(err));
|
||||
});
|
||||
} else {
|
||||
resolve(data);
|
||||
@ -127,7 +127,7 @@ function getRangeSchema(nodeObj, treeNodeInfo, itemNodeData) {
|
||||
data = res.data.data;
|
||||
resolve(data);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
reject(new Error(err));
|
||||
});
|
||||
} else {
|
||||
resolve(data);
|
||||
@ -155,7 +155,7 @@ function getRangeSchema(nodeObj, treeNodeInfo, itemNodeData) {
|
||||
data = res.data.data;
|
||||
resolve(data);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
reject(new Error(err));
|
||||
});
|
||||
} else {
|
||||
resolve(data);
|
||||
|
@ -32,6 +32,7 @@ from .schema_diff_view_utils import SchemaDiffViewCompare
|
||||
from pgadmin.utils import html, does_utility_exist, get_server
|
||||
from pgadmin.model import Server
|
||||
from pgadmin.misc.bgprocess.processes import BatchProcess, IProcessDesc
|
||||
from pgadmin.utils.constants import SERVER_NOT_FOUND
|
||||
|
||||
|
||||
"""
|
||||
@ -2425,7 +2426,7 @@ class MViewNode(ViewNode, VacuumSettings):
|
||||
if server is None:
|
||||
return make_json_response(
|
||||
success=0,
|
||||
errormsg=gettext("Could not find the specified server.")
|
||||
errormsg=SERVER_NOT_FOUND
|
||||
)
|
||||
|
||||
driver = get_driver(PG_DEFAULT_DRIVER)
|
||||
|
@ -104,7 +104,7 @@ define('pgadmin.node.subscription', [
|
||||
gettext('Publication fetched successfully.')
|
||||
);
|
||||
}else if(!_.isNull(res.data.errormsg) && _.isNull(res.data.data)){
|
||||
reject(res.data.errormsg);
|
||||
reject(new Error(res.data.errormsg));
|
||||
pgAdmin.Browser.notifier.alert(
|
||||
gettext('Check connection?'),
|
||||
gettext(res.data.errormsg)
|
||||
@ -112,7 +112,7 @@ define('pgadmin.node.subscription', [
|
||||
}
|
||||
})
|
||||
.catch((err)=>{
|
||||
reject(err);
|
||||
reject(new Error(err));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -13,6 +13,7 @@ from regression import parent_node_dict
|
||||
from regression.python_test_utils import test_utils as utils
|
||||
from . import utils as servers_utils
|
||||
import json
|
||||
from pgadmin.utils.constants import TWO_PARAM_STRING
|
||||
|
||||
|
||||
class AllServersGetTestCase(BaseTestGenerator):
|
||||
@ -71,16 +72,16 @@ class AllServersGetTestCase(BaseTestGenerator):
|
||||
utils.SERVER_GROUP, secrets.choice(range(1, 9999999)))
|
||||
elif hasattr(self, 'children'):
|
||||
|
||||
self.url = self.url + '{0}/{1}'.format(
|
||||
self.url = self.url + TWO_PARAM_STRING.format(
|
||||
utils.SERVER_GROUP, self.server_id)
|
||||
elif hasattr(self, 'server_list'):
|
||||
if hasattr(self, 'servers'):
|
||||
server_id = ''
|
||||
self.url = self.url + '{0}/{1}'.format(
|
||||
self.url = self.url + TWO_PARAM_STRING.format(
|
||||
utils.SERVER_GROUP, server_id)
|
||||
else:
|
||||
if hasattr(self, "connected"):
|
||||
url = '/browser/server/connect/' + '{0}/{1}'.format(
|
||||
url = '/browser/server/connect/' + TWO_PARAM_STRING.format(
|
||||
utils.SERVER_GROUP,
|
||||
self.server_id)
|
||||
self.server['password'] = self.server['db_password']
|
||||
|
@ -13,6 +13,7 @@ from regression.python_test_utils import test_utils as utils
|
||||
from . import utils as servers_utils
|
||||
import json
|
||||
from unittest.mock import patch, MagicMock
|
||||
from pgadmin.utils.constants import TWO_PARAM_STRING
|
||||
|
||||
|
||||
class ServersConnectTestCase(BaseTestGenerator):
|
||||
@ -82,7 +83,7 @@ class ServersConnectTestCase(BaseTestGenerator):
|
||||
server_id = 99999
|
||||
response = self.server_disonnect(server_id)
|
||||
elif hasattr(self, "connect"):
|
||||
url = self.url + '{0}/{1}'.format(
|
||||
url = self.url + TWO_PARAM_STRING.format(
|
||||
utils.SERVER_GROUP,
|
||||
self.server_id)
|
||||
self.server['password'] = self.server['db_password']
|
||||
@ -134,7 +135,7 @@ class ServersConnectTestCase(BaseTestGenerator):
|
||||
connect_url = '/browser/server/connect/{0}/{1}'.format(
|
||||
utils.SERVER_GROUP,
|
||||
self.server_id)
|
||||
url = self.url + '{0}/{1}'.format(
|
||||
url = self.url + TWO_PARAM_STRING.format(
|
||||
utils.SERVER_GROUP,
|
||||
self.server_id)
|
||||
|
||||
|
@ -13,6 +13,7 @@ from . import utils as servers_utils
|
||||
from unittest.mock import patch, MagicMock
|
||||
import json
|
||||
from psycopg import OperationalError
|
||||
from pgadmin.utils.constants import TWO_PARAM_STRING
|
||||
|
||||
|
||||
class ServersSSHConnectTestCase(BaseTestGenerator):
|
||||
@ -51,7 +52,7 @@ class ServersSSHConnectTestCase(BaseTestGenerator):
|
||||
self.manager.connection().connect.side_effect = \
|
||||
MagicMock(side_effect=OperationalError())
|
||||
|
||||
url = self.url + '{0}/{1}'.format(utils.SERVER_GROUP, 1)
|
||||
url = self.url + TWO_PARAM_STRING.format(utils.SERVER_GROUP, 1)
|
||||
|
||||
class TestMockServer():
|
||||
def __init__(self, name, id, username, use_ssh_tunnel,
|
||||
|
@ -191,7 +191,7 @@ define('pgadmin.browser', [
|
||||
if(categoryMenuOptions?.above) {
|
||||
menuItemList.push(MainMenuFactory.getSeparator(label, priority));
|
||||
}
|
||||
if(!allMenuItemsDisabled && skipDisabled) {
|
||||
if((!allMenuItemsDisabled && skipDisabled) || !skipDisabled) {
|
||||
let _menuItem = MainMenuFactory.createMenuItem({
|
||||
name: c,
|
||||
label: label,
|
||||
@ -201,17 +201,6 @@ define('pgadmin.browser', [
|
||||
priority: priority
|
||||
});
|
||||
|
||||
menuItemList.push(_menuItem);
|
||||
} else if(!skipDisabled){
|
||||
let _menuItem = MainMenuFactory.createMenuItem({
|
||||
name: c,
|
||||
label: label,
|
||||
module:c,
|
||||
category: c,
|
||||
menu_items: category[c],
|
||||
priority: priority
|
||||
});
|
||||
|
||||
menuItemList.push(_menuItem);
|
||||
}
|
||||
if(categoryMenuOptions?.below) {
|
||||
@ -223,9 +212,7 @@ define('pgadmin.browser', [
|
||||
});
|
||||
|
||||
category[c].forEach((m)=> {
|
||||
if(!skipDisabled) {
|
||||
menuItemList.push(m);
|
||||
} else if(skipDisabled && !m.isDisabled){
|
||||
if(!skipDisabled || (skipDisabled && !m.isDisabled)) {
|
||||
menuItemList.push(m);
|
||||
}
|
||||
});
|
||||
@ -1127,7 +1114,7 @@ define('pgadmin.browser', [
|
||||
this.t.openPath(this.i);
|
||||
this.t.select(this.i);
|
||||
if (
|
||||
_ctx.o && _ctx.o.success && typeof(_ctx.o.success) == 'function'
|
||||
_ctx.o?.success && typeof(_ctx.o?.success) == 'function'
|
||||
) {
|
||||
_ctx.o.success.apply(_ctx.t, [_ctx.i, _new]);
|
||||
}
|
||||
@ -1356,7 +1343,7 @@ define('pgadmin.browser', [
|
||||
ctx.b._refreshNode(ctx, ctx.branch);
|
||||
},
|
||||
error: function() {
|
||||
let fail = (_opts.o && _opts.o.fail) || _opts.fail;
|
||||
let fail = _opts.o?.fail || _opts?.fail;
|
||||
|
||||
if (typeof(fail) == 'function') {
|
||||
fail();
|
||||
@ -1673,7 +1660,7 @@ define('pgadmin.browser', [
|
||||
_refreshNode: function(_ctx, _d) {
|
||||
let traverseNodes = function(__d) {
|
||||
let __ctx = this, idx = 0, ctx, d,
|
||||
size = (__d.branch && __d.branch.length) || 0,
|
||||
size = __d?.branch?.length || 0,
|
||||
findNode = function(i_findNode, d_findNode, ctx_findNode) {
|
||||
setTimeout(
|
||||
function() {
|
||||
@ -1703,7 +1690,7 @@ define('pgadmin.browser', [
|
||||
}
|
||||
}.bind(_ctx, _d);
|
||||
|
||||
if (!_d || !_d.open)
|
||||
if (!_d?.open)
|
||||
return;
|
||||
|
||||
if (!_ctx.t.isOpen(_ctx.i)) {
|
||||
|
@ -935,9 +935,7 @@ define('pgadmin.browser.node', [
|
||||
cache: function(url, node_info, level, data) {
|
||||
let cached = this.cached = this.cached || {},
|
||||
hash = url,
|
||||
min_priority = (
|
||||
node_info?.[level] && node_info?.[level].priority
|
||||
) || 0;
|
||||
min_priority = node_info?.[level]?.priority || 0;
|
||||
|
||||
if (node_info) {
|
||||
_.each(_.sortBy(_.values(_.pickBy(
|
||||
|
@ -124,7 +124,7 @@ export function getNodeAjaxOptions(url, nodeObj, treeNodeInfo, itemNodeData, par
|
||||
otherParams.useCache && cacheNode.cache(nodeObj.type + '#' + url, treeNodeInfo, cacheLevel, data);
|
||||
resolve(transform(data));
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
reject(new Error(err));
|
||||
});
|
||||
} else {
|
||||
// To fetch only options from cache, we do not need time from 'at'
|
||||
|
@ -15,13 +15,12 @@ import pickle
|
||||
from flask_babel import gettext
|
||||
from flask import session, current_app
|
||||
from pgadmin.user_login_check import pga_login_required
|
||||
from werkzeug.datastructures import Headers
|
||||
from pgadmin.utils import PgAdminModule
|
||||
from pgadmin.misc.cloud.utils import _create_server, CloudProcessDesc
|
||||
from pgadmin.misc.bgprocess.processes import BatchProcess
|
||||
from pgadmin.utils.ajax import make_json_response
|
||||
from config import root
|
||||
from pgadmin.utils.constants import MIMETYPE_APP_JSON
|
||||
from pgadmin.utils.constants import MIMETYPE_APP_JSON, TWO_PARAM_STRING
|
||||
|
||||
MODULE_NAME = 'biganimal'
|
||||
|
||||
@ -192,15 +191,15 @@ class BigAnimalProvider():
|
||||
|
||||
def get_auth_provider(self):
|
||||
"""Get Authentication Provider Relevant Information."""
|
||||
provider_resp = requests.get("{0}/{1}".format(self.BASE_URL,
|
||||
'auth/provider'))
|
||||
provider_resp = requests.get(TWO_PARAM_STRING.format(self.BASE_URL,
|
||||
'auth/provider'))
|
||||
if provider_resp.status_code == 200 and provider_resp.content:
|
||||
self.provider = json.loads(provider_resp.content)
|
||||
|
||||
def get_device_code(self):
|
||||
"""Get device code"""
|
||||
_url = "{0}/{1}".format(self.provider['issuerUri'],
|
||||
'oauth/device/code')
|
||||
_url = TWO_PARAM_STRING.format(self.provider['issuerUri'],
|
||||
'oauth/device/code')
|
||||
_headers = {"content-type": "application/x-www-form-urlencoded"}
|
||||
_data = {
|
||||
'client_id': self.provider['clientId'],
|
||||
@ -217,7 +216,8 @@ class BigAnimalProvider():
|
||||
|
||||
def polling_for_token(self):
|
||||
# Polling for the Token
|
||||
_url = "{0}/{1}".format(self.provider['issuerUri'], 'oauth/token')
|
||||
_url = TWO_PARAM_STRING.format(self.provider['issuerUri'],
|
||||
'oauth/token')
|
||||
_headers = {"content-type": "application/x-www-form-urlencoded"}
|
||||
_data = {
|
||||
'grant_type': 'urn:ietf:params:oauth:grant-type:device_code',
|
||||
@ -245,7 +245,7 @@ class BigAnimalProvider():
|
||||
return False, None
|
||||
|
||||
def exchange_token(self):
|
||||
_url = "{0}/{1}".format(self.BASE_URL, 'auth/token')
|
||||
_url = TWO_PARAM_STRING.format(self.BASE_URL, 'auth/token')
|
||||
_headers = {"content-type": "application/json",
|
||||
"accept": "application/json"}
|
||||
_data = {'token': self.raw_access_token}
|
||||
@ -266,7 +266,7 @@ class BigAnimalProvider():
|
||||
There is no direct way to do this, so just checking the create cluster
|
||||
permission.
|
||||
"""
|
||||
_url = "{0}/{1}".format(
|
||||
_url = TWO_PARAM_STRING.format(
|
||||
self.BASE_URL,
|
||||
'user-info')
|
||||
resp = requests.get(_url, headers=self._get_headers())
|
||||
|
@ -19,7 +19,7 @@ import { isEmptyString } from 'sources/validators';
|
||||
import PropTypes from 'prop-types';
|
||||
import gettext from 'sources/gettext';
|
||||
|
||||
const StyledSchemaView= styled(SchemaView)(() =>
|
||||
const StyledSchemaView= styled(SchemaView)(() =>
|
||||
({
|
||||
'& .aws-formClass': {
|
||||
overflow: 'auto',
|
||||
@ -90,7 +90,7 @@ export function AwsInstanceDetails(props) {
|
||||
resolve(data);
|
||||
})
|
||||
.catch((err)=>{
|
||||
reject(err);
|
||||
reject(new Error(err));
|
||||
});
|
||||
} else {
|
||||
resolve(options);
|
||||
|
@ -72,7 +72,7 @@ export function AzureCredentials(props) {
|
||||
})
|
||||
.catch((error)=>{
|
||||
clearInterval(interval);
|
||||
reject(error);
|
||||
reject(new Error(error));
|
||||
});
|
||||
}, 1000);
|
||||
});
|
||||
|
@ -122,7 +122,7 @@ class AzureCredSchema extends BaseUISchema {
|
||||
}));
|
||||
})
|
||||
.catch((err)=>{
|
||||
reject(err);
|
||||
reject(new Error(err));
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -152,7 +152,7 @@ class AzureCredSchema extends BaseUISchema {
|
||||
});
|
||||
})
|
||||
.catch((err)=>{
|
||||
reject(err);
|
||||
reject(new Error(err));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -87,7 +87,7 @@ export function GoogleCredentials(props) {
|
||||
})
|
||||
.catch((error)=>{
|
||||
clearInterval(interval);
|
||||
reject(error);
|
||||
reject(new Error(error));
|
||||
});
|
||||
countdown = countdown - 1;
|
||||
}, 1000);
|
||||
|
@ -68,13 +68,13 @@ class GoogleCredSchema extends BaseUISchema{
|
||||
resolve();
|
||||
})
|
||||
.catch((err)=>{
|
||||
reject(err);
|
||||
reject(new Error(err));
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch((err)=>{
|
||||
reject(err);
|
||||
reject(new Error(err));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -14,6 +14,7 @@ from pgadmin.misc.bgprocess.processes import IProcessDesc
|
||||
from pgadmin.model import db, Server
|
||||
from flask_babel import gettext
|
||||
from pgadmin.utils import get_server
|
||||
from pgadmin.utils.constants import IP_ADDRESS_STRING
|
||||
|
||||
|
||||
def get_my_ip():
|
||||
@ -33,11 +34,11 @@ def get_my_ip():
|
||||
|
||||
ip = ipaddress.ip_address(external_ip)
|
||||
if isinstance(ip, ipaddress.IPv4Address):
|
||||
return '{}/{}'.format(external_ip, 32)
|
||||
return IP_ADDRESS_STRING.format(external_ip, 32)
|
||||
elif isinstance(ip, ipaddress.IPv6Address):
|
||||
return '{}/{}'.format(external_ip, 128)
|
||||
return IP_ADDRESS_STRING.format(external_ip, 128)
|
||||
|
||||
return '{}/{}'.format(external_ip, 32)
|
||||
return IP_ADDRESS_STRING.format(external_ip, 32)
|
||||
|
||||
|
||||
def _create_server(data):
|
||||
|
@ -17,7 +17,7 @@ import time
|
||||
from urllib.parse import unquote
|
||||
from sys import platform as _platform
|
||||
from flask_security import current_user
|
||||
from pgadmin.utils.constants import ACCESS_DENIED_MESSAGE
|
||||
from pgadmin.utils.constants import ACCESS_DENIED_MESSAGE, TWO_PARAM_STRING
|
||||
import config
|
||||
import codecs
|
||||
import pathlib
|
||||
@ -748,12 +748,12 @@ class Filemanager():
|
||||
if path.startswith('/') or path.startswith('\\'):
|
||||
return "{}{}".format(in_dir[:-1], path)
|
||||
else:
|
||||
return "{}/{}".format(in_dir, path)
|
||||
return TWO_PARAM_STRING.format(in_dir, path)
|
||||
else:
|
||||
if path.startswith('/') or path.startswith('\\'):
|
||||
return "{}{}".format(in_dir, path)
|
||||
else:
|
||||
return "{}/{}".format(in_dir, path)
|
||||
return TWO_PARAM_STRING.format(in_dir, path)
|
||||
|
||||
def validate_request(self, capability):
|
||||
"""
|
||||
@ -952,7 +952,7 @@ class Filemanager():
|
||||
file_path = "{}{}/".format(path, new_name)
|
||||
create_path = file_path
|
||||
if in_dir != "":
|
||||
create_path = "{}/{}".format(in_dir, file_path)
|
||||
create_path = TWO_PARAM_STRING.format(in_dir, file_path)
|
||||
|
||||
if not path_exists(create_path):
|
||||
return create_path, file_path, new_name
|
||||
|
@ -25,7 +25,7 @@ export default function ObjectNodeProperties({panelId, node, treeNodeInfo, nodeD
|
||||
const nodeType = nodeData?._type;
|
||||
const pgAdmin = usePgAdmin();
|
||||
let serverInfo = treeNodeInfo && ('server' in treeNodeInfo) &&
|
||||
pgAdmin.Browser.serverInfo && pgAdmin.Browser.serverInfo[treeNodeInfo.server._id];
|
||||
pgAdmin.Browser.serverInfo?.[treeNodeInfo.server._id];
|
||||
let inCatalog = treeNodeInfo && ('catalog' in treeNodeInfo);
|
||||
let isActionTypeCopy = actionType == 'copy';
|
||||
// If the actionType is set to 'copy' it is necessary to retrieve the details
|
||||
@ -85,9 +85,9 @@ export default function ObjectNodeProperties({panelId, node, treeNodeInfo, nodeD
|
||||
if (msg == 'CRYPTKEY_SET') {
|
||||
return Promise.resolve(initData());
|
||||
} else if (msg == 'CRYPTKEY_NOT_SET') {
|
||||
reject(gettext('The master password is not set.'));
|
||||
reject(new Error(gettext('The master password is not set.')));
|
||||
}
|
||||
reject(err);
|
||||
reject(new Error(err));
|
||||
});
|
||||
|
||||
})
|
||||
@ -114,9 +114,9 @@ export default function ObjectNodeProperties({panelId, node, treeNodeInfo, nodeD
|
||||
if (msg == 'CRYPTKEY_SET') {
|
||||
return Promise.resolve(onSaveClick(isNew, data));
|
||||
} else if (msg == 'CRYPTKEY_NOT_SET') {
|
||||
reject(gettext('The master password is not set.'));
|
||||
reject(new Error(gettext('The master password is not set.')));
|
||||
}
|
||||
reject(err);
|
||||
reject(new Error(err));
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -133,7 +133,7 @@ export default function ObjectNodeProperties({panelId, node, treeNodeInfo, nodeD
|
||||
resolve(res.data.data);
|
||||
}).catch((err)=>{
|
||||
onError(err);
|
||||
reject(err);
|
||||
reject(new Error(err));
|
||||
});
|
||||
});
|
||||
};
|
||||
|
@ -49,6 +49,7 @@ db = SQLAlchemy(
|
||||
|
||||
USER_ID = 'user.id'
|
||||
SERVER_ID = 'server.id'
|
||||
CASCADE_STR = "all, delete-orphan"
|
||||
|
||||
# Define models
|
||||
roles_users = db.Table(
|
||||
@ -173,7 +174,7 @@ class Server(db.Model):
|
||||
discovery_id = db.Column(db.String(128), nullable=True)
|
||||
servers = db.relationship(
|
||||
'ServerGroup',
|
||||
backref=db.backref('server', cascade="all, delete-orphan"),
|
||||
backref=db.backref('server', cascade=CASCADE_STR),
|
||||
lazy='joined'
|
||||
)
|
||||
db_res = db.Column(db.Text(), nullable=True)
|
||||
@ -388,7 +389,7 @@ class SharedServer(db.Model):
|
||||
discovery_id = db.Column(db.String(128), nullable=True)
|
||||
servers = db.relationship(
|
||||
'ServerGroup',
|
||||
backref=db.backref('sharedserver', cascade="all, delete-orphan"),
|
||||
backref=db.backref('sharedserver', cascade=CASCADE_STR),
|
||||
lazy='joined'
|
||||
)
|
||||
db_res = db.Column(db.Text(), nullable=True)
|
||||
@ -452,5 +453,5 @@ class UserMFA(db.Model):
|
||||
options = db.Column(db.Text(), nullable=True)
|
||||
user = db.relationship(
|
||||
'User',
|
||||
backref=db.backref('user', cascade="all, delete-orphan")
|
||||
backref=db.backref('user', cascade=CASCADE_STR)
|
||||
)
|
||||
|
@ -111,7 +111,7 @@ function RightPanel({ schema, ...props }) {
|
||||
try {
|
||||
resolve(props.initValues);
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
reject(new Error(error));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -206,7 +206,7 @@ export function showChangeServerPassword() {
|
||||
onClose();
|
||||
})
|
||||
.catch((error)=>{
|
||||
reject(error);
|
||||
reject(new Error(error));
|
||||
});
|
||||
});
|
||||
}}
|
||||
@ -233,7 +233,7 @@ export function showChangeUserPassword(url) {
|
||||
resolve(res.data);
|
||||
})
|
||||
.catch((err)=>{
|
||||
reject(err);
|
||||
reject(new Error(err));
|
||||
});
|
||||
});
|
||||
}}
|
||||
@ -259,7 +259,7 @@ export function showChangeUserPassword(url) {
|
||||
onClose();
|
||||
pgAdmin.Browser.notifier.success(res.data.info);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
reject(new Error(err));
|
||||
});
|
||||
});
|
||||
}}
|
||||
@ -332,7 +332,7 @@ export function showChangeOwnership() {
|
||||
resolve(respData.data);
|
||||
})
|
||||
.catch((err)=>{
|
||||
reject(err);
|
||||
reject(new Error(err));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -67,8 +67,7 @@ function UtilityViewContent({panelId, schema, treeNodeInfo, actionType, formType
|
||||
onSave, extraData, saveBtnName, urlBase, sqlHelpUrl, helpUrl, isTabView=true}) {
|
||||
|
||||
const pgAdmin = usePgAdmin();
|
||||
const serverInfo = treeNodeInfo && ('server' in treeNodeInfo) &&
|
||||
pgAdmin.Browser.serverInfo && pgAdmin.Browser.serverInfo[treeNodeInfo.server._id];
|
||||
const serverInfo = treeNodeInfo && ('server' in treeNodeInfo) && pgAdmin.Browser.serverInfo?.[treeNodeInfo.server._id];
|
||||
const api = getApiInstance();
|
||||
const url = ()=>{
|
||||
return urlBase;
|
||||
@ -89,14 +88,14 @@ function UtilityViewContent({panelId, schema, treeNodeInfo, actionType, formType
|
||||
return api({
|
||||
url: url(),
|
||||
method: isNew ? 'POST' : 'PUT',
|
||||
data: Object.assign({}, data, extraData),
|
||||
data: {...data, ...extraData},
|
||||
}).then((res)=>{
|
||||
/* Don't warn the user before closing dialog */
|
||||
resolve(res.data);
|
||||
onSave?.(res.data);
|
||||
onClose();
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
reject(new Error(err));
|
||||
});
|
||||
});
|
||||
|
||||
@ -112,7 +111,7 @@ function UtilityViewContent({panelId, schema, treeNodeInfo, actionType, formType
|
||||
resolve(res.data.data);
|
||||
}).catch((err)=>{
|
||||
onError(err);
|
||||
reject(err);
|
||||
reject(new Error(err));
|
||||
});
|
||||
});
|
||||
};
|
||||
@ -162,7 +161,7 @@ function UtilityViewContent({panelId, schema, treeNodeInfo, actionType, formType
|
||||
} else if(err.message){
|
||||
console.error('error msg', err.message);
|
||||
}
|
||||
reject(err);
|
||||
reject(new Error(err));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ export const PgReactTableCell = forwardRef(({row, cell, children, className}, re
|
||||
if (row.original.row_type === 'alert') {
|
||||
classNames.push('row-alert');
|
||||
}
|
||||
if(row.original.icon && row.original.icon[cell.column.id]) {
|
||||
if(row.original.icon?.[cell.column.id]) {
|
||||
classNames.push(row.original.icon[cell.column.id], 'cell-with-icon');
|
||||
}
|
||||
if(cell.column.columnDef.dataClassName){
|
||||
@ -304,8 +304,8 @@ export const PgReactTable = forwardRef(({children, table, rootClassName, tableCl
|
||||
const columnSizeVars = React.useMemo(() => {
|
||||
const headers = table.getFlatHeaders();
|
||||
const colSizes = {};
|
||||
for (let i = 0; i < headers.length; i++) {
|
||||
const header = headers[i];
|
||||
for (let value of headers) {
|
||||
const header = value;
|
||||
colSizes[`--header-${header.id.replace(/\W/g, '_')}-size`] = header.getSize();
|
||||
colSizes[`--col-${header.column.id.replace(/\W/g, '_')}-size`] = header.column.getSize();
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ export default function FindDialog({editor, show, replace, onClose}) {
|
||||
// Get selected text from editor and set it to find/replace input.
|
||||
let selText = editor.getSelection();
|
||||
setFindVal(selText);
|
||||
findInputRef.current && findInputRef.current.select();
|
||||
findInputRef.current?.select();
|
||||
}
|
||||
}, [show]);
|
||||
|
||||
|
@ -22,7 +22,7 @@ export function setPGCSRFToken(header, token) {
|
||||
|
||||
return config;
|
||||
}, function (error) {
|
||||
return Promise.reject(error);
|
||||
return Promise.reject(new Error(error));
|
||||
});
|
||||
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ function isCtrlAltBoth(event) {
|
||||
/* Returns the key of shortcut */
|
||||
function shortcut_key(shortcut) {
|
||||
let key = '';
|
||||
if(shortcut?.['key'] && shortcut?.['key']['char']) {
|
||||
if(shortcut?.['key']?.['char']) {
|
||||
key = shortcut['key']['char'].toUpperCase();
|
||||
}
|
||||
return key;
|
||||
|
@ -27,10 +27,10 @@ export function openSocket(namespace, options) {
|
||||
resolve(socketObj);
|
||||
});
|
||||
socketObj.on('connect_error', (err)=>{
|
||||
reject(err);
|
||||
reject(new Error(err));
|
||||
});
|
||||
socketObj.on('disconnect', (err)=>{
|
||||
reject(err);
|
||||
reject(new Error(err));
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -42,10 +42,10 @@ export function socketApiGet(socket, endpoint, params) {
|
||||
resolve(data);
|
||||
});
|
||||
socket.on(`${endpoint}_failed`, (data)=>{
|
||||
reject(data);
|
||||
reject(new Error(data));
|
||||
});
|
||||
socket.on('disconnect', ()=>{
|
||||
reject(gettext('Connection to pgAdmin server has been lost'));
|
||||
reject(new Error(gettext('Connection to pgAdmin server has been lost')));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -13,14 +13,11 @@ import copy
|
||||
import functools
|
||||
import operator
|
||||
|
||||
from flask import render_template, request, current_app, \
|
||||
url_for, Response
|
||||
from flask import render_template, request, current_app, Response
|
||||
from flask_babel import gettext
|
||||
from flask_security import current_user
|
||||
from pgadmin.user_login_check import pga_login_required
|
||||
from pgadmin.misc.bgprocess.processes import BatchProcess, IProcessDesc
|
||||
from pgadmin.utils import PgAdminModule, get_storage_directory, html, \
|
||||
fs_short_path, document_dir, does_utility_exist, get_server, \
|
||||
from pgadmin.utils import PgAdminModule, does_utility_exist, get_server, \
|
||||
filename_with_file_manager_path
|
||||
from pgadmin.utils.ajax import make_json_response, bad_request, unauthorized
|
||||
|
||||
@ -29,13 +26,14 @@ from config import PG_DEFAULT_DRIVER
|
||||
# Have to identify the cause and then remove it.
|
||||
from pgadmin.model import Server, SharedServer
|
||||
from pgadmin.misc.bgprocess import escape_dquotes_process_arg
|
||||
from pgadmin.utils.constants import MIMETYPE_APP_JS
|
||||
from pgadmin.tools.grant_wizard import _get_rows_for_type, \
|
||||
get_node_sql_with_type, properties, get_data
|
||||
from pgadmin.utils.constants import MIMETYPE_APP_JS, SERVER_NOT_FOUND
|
||||
from pgadmin.tools.grant_wizard import get_data
|
||||
|
||||
# set template path for sql scripts
|
||||
MODULE_NAME = 'backup'
|
||||
server_info = {}
|
||||
MVIEW_STR = 'materialized view'
|
||||
FOREIGN_TABLE_STR = 'foreign table'
|
||||
|
||||
|
||||
class BackupModule(PgAdminModule):
|
||||
@ -422,7 +420,7 @@ def create_backup_objects_job(sid):
|
||||
if server is None:
|
||||
return make_json_response(
|
||||
success=0,
|
||||
errormsg=gettext("Could not find the specified server.")
|
||||
errormsg=SERVER_NOT_FOUND
|
||||
)
|
||||
|
||||
# To fetch MetaData for the server
|
||||
@ -515,7 +513,7 @@ def check_utility_exists(sid, backup_obj_type):
|
||||
if server is None:
|
||||
return make_json_response(
|
||||
success=0,
|
||||
errormsg=gettext("Could not find the specified server.")
|
||||
errormsg=SERVER_NOT_FOUND
|
||||
)
|
||||
|
||||
from pgadmin.utils.driver import get_driver
|
||||
@ -558,7 +556,7 @@ def objects(sid, did, scid=None):
|
||||
if server is None:
|
||||
return make_json_response(
|
||||
success=0,
|
||||
errormsg=gettext("Could not find the specified server.")
|
||||
errormsg=SERVER_NOT_FOUND
|
||||
)
|
||||
|
||||
from pgadmin.utils.driver import get_driver
|
||||
@ -592,8 +590,8 @@ def objects(sid, did, scid=None):
|
||||
tree_data = {
|
||||
'table': [],
|
||||
'view': [],
|
||||
'materialized view': [],
|
||||
'foreign table': [],
|
||||
MVIEW_STR: [],
|
||||
FOREIGN_TABLE_STR: [],
|
||||
'sequence': []
|
||||
}
|
||||
|
||||
@ -601,7 +599,7 @@ def objects(sid, did, scid=None):
|
||||
|
||||
for data in res:
|
||||
obj_type = data['object_type'].lower()
|
||||
if obj_type in ['table', 'view', 'materialized view', 'foreign table',
|
||||
if obj_type in ['table', 'view', MVIEW_STR, FOREIGN_TABLE_STR,
|
||||
'sequence']:
|
||||
|
||||
if data['nspname'] not in schema_group:
|
||||
@ -613,8 +611,8 @@ def objects(sid, did, scid=None):
|
||||
'is_schema': True,
|
||||
}
|
||||
icon_data = {
|
||||
'materialized view': 'icon-mview',
|
||||
'foreign table': 'icon-foreign_table'
|
||||
MVIEW_STR: 'icon-mview',
|
||||
FOREIGN_TABLE_STR: 'icon-foreign_table'
|
||||
}
|
||||
icon = icon_data[obj_type] if obj_type in icon_data \
|
||||
else data['icon']
|
||||
@ -633,8 +631,8 @@ def objects(sid, did, scid=None):
|
||||
for obj_type, data in ch['children'].items():
|
||||
if data:
|
||||
icon_data = {
|
||||
'materialized view': 'icon-coll-mview',
|
||||
'foreign table': 'icon-coll-foreign_table'
|
||||
MVIEW_STR: 'icon-coll-mview',
|
||||
FOREIGN_TABLE_STR: 'icon-coll-foreign_table'
|
||||
}
|
||||
icon = icon_data[obj_type] if obj_type in icon_data \
|
||||
else f'icon-coll-{obj_type.lower()}',
|
||||
|
@ -265,7 +265,7 @@ define([
|
||||
}).then((response)=> {
|
||||
resolve(response.data.data);
|
||||
}).catch((err)=>{
|
||||
reject(err);
|
||||
reject(new Error(err));
|
||||
});
|
||||
});
|
||||
}}
|
||||
|
@ -44,6 +44,7 @@ ASYNC_OK = 1
|
||||
DEBUGGER_SQL_PATH = 'debugger/sql'
|
||||
DEBUGGER_SQL_V1_PATH = 'debugger/sql/v1'
|
||||
DEBUGGER_SQL_V3_PATH = 'debugger/sql/v3'
|
||||
SET_SEARCH_PATH = "SET search_path={0};"
|
||||
|
||||
|
||||
class DebuggerModule(PgAdminModule):
|
||||
@ -262,7 +263,7 @@ def index():
|
||||
|
||||
|
||||
def execute_dict_search_path(conn, sql, search_path):
|
||||
sql_search = "SET search_path={0};".format(search_path)
|
||||
sql_search = SET_SEARCH_PATH.format(search_path)
|
||||
status, res = conn.execute_void(sql_search)
|
||||
|
||||
if not status:
|
||||
@ -275,7 +276,7 @@ def execute_dict_search_path(conn, sql, search_path):
|
||||
|
||||
|
||||
def execute_async_search_path(conn, sql, search_path):
|
||||
sql_search = "SET search_path={0};".format(search_path)
|
||||
sql_search = SET_SEARCH_PATH.format(search_path)
|
||||
status, res = conn.execute_void(sql_search)
|
||||
|
||||
if not status:
|
||||
@ -679,7 +680,7 @@ def get_debugger_version(conn, search_path):
|
||||
:return:
|
||||
"""
|
||||
debugger_version = 0
|
||||
status, res = conn.execute_void("SET search_path={0};".format(search_path))
|
||||
status, res = conn.execute_void(SET_SEARCH_PATH.format(search_path))
|
||||
|
||||
if not status:
|
||||
return False, internal_server_error(errormsg=res)
|
||||
|
@ -438,7 +438,7 @@ export default function DebuggerArgumentComponent({ debuggerInfo, restartDebug,
|
||||
try {
|
||||
resolve(debuggerArgsData.current);
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
reject(new Error(error));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -23,7 +23,7 @@ export default class ERDDialogs {
|
||||
return new Promise((resolve, reject)=>{
|
||||
let errorMsg = okCallback(data);
|
||||
if(errorMsg) {
|
||||
reject(errorMsg);
|
||||
reject(new Error(errorMsg));
|
||||
} else {
|
||||
closeModal();
|
||||
resolve();
|
||||
|
@ -23,7 +23,7 @@ from pgadmin.utils.ajax import make_json_response, bad_request, unauthorized
|
||||
|
||||
from config import PG_DEFAULT_DRIVER
|
||||
from pgadmin.model import Server
|
||||
from pgadmin.utils.constants import MIMETYPE_APP_JS
|
||||
from pgadmin.utils.constants import MIMETYPE_APP_JS, SERVER_NOT_FOUND
|
||||
from pgadmin.settings import get_setting, store_setting
|
||||
|
||||
MODULE_NAME = 'import_export'
|
||||
@ -388,7 +388,7 @@ def check_utility_exists(sid):
|
||||
if server is None:
|
||||
return make_json_response(
|
||||
success=0,
|
||||
errormsg=_("Could not find the specified server.")
|
||||
errormsg=SERVER_NOT_FOUND
|
||||
)
|
||||
|
||||
from pgadmin.utils.driver import get_driver
|
||||
|
@ -11,9 +11,8 @@
|
||||
|
||||
import json
|
||||
|
||||
from flask import url_for, Response, render_template, request, current_app
|
||||
from flask import Response, render_template, request, current_app
|
||||
from flask_babel import gettext as _
|
||||
from flask_security import current_user
|
||||
from pgadmin.user_login_check import pga_login_required
|
||||
from pgadmin.misc.bgprocess.processes import BatchProcess, IProcessDesc
|
||||
from pgadmin.utils import PgAdminModule, html, does_utility_exist, get_server
|
||||
@ -22,7 +21,7 @@ from pgadmin.utils.driver import get_driver
|
||||
|
||||
from config import PG_DEFAULT_DRIVER
|
||||
from pgadmin.model import Server, SharedServer
|
||||
from pgadmin.utils.constants import MIMETYPE_APP_JS
|
||||
from pgadmin.utils.constants import MIMETYPE_APP_JS, SERVER_NOT_FOUND
|
||||
|
||||
MODULE_NAME = 'maintenance'
|
||||
|
||||
@ -269,7 +268,7 @@ def check_utility_exists(sid):
|
||||
if server is None:
|
||||
return make_json_response(
|
||||
success=0,
|
||||
errormsg=_("Could not find the specified server.")
|
||||
errormsg=SERVER_NOT_FOUND
|
||||
)
|
||||
|
||||
from pgadmin.utils.driver import get_driver
|
||||
|
@ -13,7 +13,6 @@ import json
|
||||
|
||||
from flask import render_template, request, current_app, Response
|
||||
from flask_babel import gettext as _
|
||||
from flask_security import current_user
|
||||
from pgadmin.user_login_check import pga_login_required
|
||||
from pgadmin.misc.bgprocess.processes import BatchProcess, IProcessDesc
|
||||
from pgadmin.utils import PgAdminModule, fs_short_path, does_utility_exist, \
|
||||
@ -22,7 +21,7 @@ from pgadmin.utils.ajax import make_json_response, bad_request, \
|
||||
internal_server_error
|
||||
|
||||
from config import PG_DEFAULT_DRIVER
|
||||
from pgadmin.utils.constants import MIMETYPE_APP_JS
|
||||
from pgadmin.utils.constants import MIMETYPE_APP_JS, SERVER_NOT_FOUND
|
||||
|
||||
# set template path for sql scripts
|
||||
MODULE_NAME = 'restore'
|
||||
@ -164,7 +163,7 @@ def _connect_server(sid):
|
||||
if server is None:
|
||||
return True, make_json_response(
|
||||
success=0,
|
||||
errormsg=_("Could not find the specified server.")
|
||||
errormsg=SERVER_NOT_FOUND
|
||||
), None, None, None, None, None
|
||||
|
||||
# To fetch MetaData for the server
|
||||
@ -427,7 +426,7 @@ def check_utility_exists(sid):
|
||||
if server is None:
|
||||
return make_json_response(
|
||||
success=0,
|
||||
errormsg=_("Could not find the specified server.")
|
||||
errormsg=SERVER_NOT_FOUND
|
||||
)
|
||||
|
||||
from pgadmin.utils.driver import get_driver
|
||||
|
@ -35,6 +35,7 @@ from pgadmin import socketio
|
||||
MODULE_NAME = 'schema_diff'
|
||||
COMPARE_MSG = gettext("Comparing objects...")
|
||||
SOCKETIO_NAMESPACE = '/{0}'.format(MODULE_NAME)
|
||||
SCH_OBJ_STR = 'Schema Objects'
|
||||
|
||||
|
||||
class SchemaDiffModule(PgAdminModule):
|
||||
@ -607,7 +608,7 @@ def compare_schema(params):
|
||||
This function will compare the two schema.
|
||||
"""
|
||||
# Check the pre validation before compare
|
||||
SchemaDiffRegistry.set_schema_diff_compare_mode('Schema Objects')
|
||||
SchemaDiffRegistry.set_schema_diff_compare_mode(SCH_OBJ_STR)
|
||||
status, error_msg, diff_model_obj, session_obj = \
|
||||
compare_pre_validation(params['trans_id'], params['source_sid'],
|
||||
params['target_sid'])
|
||||
@ -640,7 +641,7 @@ def compare_schema(params):
|
||||
target_sid=params['target_sid'],
|
||||
target_did=params['target_did'],
|
||||
target_scid=params['target_scid'],
|
||||
schema_name=gettext('Schema Objects'),
|
||||
schema_name=gettext(SCH_OBJ_STR),
|
||||
diff_model_obj=diff_model_obj,
|
||||
total_percent=total_percent,
|
||||
node_percent=node_percent,
|
||||
@ -853,7 +854,7 @@ def compare_schema_objects(**kwargs):
|
||||
for node_name, node_view in all_registered_nodes.items():
|
||||
view = SchemaDiffRegistry.get_node_view(node_name)
|
||||
if hasattr(view, 'compare'):
|
||||
if schema_name == 'Schema Objects':
|
||||
if schema_name == SCH_OBJ_STR:
|
||||
msg = gettext('Comparing {0} '). \
|
||||
format(gettext(view.blueprint.collection_label))
|
||||
else:
|
||||
|
@ -383,11 +383,11 @@ export default function SearchObjects({nodeData}) {
|
||||
})
|
||||
.catch((err)=>{
|
||||
pgAdmin.Browser.notifier.error(parseApiError(err));
|
||||
reject(err);
|
||||
reject(new Error(err));
|
||||
});
|
||||
} catch (error) {
|
||||
pgAdmin.Browser.notifier.error(parseApiError(error));
|
||||
reject(error);
|
||||
reject(new Error(error));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -312,7 +312,7 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN
|
||||
]
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
const getSQLScript = () => {
|
||||
// Fetch the SQL for Scripts (eg: CREATE/UPDATE/DELETE/SELECT)
|
||||
// Call AJAX only if script type URL is present
|
||||
@ -337,7 +337,7 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN
|
||||
setQtState({ editor_disabled: false });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const initializeQueryTool = (password)=>{
|
||||
let selectedConn = _.find(qtState.connection_list, (c)=>c.is_selected);
|
||||
let baseUrl = '';
|
||||
@ -721,7 +721,7 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN
|
||||
});
|
||||
} else {
|
||||
selectConn(currSelectedConn, currConnected, false);
|
||||
reject(error);
|
||||
reject(new Error(error));
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -763,7 +763,7 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN
|
||||
}
|
||||
updateQueryToolConnection(connectionData, true)
|
||||
.catch((err)=>{
|
||||
reject(err);
|
||||
reject(new Error(err));
|
||||
}).then(()=>{
|
||||
resolve();
|
||||
onClose();
|
||||
@ -818,7 +818,7 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN
|
||||
}}
|
||||
onClose={onClose}/>
|
||||
}, 850, 500);
|
||||
}, [qtState.preferences.browser]);
|
||||
}, [qtState.preferences.browser]);
|
||||
|
||||
const onAddToMacros = () => {
|
||||
if (selectedText){
|
||||
@ -826,7 +826,7 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN
|
||||
const existingNames = currMacros.map(macro => macro.name);
|
||||
const newName = getRandomName(existingNames);
|
||||
let changed = [{ 'name': newName, 'sql': selectedText }];
|
||||
|
||||
|
||||
api.put(
|
||||
url_for('sqleditor.set_macros', {
|
||||
'trans_id': qtState.params.trans_id,
|
||||
@ -849,7 +849,7 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN
|
||||
}
|
||||
setSelectedText('');
|
||||
};
|
||||
|
||||
|
||||
|
||||
const onFilterClick = useCallback(()=>{
|
||||
const onClose = ()=>docker.current.close('filter-dialog');
|
||||
|
@ -88,7 +88,7 @@ export default function FilterDialog({onClose, onSave}) {
|
||||
filterSchemaObj.setColumnOptions((columns||[]).map((c)=>({label: c, value: c})));
|
||||
resolve(filterData);
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
reject(new Error(error));
|
||||
}
|
||||
};
|
||||
getFilterData();
|
||||
@ -106,10 +106,10 @@ export default function FilterDialog({onClose, onSave}) {
|
||||
resolve();
|
||||
onSave();
|
||||
} else {
|
||||
reject(respData.data.result);
|
||||
reject(new Error(respData.data.result));
|
||||
}
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
reject(new Error(error));
|
||||
}
|
||||
};
|
||||
setFilterData();
|
||||
|
@ -168,7 +168,7 @@ export default function MacrosDialog({onClose, onSave}) {
|
||||
onSave(respData.filter((m) => Boolean(m.name)));
|
||||
onClose();
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
reject(new Error(error));
|
||||
}
|
||||
};
|
||||
setMacros();
|
||||
|
@ -75,7 +75,7 @@ class NewConnectionSchema extends BaseUISchema {
|
||||
resolve(groupedOptions);
|
||||
})
|
||||
.catch((error)=>{
|
||||
reject(error);
|
||||
reject(new Error(error));
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -97,7 +97,7 @@ class NewConnectionSchema extends BaseUISchema {
|
||||
resolve(respData.data.result.data);
|
||||
})
|
||||
.catch((error)=>{
|
||||
reject(error);
|
||||
reject(new Error(error));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ async function registerAutocomplete(editor, api, transId) {
|
||||
})
|
||||
.catch((err) => {
|
||||
onAvailable();
|
||||
reject(err);
|
||||
reject(new Error(err));
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -174,7 +174,7 @@ export default function Query({onTextSelect}) {
|
||||
editor.current.removeErrorMark();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
eventBus.registerListener(QUERY_TOOL_EVENTS.LOAD_FILE, (fileName, storage)=>{
|
||||
queryToolCtx.api.post(url_for('sqleditor.load_file'), {
|
||||
@ -339,7 +339,7 @@ export default function Query({onTextSelect}) {
|
||||
const formatSQL = ()=>{
|
||||
let selection = true, sql = editor.current?.getSelection();
|
||||
/* New library does not support capitalize casing
|
||||
so if a user has set capitalize casing we will
|
||||
so if a user has set capitalize casing we will
|
||||
use preserve casing which is default for the library.
|
||||
*/
|
||||
let formatPrefs = {
|
||||
@ -511,4 +511,4 @@ export default function Query({onTextSelect}) {
|
||||
|
||||
Query.propTypes = {
|
||||
onTextSelect: PropTypes.func,
|
||||
};
|
||||
};
|
||||
|
@ -24,7 +24,7 @@ import * as clipboard from '../../../../../../static/js/clipboard';
|
||||
import EmptyPanelMessage from '../../../../../../static/js/components/EmptyPanelMessage';
|
||||
|
||||
const Root = styled('div')(({ theme }) => ({
|
||||
display: 'flex',
|
||||
display: 'flex',
|
||||
height: '100%',
|
||||
'.QuerySources-leftRoot': {
|
||||
display: 'flex',
|
||||
@ -267,7 +267,7 @@ QuerySourceIcon.propTypes = {
|
||||
|
||||
function HistoryEntry({entry, formatEntryDate, itemKey, selectedItemKey, onClick}) {
|
||||
return <Root><ListItem tabIndex="0" data-label="history-entry" data-pgadmin={entry.is_pgadmin_query} ref={(ele)=>{
|
||||
selectedItemKey==itemKey && ele && ele.scrollIntoView({
|
||||
selectedItemKey==itemKey && ele?.scrollIntoView({
|
||||
block: 'center',
|
||||
behavior: 'smooth',
|
||||
});
|
||||
|
@ -638,7 +638,7 @@ export class ResultSetUtils {
|
||||
&& data.types[0] && data.types[0].typname === 'json') {
|
||||
/* json is sent as text, parse it */
|
||||
let planJson = JSON.parse(data.result[0][0]);
|
||||
if (planJson?.[0] && planJson?.[0].hasOwnProperty('Plan') &&
|
||||
if (planJson?.[0]?.hasOwnProperty('Plan') &&
|
||||
_.isObject(planJson[0]['Plan'])
|
||||
) {
|
||||
return planJson;
|
||||
|
@ -188,7 +188,7 @@ export function generateViewDataTitle(pgBrowser, treeIdentifier, custom_title=nu
|
||||
);
|
||||
|
||||
const namespaceName = retrieveNameSpaceName(parentData);
|
||||
const db_label = !_.isUndefined(backend_entity) && backend_entity != null && backend_entity.hasOwnProperty('db_name') ? backend_entity['db_name'] : getDatabaseLabel(parentData);
|
||||
const db_label = !_.isUndefined(backend_entity) && backend_entity?.hasOwnProperty('db_name') ? backend_entity['db_name'] : getDatabaseLabel(parentData);
|
||||
const node = pgBrowser.tree.findNodeByDomElement(treeIdentifier);
|
||||
|
||||
let dtg_title_placeholder = '';
|
||||
|
@ -16,6 +16,10 @@ from pgadmin.utils.constants import PREF_LABEL_DISPLAY,\
|
||||
from pgadmin.utils import SHORTCUT_FIELDS as shortcut_fields
|
||||
from config import ON_DEMAND_RECORD_COUNT
|
||||
|
||||
UPPER_CASE_STR = gettext('Upper case')
|
||||
LOWER_CASE_STR = gettext('Lower case')
|
||||
PRESERVE_STR = gettext('Preserve')
|
||||
|
||||
|
||||
def register_query_tool_preferences(self):
|
||||
self.explain_verbose = self.preference.register(
|
||||
@ -814,9 +818,9 @@ def register_query_tool_preferences(self):
|
||||
self.keyword_case = self.preference.register(
|
||||
'editor', 'keyword_case',
|
||||
gettext("Keyword case"), 'radioModern', 'upper',
|
||||
options=[{'label': gettext('Upper case'), 'value': 'upper'},
|
||||
{'label': gettext('Lower case'), 'value': 'lower'},
|
||||
{'label': gettext('Preserve'), 'value': 'preserve'}],
|
||||
options=[{'label': UPPER_CASE_STR, 'value': 'upper'},
|
||||
{'label': LOWER_CASE_STR, 'value': 'lower'},
|
||||
{'label': PRESERVE_STR, 'value': 'preserve'}],
|
||||
category_label=PREF_LABEL_SQL_FORMATTING,
|
||||
help_str=gettext(
|
||||
'Convert keywords to upper, lower, or preserve casing.'
|
||||
@ -826,9 +830,9 @@ def register_query_tool_preferences(self):
|
||||
self.identifier_case = self.preference.register(
|
||||
'editor', 'identifier_case',
|
||||
gettext("Identifier case"), 'radioModern', 'upper',
|
||||
options=[{'label': gettext('Upper case'), 'value': 'upper'},
|
||||
{'label': gettext('Lower case'), 'value': 'lower'},
|
||||
{'label': gettext('Preserve'), 'value': 'preserve'}],
|
||||
options=[{'label': UPPER_CASE_STR, 'value': 'upper'},
|
||||
{'label': LOWER_CASE_STR, 'value': 'lower'},
|
||||
{'label': PRESERVE_STR, 'value': 'preserve'}],
|
||||
category_label=PREF_LABEL_SQL_FORMATTING,
|
||||
help_str=gettext(
|
||||
'Convert identifiers to upper, lower, or preserve casing.'
|
||||
@ -838,9 +842,9 @@ def register_query_tool_preferences(self):
|
||||
self.function_case = self.preference.register(
|
||||
'editor', 'function_case',
|
||||
gettext("Function case"), 'radioModern', 'upper',
|
||||
options=[{'label': gettext('Upper case'), 'value': 'upper'},
|
||||
{'label': gettext('Lower case'), 'value': 'lower'},
|
||||
{'label': gettext('Preserve'), 'value': 'preserve'}],
|
||||
options=[{'label': UPPER_CASE_STR, 'value': 'upper'},
|
||||
{'label': LOWER_CASE_STR, 'value': 'lower'},
|
||||
{'label': PRESERVE_STR, 'value': 'preserve'}],
|
||||
category_label=PREF_LABEL_SQL_FORMATTING,
|
||||
help_str=gettext(
|
||||
'Convert function names to upper, lower, or preserve casing.'
|
||||
@ -850,9 +854,9 @@ def register_query_tool_preferences(self):
|
||||
self.data_type_case = self.preference.register(
|
||||
'editor', 'data_type_case',
|
||||
gettext("Data type case"), 'radioModern', 'upper',
|
||||
options=[{'label': gettext('Upper case'), 'value': 'upper'},
|
||||
{'label': gettext('Lower case'), 'value': 'lower'},
|
||||
{'label': gettext('Preserve'), 'value': 'preserve'}],
|
||||
options=[{'label': UPPER_CASE_STR, 'value': 'upper'},
|
||||
{'label': LOWER_CASE_STR, 'value': 'lower'},
|
||||
{'label': PRESERVE_STR, 'value': 'preserve'}],
|
||||
category_label=PREF_LABEL_SQL_FORMATTING,
|
||||
help_str=gettext(
|
||||
'Convert data types to upper, lower, or preserve casing.'
|
||||
|
@ -363,7 +363,7 @@ function UserManagementDialog({onClose}) {
|
||||
onClose();
|
||||
})
|
||||
.catch((err)=>{
|
||||
reject(err);
|
||||
reject(new Error(err));
|
||||
});
|
||||
} catch (error) {
|
||||
reject(parseApiError(error));
|
||||
@ -401,7 +401,7 @@ function UserManagementDialog({onClose}) {
|
||||
resolve({userManagement:res.data});
|
||||
})
|
||||
.catch((err)=>{
|
||||
reject(err);
|
||||
reject(new Error(err));
|
||||
});
|
||||
}); }}
|
||||
schema={new UserManagementSchema(authSourcesOptions, roleOptions)}
|
||||
|
@ -142,3 +142,8 @@ class MessageType:
|
||||
|
||||
|
||||
DBMS_JOB_SCHEDULER_ID = 999999
|
||||
|
||||
# String Constants
|
||||
IP_ADDRESS_STRING = '{}/{}'
|
||||
TWO_PARAM_STRING = '{0}/{1}'
|
||||
SERVER_NOT_FOUND = gettext("Could not find the specified server.")
|
||||
|
@ -21,6 +21,8 @@ from regression.feature_utils.locators import QueryToolLocators
|
||||
import time
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
|
||||
QUERY_HISTORY_STR = "Query History"
|
||||
|
||||
|
||||
class QueryToolJourneyTest(BaseFeatureTest):
|
||||
"""
|
||||
@ -36,7 +38,7 @@ class QueryToolJourneyTest(BaseFeatureTest):
|
||||
invalid_table_name = ""
|
||||
|
||||
select_query = "SELECT * FROM %s"
|
||||
query_history_tab_name = "Query History"
|
||||
query_history_tab_name = QUERY_HISTORY_STR
|
||||
query_history_tab_id = "id-history"
|
||||
query_editor_tab_name = "Query Editor"
|
||||
query_editor_tab_id = "id-query"
|
||||
@ -102,8 +104,8 @@ class QueryToolJourneyTest(BaseFeatureTest):
|
||||
print(" OK.", file=sys.stderr)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
self.assertTrue(False, 'Exception occurred in run test Tests the '
|
||||
'path through the query tool data' + str(e))
|
||||
raise AssertionError('Exception occurred in run test Tests the '
|
||||
'path through the query tool data' + str(e))
|
||||
|
||||
def _test_copies_rows(self):
|
||||
self.page.driver.switch_to.default_content()
|
||||
@ -153,9 +155,9 @@ class QueryToolJourneyTest(BaseFeatureTest):
|
||||
|
||||
clipboard_text = scratch_pad_ele.get_attribute("value")
|
||||
|
||||
self.assertTrue('"Some-Name"' in clipboard_text)
|
||||
self.assertTrue('"Some-Other-Name"' in clipboard_text)
|
||||
self.assertTrue('"Yet-Another-Name"' in clipboard_text)
|
||||
self.assertIn('"Some-Name"', clipboard_text)
|
||||
self.assertIn('"Some-Other-Name"', clipboard_text)
|
||||
self.assertIn('"Yet-Another-Name"', clipboard_text)
|
||||
scratch_pad_ele.clear()
|
||||
|
||||
def _test_history_tab(self):
|
||||
@ -169,7 +171,7 @@ class QueryToolJourneyTest(BaseFeatureTest):
|
||||
self.page.click_element(editor_input)
|
||||
self.page.execute_query(self.select_query % self.invalid_table_name)
|
||||
|
||||
self.page.click_tab("Query History")
|
||||
self.page.click_tab(QUERY_HISTORY_STR)
|
||||
self.page.wait_for_query_tool_loading_indicator_to_disappear(
|
||||
container_id="id-history")
|
||||
selected_history_entry = self.page.find_by_css_selector(
|
||||
@ -223,13 +225,13 @@ class QueryToolJourneyTest(BaseFeatureTest):
|
||||
QueryToolLocators.btn_execute_query_css).click()
|
||||
self.page.wait_for_query_tool_loading_indicator_to_disappear()
|
||||
|
||||
self.page.click_tab("Query History")
|
||||
self.page.click_tab(QUERY_HISTORY_STR)
|
||||
|
||||
query_list = self.page.wait_for_elements(
|
||||
lambda driver: driver.find_elements(
|
||||
By.CSS_SELECTOR, QueryToolLocators.query_history_entries))
|
||||
|
||||
self.assertTrue(17, len(query_list))
|
||||
self.assertEqual(17, len(query_list))
|
||||
|
||||
def _test_query_sources_and_generated_queries(self):
|
||||
self.__clear_query_history()
|
||||
@ -240,7 +242,7 @@ class QueryToolJourneyTest(BaseFeatureTest):
|
||||
self.page.click_tab("Query")
|
||||
self._execute_sources_test_queries()
|
||||
|
||||
self.page.click_tab("Query History")
|
||||
self.page.click_tab(QUERY_HISTORY_STR)
|
||||
|
||||
history_entries_icons = [
|
||||
'CommitIcon',
|
||||
@ -368,13 +370,12 @@ class QueryToolJourneyTest(BaseFeatureTest):
|
||||
)
|
||||
query_history_selected_item = \
|
||||
query_history_selected_item.text.split('\n')[0]
|
||||
self.assertTrue(query_history_selected_item in history_queries)
|
||||
self.assertIn(query_history_selected_item, history_queries)
|
||||
# Check source icon
|
||||
query_history_selected_icon = self.page.find_by_css_selector(
|
||||
QueryToolLocators.query_history_selected_icon)
|
||||
self.assertTrue(
|
||||
icon == query_history_selected_icon.get_attribute(
|
||||
'data-label'))
|
||||
self.assertEqual(icon, query_history_selected_icon.get_attribute(
|
||||
'data-label'))
|
||||
# Move to next entry
|
||||
ActionChains(self.page.driver) \
|
||||
.send_keys(Keys.ARROW_DOWN) \
|
||||
@ -412,7 +413,7 @@ class QueryToolJourneyTest(BaseFeatureTest):
|
||||
)
|
||||
|
||||
def __clear_query_history(self):
|
||||
self.page.click_tab("Query History")
|
||||
self.page.click_tab(QUERY_HISTORY_STR)
|
||||
self.page.wait_for_query_tool_loading_indicator_to_disappear(
|
||||
container_id="id-history")
|
||||
self.page.click_element(
|
||||
|
@ -15,12 +15,14 @@ from selenium.common.exceptions import StaleElementReferenceException, \
|
||||
from selenium.webdriver.support.ui import WebDriverWait
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
from selenium.webdriver.common.by import By
|
||||
from regression.python_test_utils import test_utils
|
||||
from regression.feature_utils.base_feature_test import BaseFeatureTest
|
||||
import config
|
||||
from regression.feature_utils.locators import \
|
||||
QueryToolLocators
|
||||
|
||||
DATA_OUTPUT_STR = "Data Output"
|
||||
CREATE_TABLE_STR = 'CREATE TABLE'
|
||||
|
||||
|
||||
class QueryToolFeatureTest(BaseFeatureTest):
|
||||
"""
|
||||
@ -257,7 +259,7 @@ SELECT generate_series(1, 1000) as id order by id desc"""
|
||||
|
||||
self.page.wait_for_query_tool_loading_indicator_to_disappear()
|
||||
|
||||
self.page.click_tab("Data Output")
|
||||
self.page.click_tab(DATA_OUTPUT_STR)
|
||||
|
||||
canvas = self.wait.until(EC.presence_of_element_located(
|
||||
(By.CSS_SELECTOR, QueryToolLocators.query_output_canvas_css))
|
||||
@ -292,7 +294,7 @@ SELECT generate_series(1, 1000) as id order by id desc"""
|
||||
|
||||
self.page.wait_for_query_tool_loading_indicator_to_disappear()
|
||||
|
||||
self.page.click_tab("Data Output")
|
||||
self.page.click_tab(DATA_OUTPUT_STR)
|
||||
|
||||
self.wait.until(EC.presence_of_element_located(
|
||||
(By.XPATH, QueryToolLocators.output_cell_xpath.format(2, 2)))
|
||||
@ -332,7 +334,7 @@ CREATE TABLE public.{}();""".format(table_name)
|
||||
self.page.click_tab('Messages')
|
||||
|
||||
self.assertTrue(self.page.check_if_element_exist_by_xpath(
|
||||
QueryToolLocators.sql_editor_message.format('CREATE TABLE')),
|
||||
QueryToolLocators.sql_editor_message.format(CREATE_TABLE_STR)),
|
||||
self.table_creation_fail_error)
|
||||
|
||||
# do the ROLLBACK and check if the table is present or not
|
||||
@ -357,7 +359,7 @@ SELECT relname FROM pg_catalog.pg_class
|
||||
WHERE relkind IN ('r','s','t') and relnamespace = 2200::oid;"""
|
||||
|
||||
self.page.execute_query(query)
|
||||
self.page.click_tab("Data Output")
|
||||
self.page.click_tab(DATA_OUTPUT_STR)
|
||||
canvas = self.wait.until(EC.presence_of_element_located(
|
||||
(By.CSS_SELECTOR, QueryToolLocators.query_output_canvas_css)))
|
||||
|
||||
@ -413,7 +415,7 @@ CREATE TABLE public.{}();""".format(table_name)
|
||||
self.page.wait_for_query_tool_loading_indicator_to_disappear()
|
||||
self.page.click_tab('Messages')
|
||||
self.assertTrue(self.page.check_if_element_exist_by_xpath(
|
||||
QueryToolLocators.sql_editor_message.format('CREATE TABLE')),
|
||||
QueryToolLocators.sql_editor_message.format(CREATE_TABLE_STR)),
|
||||
self.table_creation_fail_error)
|
||||
|
||||
self.page.clear_query_tool()
|
||||
@ -441,7 +443,7 @@ SELECT relname FROM pg_catalog.pg_class
|
||||
WHERE relkind IN ('r','s','t') and relnamespace = 2200::oid;"""
|
||||
|
||||
self.page.execute_query(query)
|
||||
self.page.click_tab("Data Output")
|
||||
self.page.click_tab(DATA_OUTPUT_STR)
|
||||
self.page.wait_for_query_tool_loading_indicator_to_disappear()
|
||||
|
||||
canvas = self.wait.until(EC.presence_of_element_located(
|
||||
@ -492,7 +494,7 @@ CREATE TABLE public.{}();""".format(table_name)
|
||||
self.page.wait_for_query_tool_loading_indicator_to_disappear()
|
||||
self.page.click_tab('Messages')
|
||||
self.assertTrue(self.page.check_if_element_exist_by_xpath(
|
||||
QueryToolLocators.sql_editor_message.format('CREATE TABLE')),
|
||||
QueryToolLocators.sql_editor_message.format(CREATE_TABLE_STR)),
|
||||
self.table_creation_fail_error)
|
||||
self.page.clear_query_tool()
|
||||
|
||||
@ -537,7 +539,7 @@ SELECT relname FROM pg_catalog.pg_class
|
||||
WHERE relkind IN ('r','s','t') and relnamespace = 2200::oid;"""
|
||||
self.page.execute_query(query)
|
||||
self.page.wait_for_query_tool_loading_indicator_to_disappear()
|
||||
self.page.click_tab("Data Output")
|
||||
self.page.click_tab(DATA_OUTPUT_STR)
|
||||
canvas = self.wait.until(EC.presence_of_element_located(
|
||||
(By.CSS_SELECTOR, QueryToolLocators.query_output_canvas_css)))
|
||||
|
||||
|
@ -19,6 +19,7 @@ import config as app_config
|
||||
from pgadmin.utils.route import BaseTestGenerator
|
||||
from regression.feature_utils.pgadmin_page import PgadminPage
|
||||
from regression.python_test_utils import test_utils
|
||||
from pgadmin.utils.constants import TWO_PARAM_STRING
|
||||
|
||||
|
||||
class BaseFeatureTest(BaseTestGenerator):
|
||||
@ -86,7 +87,7 @@ class BaseFeatureTest(BaseTestGenerator):
|
||||
|
||||
def _screenshot(self):
|
||||
screenshots_directory = '{0}/../screenshots'.format(self.CURRENT_PATH)
|
||||
screenshots_server_directory = '{0}/{1}'.format(
|
||||
screenshots_server_directory = TWO_PARAM_STRING.format(
|
||||
screenshots_directory,
|
||||
self.server["name"].replace(" ", "_")
|
||||
)
|
||||
|
18
web/setup.py
18
web/setup.py
@ -54,6 +54,8 @@ from flask_babel import gettext
|
||||
|
||||
|
||||
app = typer.Typer(pretty_exceptions_show_locals=False)
|
||||
USER_NOT_FOUND_STR = "User not found"
|
||||
SOMETHING_WENT_WRONG = 'Something went wrong. '
|
||||
|
||||
|
||||
def update_sqlite_path(f):
|
||||
@ -216,13 +218,13 @@ class ManageUsers:
|
||||
uid = ManageUsers.get_user(username=username,
|
||||
auth_source=auth_source)
|
||||
if not uid:
|
||||
print("User not found")
|
||||
print(USER_NOT_FOUND_STR)
|
||||
else:
|
||||
status, msg = delete_user(uid)
|
||||
if status:
|
||||
print('User deleted successfully.')
|
||||
else:
|
||||
print('Something went wrong. ' + str(msg))
|
||||
print(SOMETHING_WENT_WRONG + str(msg))
|
||||
|
||||
@app.command()
|
||||
@update_sqlite_path
|
||||
@ -260,7 +262,7 @@ class ManageUsers:
|
||||
uid = ManageUsers.get_user(username=email,
|
||||
auth_source=INTERNAL)
|
||||
if not uid:
|
||||
print("User not found")
|
||||
print(USER_NOT_FOUND_STR)
|
||||
else:
|
||||
status, msg = user_management_update_user(uid, data)
|
||||
if status:
|
||||
@ -269,7 +271,7 @@ class ManageUsers:
|
||||
console=False)
|
||||
ManageUsers.display_user(_user[0], console, json)
|
||||
else:
|
||||
print('Something went wrong. ' + str(msg))
|
||||
print(SOMETHING_WENT_WRONG + str(msg))
|
||||
|
||||
@app.command()
|
||||
@update_sqlite_path
|
||||
@ -346,7 +348,7 @@ class ManageUsers:
|
||||
uid = ManageUsers.get_user(username=username,
|
||||
auth_source=auth_source)
|
||||
if not uid:
|
||||
print("User not found")
|
||||
print(USER_NOT_FOUND_STR)
|
||||
else:
|
||||
status, msg = user_management_update_user(uid, data)
|
||||
if status:
|
||||
@ -357,7 +359,7 @@ class ManageUsers:
|
||||
)
|
||||
ManageUsers.display_user(_user[0], console, json)
|
||||
else:
|
||||
print('Something went wrong. ' + str(msg))
|
||||
print(SOMETHING_WENT_WRONG + str(msg))
|
||||
|
||||
def create_user(data, console, json):
|
||||
app = create_app(config.APP_NAME + '-cli')
|
||||
@ -378,7 +380,7 @@ class ManageUsers:
|
||||
if status:
|
||||
ManageUsers.display_user(data, console, json)
|
||||
else:
|
||||
print('Something went wrong. ' + str(msg))
|
||||
print(SOMETHING_WENT_WRONG + str(msg))
|
||||
|
||||
def get_user(username=None, auth_source=INTERNAL):
|
||||
app = create_app(config.APP_NAME + '-cli')
|
||||
@ -524,7 +526,7 @@ class ManagePreferences:
|
||||
table = Table(title="Updated Pref Details", box=box.ASCII)
|
||||
table.add_column("Preference", style="green")
|
||||
if not user_id:
|
||||
print("User not found.")
|
||||
print(USER_NOT_FOUND_STR)
|
||||
return
|
||||
|
||||
prefs = ManagePreferences.fetch_prefs(True)
|
||||
|
@ -15910,11 +15910,11 @@ __metadata:
|
||||
|
||||
"typescript@patch:typescript@^5.4.5#~builtin<compat/typescript>":
|
||||
version: 5.4.5
|
||||
resolution: "typescript@patch:typescript@npm%3A5.4.5#~builtin<compat/typescript>::version=5.4.5&hash=5adc0c"
|
||||
resolution: "typescript@patch:typescript@npm%3A5.4.5#~builtin<compat/typescript>::version=5.4.5&hash=e012d7"
|
||||
bin:
|
||||
tsc: bin/tsc
|
||||
tsserver: bin/tsserver
|
||||
checksum: d59e26e74f6b444517d0ba16e0ee16e75c652c2b49a59f2ebdbeb16647a855fd50c7fc786a58987e45f03bce0677092e2dd3333649fd53b11d0b0d271455837c
|
||||
checksum: 2373c693f3b328f3b2387c3efafe6d257b057a142f9a79291854b14ff4d5367d3d730810aee981726b677ae0fd8329b23309da3b6aaab8263dbdccf1da07a3ba
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user