mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixed some SonarQube issues.
This commit is contained in:
parent
af1e9210b9
commit
71a4b20d90
@ -16,13 +16,62 @@ import _ from 'underscore';
|
|||||||
import getApiInstance from 'sources/api_instance';
|
import getApiInstance from 'sources/api_instance';
|
||||||
import { isEmptyString } from 'sources/validators';
|
import { isEmptyString } from 'sources/validators';
|
||||||
|
|
||||||
|
function isTlengthEditable(state, options) {
|
||||||
|
// We will store type from selected from combobox
|
||||||
|
let of_type = state.type;
|
||||||
|
// iterating over all the types
|
||||||
|
_.each(options, function(o) {
|
||||||
|
// if type from selected from combobox matches in options
|
||||||
|
if ( of_type == o.value ) {
|
||||||
|
// if length is allowed for selected type
|
||||||
|
if(o.length)
|
||||||
|
{
|
||||||
|
// set the values in state
|
||||||
|
state.is_tlength = true;
|
||||||
|
state.min_val = o.min_val;
|
||||||
|
state.max_val = o.max_val;
|
||||||
|
} else {
|
||||||
|
// set the values in state
|
||||||
|
state.is_tlength = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return state.is_tlength;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isPrecisionEditable(state, options) {
|
||||||
|
// We will store type from selected from combobox
|
||||||
|
let of_type = state.type;
|
||||||
|
// iterating over all the types
|
||||||
|
_.each(options, function(o) {
|
||||||
|
// if type from selected from combobox matches in options
|
||||||
|
if ( of_type == o.value ) {
|
||||||
|
// if precession is allowed for selected type
|
||||||
|
if(o.precision)
|
||||||
|
{
|
||||||
|
// set the values in model
|
||||||
|
state.is_precision = true;
|
||||||
|
state.min_val = o.min_val;
|
||||||
|
state.max_val = o.max_val;
|
||||||
|
} else {
|
||||||
|
// set the values in model
|
||||||
|
state.is_precision = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return state.is_precision;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTypes(nodeObj, treeNodeInfo, itemNodeData) {
|
||||||
|
return getNodeAjaxOptions('get_types', nodeObj, treeNodeInfo, itemNodeData, {
|
||||||
|
cacheLevel: 'domain'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function getCompositeSchema(nodeObj, treeNodeInfo, itemNodeData) {
|
function getCompositeSchema(nodeObj, treeNodeInfo, itemNodeData) {
|
||||||
return new CompositeSchema(
|
return new CompositeSchema(
|
||||||
{
|
{
|
||||||
types: () => getNodeAjaxOptions('get_types', nodeObj, treeNodeInfo, itemNodeData, {
|
types: () => { return getTypes(nodeObj, treeNodeInfo, itemNodeData); },
|
||||||
cacheLevel: 'domain'
|
|
||||||
}),
|
|
||||||
collations: () => getNodeAjaxOptions('get_collations', nodeObj, treeNodeInfo, itemNodeData)
|
collations: () => getNodeAjaxOptions('get_collations', nodeObj, treeNodeInfo, itemNodeData)
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -126,9 +175,7 @@ function getExternalSchema(nodeObj, treeNodeInfo, itemNodeData) {
|
|||||||
return new ExternalSchema(
|
return new ExternalSchema(
|
||||||
{
|
{
|
||||||
externalFunctionsList: () => getNodeAjaxOptions('get_external_functions', nodeObj, treeNodeInfo, itemNodeData),
|
externalFunctionsList: () => getNodeAjaxOptions('get_external_functions', nodeObj, treeNodeInfo, itemNodeData),
|
||||||
types: () => getNodeAjaxOptions('get_types', nodeObj, treeNodeInfo, itemNodeData, {
|
types: () => { return getTypes(nodeObj, treeNodeInfo, itemNodeData); },
|
||||||
cacheLevel: 'domain'
|
|
||||||
})
|
|
||||||
}, {
|
}, {
|
||||||
node_info: treeNodeInfo
|
node_info: treeNodeInfo
|
||||||
}
|
}
|
||||||
@ -138,9 +185,7 @@ function getExternalSchema(nodeObj, treeNodeInfo, itemNodeData) {
|
|||||||
function getDataTypeSchema(nodeObj, treeNodeInfo, itemNodeData) {
|
function getDataTypeSchema(nodeObj, treeNodeInfo, itemNodeData) {
|
||||||
return new DataTypeSchema(
|
return new DataTypeSchema(
|
||||||
{
|
{
|
||||||
types: () => getNodeAjaxOptions('get_types', nodeObj, treeNodeInfo, itemNodeData, {
|
types: () => { return getTypes(nodeObj, treeNodeInfo, itemNodeData); }
|
||||||
cacheLevel: 'domain'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -877,30 +922,9 @@ class CompositeSchema extends BaseUISchema {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
editable: (state) => {
|
editable: (state)=>{
|
||||||
// We will store type from selected from combobox
|
return isTlengthEditable(state, obj.type_options);
|
||||||
var of_type = state.type;
|
}
|
||||||
if(obj.type_options) {
|
|
||||||
// iterating over all the types
|
|
||||||
_.each(obj.type_options, function(o) {
|
|
||||||
// if type from selected from combobox matches in options
|
|
||||||
if ( of_type == o.value ) {
|
|
||||||
// if length is allowed for selected type
|
|
||||||
if(o.length)
|
|
||||||
{
|
|
||||||
// set the values in state
|
|
||||||
state.is_tlength = true;
|
|
||||||
state.min_val = o.min_val;
|
|
||||||
state.max_val = o.max_val;
|
|
||||||
} else {
|
|
||||||
// set the values in state
|
|
||||||
state.is_tlength = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return state.is_tlength;
|
|
||||||
},
|
|
||||||
}, {
|
}, {
|
||||||
// Note: There are ambiguities in the PG catalogs and docs between
|
// Note: There are ambiguities in the PG catalogs and docs between
|
||||||
// precision and scale. In the UI, we try to follow the docs as
|
// precision and scale. In the UI, we try to follow the docs as
|
||||||
@ -911,28 +935,7 @@ class CompositeSchema extends BaseUISchema {
|
|||||||
return obj.onTypeChange(state, changeSource);
|
return obj.onTypeChange(state, changeSource);
|
||||||
},
|
},
|
||||||
editable: (state) => {
|
editable: (state) => {
|
||||||
// We will store type from selected from combobox
|
return isPrecisionEditable(state, obj.type_options);
|
||||||
var of_type = state.type;
|
|
||||||
if(obj.type_options) {
|
|
||||||
// iterating over all the types
|
|
||||||
_.each(obj.type_options, function(o) {
|
|
||||||
// if type from selected from combobox matches in options
|
|
||||||
if ( of_type == o.value ) {
|
|
||||||
// if precession is allowed for selected type
|
|
||||||
if(o.precision)
|
|
||||||
{
|
|
||||||
// set the values in state
|
|
||||||
state.is_precision = true;
|
|
||||||
state.min_val = o.min_val;
|
|
||||||
state.max_val = o.max_val;
|
|
||||||
} else {
|
|
||||||
// set the values in state
|
|
||||||
state.is_precision = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return state.is_precision;
|
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
id: 'collation', label: gettext('Collation'), type: 'text',
|
id: 'collation', label: gettext('Collation'), type: 'text',
|
||||||
@ -1106,28 +1109,9 @@ class DataTypeSchema extends BaseUISchema {
|
|||||||
}, 10);
|
}, 10);
|
||||||
return flag;
|
return flag;
|
||||||
},
|
},
|
||||||
editable: function(state) {
|
editable: (state)=>{
|
||||||
// We will store type from selected from combobox
|
let options = state.type_options;
|
||||||
var of_type = state.type;
|
return isTlengthEditable(state, options);
|
||||||
if (state.type_options) {
|
|
||||||
// iterating over all the types
|
|
||||||
_.each(state.type_options, function (o) {
|
|
||||||
// if type from selected from combobox matches in options
|
|
||||||
if (of_type == o.value) {
|
|
||||||
// if length is allowed for selected type
|
|
||||||
if (o.length) {
|
|
||||||
// set the values in state
|
|
||||||
state.is_tlength = true;
|
|
||||||
state.min_val = o.min_val;
|
|
||||||
state.max_val = o.max_val;
|
|
||||||
} else {
|
|
||||||
// set the values in staet
|
|
||||||
state.is_tlength = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return state.is_tlength;
|
|
||||||
}
|
}
|
||||||
},{
|
},{
|
||||||
// Note: There are ambiguities in the PG catalogs and docs between
|
// Note: There are ambiguities in the PG catalogs and docs between
|
||||||
@ -1165,28 +1149,8 @@ class DataTypeSchema extends BaseUISchema {
|
|||||||
return flag;
|
return flag;
|
||||||
},
|
},
|
||||||
editable: function(state) {
|
editable: function(state) {
|
||||||
// We will store type from selected from combobox
|
let options = state.type_options;
|
||||||
var of_type = state.type;
|
return isPrecisionEditable(state, options);
|
||||||
if(state.type_options) {
|
|
||||||
// iterating over all the types
|
|
||||||
_.each(state.type_options, function(o) {
|
|
||||||
// if type from selected from combobox matches in options
|
|
||||||
if ( of_type == o.value ) {
|
|
||||||
// if precession is allowed for selected type
|
|
||||||
if(o.precision)
|
|
||||||
{
|
|
||||||
// set the values in model
|
|
||||||
state.is_precision = true;
|
|
||||||
state.min_val = o.min_val;
|
|
||||||
state.max_val = o.max_val;
|
|
||||||
} else {
|
|
||||||
// set the values in model
|
|
||||||
state.is_precision = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return state.is_precision;
|
|
||||||
},
|
},
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
@ -1236,8 +1200,7 @@ export default class TypeSchema extends BaseUISchema {
|
|||||||
}
|
}
|
||||||
|
|
||||||
schemaCheck(state) {
|
schemaCheck(state) {
|
||||||
if(this.fieldOptions.node_info && 'schema' in this.fieldOptions.node_info)
|
if(this.fieldOptions.node_info && this.fieldOptions.node_info?.schema) {
|
||||||
{
|
|
||||||
if(!state)
|
if(!state)
|
||||||
return true;
|
return true;
|
||||||
if (this.isNew(state)) {
|
if (this.isNew(state)) {
|
||||||
|
@ -115,8 +115,8 @@ export function getUtilityView(schema, treeNodeInfo, actionType, formType, conta
|
|||||||
console.error('error req', err.request);
|
console.error('error req', err.request);
|
||||||
} else if(err.message){
|
} else if(err.message){
|
||||||
console.error('error msg', err.message);
|
console.error('error msg', err.message);
|
||||||
}reject(err);
|
}
|
||||||
|
reject(err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ class CheckRoleMembershipControlFeatureTest(BaseFeatureTest):
|
|||||||
]
|
]
|
||||||
|
|
||||||
role = ""
|
role = ""
|
||||||
|
xss_test_role = "<h1>test</h1>"
|
||||||
|
|
||||||
def before(self):
|
def before(self):
|
||||||
with test_utils.Database(self.server) as (connection, _):
|
with test_utils.Database(self.server) as (connection, _):
|
||||||
@ -40,10 +41,9 @@ class CheckRoleMembershipControlFeatureTest(BaseFeatureTest):
|
|||||||
# Some test function is needed for debugger
|
# Some test function is needed for debugger
|
||||||
test_utils.create_role(self.server, "postgres",
|
test_utils.create_role(self.server, "postgres",
|
||||||
self.role)
|
self.role)
|
||||||
test_utils.create_role(self.server, "postgres",
|
test_utils.create_role(self.server, "postgres", self.xss_test_role)
|
||||||
"<h1>test</h1>")
|
|
||||||
test_utils.grant_role(self.server, "postgres",
|
test_utils.grant_role(self.server, "postgres",
|
||||||
self.role, "<h1>test</h1>")
|
self.role, self.xss_test_role)
|
||||||
self.wait = WebDriverWait(self.page.driver, 20)
|
self.wait = WebDriverWait(self.page.driver, 20)
|
||||||
|
|
||||||
def runTest(self):
|
def runTest(self):
|
||||||
@ -56,8 +56,7 @@ class CheckRoleMembershipControlFeatureTest(BaseFeatureTest):
|
|||||||
self.page.remove_server(self.server)
|
self.page.remove_server(self.server)
|
||||||
test_utils.drop_role(self.server, "postgres",
|
test_utils.drop_role(self.server, "postgres",
|
||||||
self.role)
|
self.role)
|
||||||
test_utils.drop_role(self.server, "postgres",
|
test_utils.drop_role(self.server, "postgres",self.xss_test_role)
|
||||||
"<h1>test</h1>")
|
|
||||||
|
|
||||||
def _role_node_expandable(self, role):
|
def _role_node_expandable(self, role):
|
||||||
retry = 3
|
retry = 3
|
||||||
|
@ -84,7 +84,7 @@ define('pgadmin.misc.cloud', [
|
|||||||
const axiosApi = getApiInstance();
|
const axiosApi = getApiInstance();
|
||||||
let _url = url_for('cloud.clear_cloud_session');
|
let _url = url_for('cloud.clear_cloud_session');
|
||||||
axiosApi.post(_url)
|
axiosApi.post(_url)
|
||||||
.then(() => {})
|
.then(() => {/*This is intentional (SonarQube)*/})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
Notifier.error(gettext(`Error while clearing cloud wizard data: ${error.response.data.errormsg}`));
|
Notifier.error(gettext(`Error while clearing cloud wizard data: ${error.response.data.errormsg}`));
|
||||||
});
|
});
|
||||||
|
@ -66,7 +66,7 @@ PolyLine.propTypes = {
|
|||||||
function Multitext({currentXpos, currentYpos, label, maxWidth}) {
|
function Multitext({currentXpos, currentYpos, label, maxWidth}) {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
let abc = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
let abc = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||||
var xmlns = 'https://www.w3.org/2000/svg';
|
var xmlns = 'http://www.w3.org/2000/svg';
|
||||||
var svgElem = document.createElementNS(xmlns, 'svg');
|
var svgElem = document.createElementNS(xmlns, 'svg');
|
||||||
svgElem.setAttributeNS(xmlns, 'height', '100%');
|
svgElem.setAttributeNS(xmlns, 'height', '100%');
|
||||||
svgElem.setAttributeNS(xmlns, 'width', '100%');
|
svgElem.setAttributeNS(xmlns, 'width', '100%');
|
||||||
@ -387,7 +387,7 @@ export default function Graphical({planData, ctx}) {
|
|||||||
|
|
||||||
const onDownloadClick = ()=>{
|
const onDownloadClick = ()=>{
|
||||||
downloadSvg(ReactDOMServer.renderToStaticMarkup(
|
downloadSvg(ReactDOMServer.renderToStaticMarkup(
|
||||||
<PlanSVG planData={planData} download={true} ctx={ctx} zoomFactor={INIT_ZOOM_FACTOR} onNodeClick={()=>{}}/>
|
<PlanSVG planData={planData} download={true} ctx={ctx} zoomFactor={INIT_ZOOM_FACTOR} onNodeClick={()=>{/*This is intentional (SonarQube)*/}}/>
|
||||||
), 'explain_plan_' + (new Date()).getTime() + '.svg');
|
), 'explain_plan_' + (new Date()).getTime() + '.svg');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -442,27 +442,25 @@ function parsePlanData(data, ctx) {
|
|||||||
'Triggers': [],
|
'Triggers': [],
|
||||||
'Summary': {},
|
'Summary': {},
|
||||||
};
|
};
|
||||||
if (data && 'JIT' in data) {
|
if ('JIT' in data) {
|
||||||
retPlan['Statistics']['JIT'] = retPlan['JIT'];
|
retPlan['Statistics']['JIT'] = retPlan['JIT'];
|
||||||
}
|
}
|
||||||
if (data && 'Triggers' in data) {
|
if ('Triggers' in data) {
|
||||||
retPlan['Statistics']['Triggers'] = retPlan['JITriggersT'];
|
retPlan['Statistics']['Triggers'] = retPlan['JITriggersT'];
|
||||||
}
|
}
|
||||||
if(data) {
|
if ('Settings' in data) {
|
||||||
let summKeys = ['Planning Time', 'Execution Time'],
|
|
||||||
summary = {};
|
|
||||||
|
|
||||||
summKeys.forEach((key)=>{
|
|
||||||
if (key in data) {
|
|
||||||
summary[key] = data[key];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
retPlan['Statistics']['Summary'] = summary;
|
|
||||||
}
|
|
||||||
if (data && 'Settings' in data) {
|
|
||||||
retPlan['Statistics']['Settings'] = data['Settings'];
|
retPlan['Statistics']['Settings'] = data['Settings'];
|
||||||
}
|
}
|
||||||
|
let summKeys = ['Planning Time', 'Execution Time'],
|
||||||
|
summary = {};
|
||||||
|
|
||||||
|
summKeys.forEach((key)=>{
|
||||||
|
if (key in data) {
|
||||||
|
summary[key] = data[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
retPlan['Statistics']['Summary'] = summary;
|
||||||
|
|
||||||
parseExplainTableData(retPlan['Plan'], ctx);
|
parseExplainTableData(retPlan['Plan'], ctx);
|
||||||
}
|
}
|
||||||
|
@ -29,14 +29,14 @@ import ModalProvider from '../../../../static/js/helpers/ModalProvider';
|
|||||||
import DebuggerComponent from './components/DebuggerComponent';
|
import DebuggerComponent from './components/DebuggerComponent';
|
||||||
import Theme from '../../../../static/js/Theme';
|
import Theme from '../../../../static/js/Theme';
|
||||||
|
|
||||||
export default class Debugger {
|
export default class DebuggerModule {
|
||||||
static instance;
|
static instance;
|
||||||
|
|
||||||
static getInstance(...args) {
|
static getInstance(...args) {
|
||||||
if (!Debugger.instance) {
|
if (!DebuggerModule.instance) {
|
||||||
Debugger.instance = new Debugger(...args);
|
DebuggerModule.instance = new DebuggerModule(...args);
|
||||||
}
|
}
|
||||||
return Debugger.instance;
|
return DebuggerModule.instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(pgAdmin, pgBrowser) {
|
constructor(pgAdmin, pgBrowser) {
|
||||||
|
@ -556,6 +556,7 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN
|
|||||||
}, isNew)
|
}, isNew)
|
||||||
);
|
);
|
||||||
}, ()=>{
|
}, ()=>{
|
||||||
|
/*This is intentional (SonarQube)*/
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
selectConn(currSelectedConn, currConnected, false);
|
selectConn(currSelectedConn, currConnected, false);
|
||||||
|
@ -386,7 +386,7 @@ UserManagementDialog.propTypes = {
|
|||||||
onClose: PropTypes.func
|
onClose: PropTypes.func
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function showUserManagement() {
|
export function showUserManagement() {
|
||||||
pgAdmin.Browser.Node.registerUtilityPanel();
|
pgAdmin.Browser.Node.registerUtilityPanel();
|
||||||
let panel = pgAdmin.Browser.Node.addUtilityPanel(980, pgAdmin.Browser.stdH.md),
|
let panel = pgAdmin.Browser.Node.addUtilityPanel(980, pgAdmin.Browser.stdH.md),
|
||||||
j = panel.$container.find('.obj_properties').first();
|
j = panel.$container.find('.obj_properties').first();
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
import pgAdmin from 'sources/pgadmin';
|
import pgAdmin from 'sources/pgadmin';
|
||||||
import gettext from 'sources/gettext';
|
import gettext from 'sources/gettext';
|
||||||
import { showUrlDialog } from '../../../../static/js/Dialogs/index';
|
import { showUrlDialog } from '../../../../static/js/Dialogs/index';
|
||||||
import showUserManagement from './UserManagementDialog';
|
import { showUserManagement } from './UserManagementDialog';
|
||||||
|
|
||||||
|
|
||||||
class UserManagement {
|
class UserManagement {
|
||||||
@ -49,4 +49,4 @@ pgAdmin.UserManagement = UserManagement.getInstance();
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
UserManagement: UserManagement,
|
UserManagement: UserManagement,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user