Fixed code smell 'Variables should not be shadowed'.

Fixed all the duplicate CSS blocks issues raised by SonarQube.
pull/33/head
Aditya Toshniwal 2020-07-14 15:45:01 +05:30 committed by Akshay Joshi
parent 0013a3b047
commit 161c9b0fc7
11 changed files with 118 additions and 165 deletions

View File

@ -408,11 +408,11 @@ define('pgadmin.browser.node', [
var msgDiv = '<div role="status" class="pg-panel-message pg-panel-properties-message">' +
gettext('Retrieving data from the server...') + '</div>',
$msgDiv = $(msgDiv);
var timer = setTimeout(function(ctx) {
var timer = setTimeout(function(_ctx) {
// notify user if request is taking longer than 1 second
if (!_.isUndefined(ctx)) {
$msgDiv.appendTo(ctx);
if (!_.isUndefined(_ctx)) {
$msgDiv.appendTo(_ctx);
}
}, 1000, ctx);
@ -584,17 +584,16 @@ define('pgadmin.browser.node', [
var self = this,
isParent = (_.isArray(this.parent_type) ?
function(d) {
return (_.indexOf(self.parent_type, d._type) != -1);
} : function(d) {
return (self.parent_type == d._type);
function(_d) {
return (_.indexOf(self.parent_type, _d._type) != -1);
} : function(_d) {
return (self.parent_type == _d._type);
}),
addPanel = function() {
var d = window.document,
b = d.body,
el = d.createElement('div');
var body = window.document.body,
el = document.createElement('div');
d.body.insertBefore(el, d.body.firstChild);
body.insertBefore(el, body.firstChild);
let w, h, x, y;
if(screen.width < 800) {
@ -637,8 +636,8 @@ define('pgadmin.browser.node', [
}
}
x = (b.offsetWidth - w) / 2;
y = (b.offsetHeight - h) / 4;
x = (body.offsetWidth - w) / 2;
y = (body.offsetHeight - h) / 4;
// If the screen resolution is higher, but - it is zoomed, dialog
// may be go out of window, and will not be accessible through the
@ -652,7 +651,7 @@ define('pgadmin.browser.node', [
h = window.innerHeight;
}
var p = pgBrowser.docker.addPanel(
var new_panel = pgBrowser.docker.addPanel(
'node_props', wcDocker.DOCK.FLOAT, undefined, {
w: w + 'px',
h: h + 'px',
@ -661,9 +660,9 @@ define('pgadmin.browser.node', [
}
);
b.removeChild(el);
body.removeChild(el);
return p;
return new_panel;
};
if (args.action == 'create') {
@ -824,18 +823,18 @@ define('pgadmin.browser.node', [
return true;
})
.fail(function(jqx) {
var msg = jqx.responseText;
var errmsg = jqx.responseText;
/* Error from the server */
if (jqx.status == 417 || jqx.status == 410 || jqx.status == 500) {
try {
var data = JSON.parse(jqx.responseText);
msg = data.info || data.errormsg;
errmsg = data.info || data.errormsg;
} catch (e) {
console.warn(e.stack || e);
}
}
pgBrowser.report_error(
gettext('Error dropping/removing %s: "%s"', obj.label, objName), msg);
gettext('Error dropping/removing %s: "%s"', obj.label, objName), errmsg);
});
},
@ -1179,18 +1178,17 @@ define('pgadmin.browser.node', [
properties = function() {
// Avoid unnecessary reloads
var panel = this,
i = tree.selected(),
var i = tree.selected(),
d = i && tree.itemData(i),
n = i && d && pgBrowser.Nodes[d._type],
treeHierarchy = n.getTreeNodeHierarchy(i);
if (_.isEqual($(panel).data('node-prop'), treeHierarchy)) {
if (_.isEqual($(this).data('node-prop'), treeHierarchy)) {
return;
}
// Cache the current IDs for next time
$(panel).data('node-prop', treeHierarchy);
$(this).data('node-prop', treeHierarchy);
if (!content.hasClass('has-pg-prop-btn-group'))
content.addClass('has-pg-prop-btn-group');
@ -1290,13 +1288,13 @@ define('pgadmin.browser.node', [
}.bind(panel),
warnBeforeChangesLost = function(warn_text, yes_callback) {
var j = this.$container.find('.obj_properties').first(),
view = j && j.data('obj-view'),
var $props = this.$container.find('.obj_properties').first(),
objview = $props && $props.data('obj-view'),
self = this;
let confirm_on_properties_close = pgBrowser.get_preferences_for_module('browser').confirm_on_properties_close;
if (confirm_on_properties_close && confirm_close && view && view.model) {
if(view.model.sessChanged()){
if (confirm_on_properties_close && confirm_close && objview && objview.model) {
if(objview.model.sessChanged()){
Alertify.confirm(
gettext('Warning'),
warn_text,
@ -1323,14 +1321,14 @@ define('pgadmin.browser.node', [
}.bind(panel),
warnBeforeAttributeChange = function(yes_callback) {
var j = this.$container.find('.obj_properties').first(),
view = j && j.data('obj-view'),
var $props = this.$container.find('.obj_properties').first(),
objview = $props && $props.data('obj-view'),
self = this;
if (view && view.model && !_.isUndefined(view.model.warn_text) && !_.isNull(view.model.warn_text)) {
if (objview && objview.model && !_.isUndefined(objview.model.warn_text) && !_.isNull(objview.model.warn_text)) {
let warn_text;
warn_text = gettext(view.model.warn_text);
if(view.model.sessChanged()){
warn_text = gettext(objview.model.warn_text);
if(objview.model.sessChanged()){
Alertify.confirm(
gettext('Warning'),
warn_text,
@ -1357,13 +1355,13 @@ define('pgadmin.browser.node', [
}.bind(panel),
informBeforeAttributeChange = function(ok_callback) {
var obj = this.$container.find('.obj_properties').first();
view = obj && obj .data('obj-view');
var $props = this.$container.find('.obj_properties').first(),
objview = $props && $props.data('obj-view');
if (view && view.model && !_.isUndefined(view.model.inform_text) && !_.isNull(view.model.inform_text)) {
if (objview && objview.model && !_.isUndefined(objview.model.inform_text) && !_.isNull(objview.model.inform_text)) {
Alertify.alert(
gettext('Warning'),
gettext(view.model.inform_text)
gettext(objview.model.inform_text)
);
}
@ -1371,8 +1369,8 @@ define('pgadmin.browser.node', [
return true;
}.bind(panel),
onSave = function(view, saveBtn) {
var m = view.model,
onSave = function(_view, saveBtn) {
var m = _view.model,
d = m.toJSON(true),
// Generate a timer for the request
timer = setTimeout(function() {
@ -1414,7 +1412,7 @@ define('pgadmin.browser.node', [
if (pnlDependents)
$(pnlDependents).removeData('node-prop');
},
error: function(m, jqxhr) {
error: function(_m, jqxhr) {
Alertify.pgNotifier(
'error', jqxhr,
gettext('Error saving properties')
@ -1431,11 +1429,11 @@ define('pgadmin.browser.node', [
}.bind(panel),
editFunc = function() {
var panel = this;
var self = this;
if (action && action == 'properties') {
action = 'edit';
}
panel.$container.attr('action-mode', action);
self.$container.attr('action-mode', action);
// We need to release any existing view, before
// creating the new view.
if (view) {
@ -1489,7 +1487,7 @@ define('pgadmin.browser.node', [
// Save it to release it later
j.data('obj-view', view);
panel.icon(
self.icon(
_.isFunction(that['node_image']) ?
(that['node_image']).apply(that, [data, view.model]) :
(that['node_image'] || ('icon-' + that.type))
@ -1530,7 +1528,7 @@ define('pgadmin.browser.node', [
register: function(btn) {
btn.on('click',() => {
// Removing the action-mode
panel.$container.removeAttr('action-mode');
self.$container.removeAttr('action-mode');
onCancelFunc.call(true);
});
},
@ -1544,7 +1542,7 @@ define('pgadmin.browser.node', [
register: function(btn) {
btn.on('click',() => {
warnBeforeChangesLost.call(
panel,
self,
gettext('Changes will be lost. Are you sure you want to reset?'),
function() {
setTimeout(function() {
@ -1565,9 +1563,9 @@ define('pgadmin.browser.node', [
// Save the changes
btn.on('click',() => {
warnBeforeAttributeChange.call(
panel,
self,
function() {
informBeforeAttributeChange.call(panel, function(){
informBeforeAttributeChange.call(self, function(){
setTimeout(function() {
onSave.call(this, view, btn);
}, 0);
@ -1584,12 +1582,12 @@ define('pgadmin.browser.node', [
view.$el.closest('.wcFloating').find('[tabindex]:not([tabindex="-1"]').first().focus();
return false;
}
let btnGroup = $(panel.$container.find('.pg-prop-btn-group'));
let btnGroup = $(self.$container.find('.pg-prop-btn-group'));
let el = $(btnGroup).find('button:first');
if (panel.$container.find('.number-cell.editable:last').is(':visible')){
if (self.$container.find('.number-cell.editable:last').is(':visible')){
if (event.keyCode === 9 && event.shiftKey) {
if ($(el).is($(event.target))){
$(panel.$container.find('td.editable:last').trigger('click'));
$(self.$container.find('td.editable:last').trigger('click'));
event.preventDefault();
event.stopPropagation();
}
@ -1598,7 +1596,7 @@ define('pgadmin.browser.node', [
});
setTimeout(function() {
pgBrowser.keyboardNavigation.getDialogTabNavigator(panel.pgElContainer);
pgBrowser.keyboardNavigation.getDialogTabNavigator(self.pgElContainer);
}, 200);
}
@ -1628,14 +1626,14 @@ define('pgadmin.browser.node', [
// Closing this panel
this.close();
}.bind(panel),
updateTreeItem = function(that) {
updateTreeItem = function(obj) {
var _old = data,
_new = _.clone(view.model.tnode),
info = _.clone(view.model.node_info);
// Clear the cache for this node now.
setTimeout(function() {
that.clear_cache.apply(that, item);
obj.clear_cache.apply(obj, item);
}, 0);
pgBrowser.Events.trigger(
@ -1655,19 +1653,18 @@ define('pgadmin.browser.node', [
);
closePanel(false);
},
saveNewNode = function(that) {
var panel = this,
j = panel.$container.find('.obj_properties').first(),
view = j.data('obj-view');
saveNewNode = function(obj) {
var $props = this.$container.find('.obj_properties').first(),
objview = $props.data('obj-view');
// Clear the cache for this node now.
setTimeout(function() {
that.clear_cache.apply(that, item);
obj.clear_cache.apply(obj, item);
}, 0);
try {
pgBrowser.Events.trigger(
'pgadmin:browser:tree:add', _.clone(view.model.tnode),
_.clone(view.model.node_info)
'pgadmin:browser:tree:add', _.clone(objview.model.tnode),
_.clone(objview.model.node_info)
);
} catch (e) {
console.warn(e.stack || e);
@ -1713,11 +1710,11 @@ define('pgadmin.browser.node', [
));
var onCloseFunc = function() {
var j = this.$container.find('.obj_properties').first(),
view = j && j.data('obj-view');
var $props = this.$container.find('.obj_properties').first(),
objview = $props && $props.data('obj-view');
if (view) {
view.remove({
if (objview) {
objview.remove({
data: true,
internal: true,
silent: true,
@ -1789,13 +1786,13 @@ define('pgadmin.browser.node', [
if (self.parent_type) {
if (_.isString(self.parent_type)) {
var p = treeInfo[self.parent_type];
let p = treeInfo[self.parent_type];
if (p) {
priority = p.priority;
}
} else {
_.each(self.parent_type, function(o) {
var p = treeInfo[o];
let p = treeInfo[o];
if (p) {
if (priority < p.priority) {
priority = p.priority;

View File

@ -16,46 +16,46 @@ define([], function() {
(function(t, e, o) {
'use strict';
function r(t, e, r, p) {
r = r || 'width';
var n, l, m, c = (e.match(s) || [])[2],
f = 'px' === c ? 1 : d[c + 'toPx'],
u = /r?em/i;
if (f || u.test(c) && !p){
t = f ? t : 'rem' === c ? i : 'fontSize' === r ? t.parentNode || t : t;
f = f || parseFloat(a(t, 'fontSize'));
m = parseFloat(e) * f;
function r(_t, _e, _r, _p) {
_r = _r || 'width';
let _n, _l, _m, _c = (_e.match(s) || [])[2],
_f = 'px' === _c ? 1 : d[_c + 'toPx'],
_u = /r?em/i;
if (_f || _u.test(_c) && !_p){
_t = _f ? _t : 'rem' === _c ? i : 'fontSize' === _r ? +t.parentNode || _t : _t;
_f = _f || parseFloat(a(_t, 'fontSize'));
_m = parseFloat(_e) * _f;
}
else {
n = t.style;
l = n[r];
_n = _t.style;
_l = _n[_r];
try {
n[r] = e;
_n[_r] = _e;
} catch (x) {
return 0;
}
m = n[r] ? parseFloat(a(t, r)) : 0;
n[r] = l !== o ? l : null;
_m = _n[_r] ? parseFloat(a(_t, _r)) : 0;
_n[_r] = _l !== o ? _l : null;
}
return m;
return _m;
}
function a(t, e) {
var o, n, i, l, d, c = /^top|bottom/,
f = ['paddingTop', 'paddingBottom', 'borderTop', 'borderBottom'],
u = 4;
function a(_t, _e) {
let _o, _n, _i, _l, _d, _c = /^top|bottom/,
_f = ['paddingTop', 'paddingBottom', 'borderTop', 'borderBottom'],
_u = 4;
n = t.style['pixel' + e.charAt(0).toUpperCase() + e.slice(1)];
o = m ? m(t)[e] : (n) ? n + 'px' : 'fontSize' === e ? r(t, '1em', 'left', 1) + 'px' : t.currentStyle[e];
i = (o.match(s) || [])[2];
_n = _t.style['pixel' + _e.charAt(0).toUpperCase() + _e.slice(1)];
_o = m ? m(_t)[_e] : (_n) ? _n + 'px' : 'fontSize' === _e ? r(_t, '1em', 'left', 1) + 'px' : _t.currentStyle[_e];
_i = (_o.match(s) || [])[2];
if ('%' === i && p)
if (c.test(e)) {
for (l = (d = t.parentNode || t).offsetHeight; u--;) l -= parseFloat(a(d, f[u]));
o = parseFloat(o) / 100 * l + 'px';
} else o = r(t, o);
else('auto' === o || i && 'px' !== i) && m ? o = 0 : i && 'px' !== i && !m && (o = r(t, o) + 'px');
return o;
if ('%' === _i && p)
if (_c.test(_e)) {
for (_l = (_d = _t.parentNode || _t).offsetHeight; _u--;) _l -= parseFloat(a(_d, _f[_u]));
_o = parseFloat(_o) / 100 * _l + 'px';
} else _o = r(_t, _o);
else('auto' === _o || _i && 'px' !== _i) && m ? _o = 0 : _i && 'px' !== _i && !m && (_o = r(_t, _o) + 'px');
return _o;
}
var p, n = e.createElement('test'),
i = e.documentElement,

View File

@ -50,6 +50,7 @@
& .ajs-body {
& .ajs-content {
top: 0 !important;
bottom: 0px !important;
padding: 0px;
}
}
@ -131,10 +132,6 @@
}
}
.alertify.ajs-frameless .ajs-body .ajs-content {
bottom: 0px !important;
}
.alertify.ajs-maximized .ajs-commands,
.alertify.ajs-resizable .ajs-commands {
margin: 2px 0px 0 0;

View File

@ -129,6 +129,7 @@
table.backgrid {
position: initial;
overflow: auto;
}
.backgrid td.editor input[type=password] {
@ -209,9 +210,12 @@ table.backgrid {
border-color: $color-gray-light;
border-style: inset inset inset solid;
border-width: 2px 1px 0;
margin: 0px, 15px;
margin-top: -10px;
height: 38px;
min-height: 40px;
vertical-align: bottom;
}
.subnode-footer .ajs-button {
margin: 2px 2px 0;
}
@ -266,12 +270,6 @@ table.backgrid {
background: $color-bg;
}
}
.subnode-footer {
height: 38px;
margin: 0px, 15px;
min-height: 40px;
vertical-align: bottom;
}
.sub-node-form {
height: auto;
@ -300,10 +298,6 @@ table.backgrid {
color: $color-danger;
}
table.backgrid {
overflow: auto;
}
.backgrid tbody {
& td.edit-cell.editor {
background-color: $color-gray-light !important;

View File

@ -192,19 +192,7 @@ legend {
border-top: none !important;
}
}
}
}
& tbody {
& tr {
& th, & td {
border-top: $panel-border;
border-bottom: none;
}
}
}
& thead {
& tr {
& th {
&:first-of-type {
border-left: none;
@ -216,9 +204,13 @@ legend {
}
}
}
& tbody {
& tr {
& th, & td {
border-top: $panel-border;
border-bottom: none;
}
& td {
&:first-of-type {
border-left: none;

View File

@ -97,13 +97,6 @@
display: none;
}
.CodeMirror-foldmarker {
color: $color-primary;
text-shadow: #b9f 1px 1px 2px, #b9f -1px -1px 2px, #b9f 1px -1px 2px, #b9f -1px 1px 2px;
line-height: .3;
cursor: pointer;
}
.CodeMirror-linenumber {
color: $color-fg;
}

View File

@ -1,6 +1,3 @@
.pgadmin-control-group {
min-width: 34px;
}
.control-label {
margin: 0px;
display: inline-block;
@ -312,8 +309,15 @@
.pgadmin-control-group {
margin: 0rem 0rem $form-group-margin-bottom 0rem;
padding: 0rem;
margin: 0rem 0rem $form-group-margin-bottom 0rem;
padding: 0rem;
min-width: 34px;
&.sql, &.sqltab {
margin: 0px;
padding: 0px;
height: 100%;
}
}
.pgadmin-controls {
@ -514,14 +518,6 @@ fieldset.inline-fieldset > div {
padding: 15px;
}
.pgadmin-control-group{
&.sql, &.sqltab {
margin: 0px;
padding: 0px;
height: 100%;
}
}
.tab-pane.sql-code-control {
& .pgadmin-control-group{
margin: 0px;
@ -683,12 +679,6 @@ div.rolmembership {
margin-top: 15px;
}
.inline-tab-panel {
float: left; width: 100%;
background-color: $header-bg;
border: 1px solid $border-color;
border-radius: $card-border-radius;
}
.inline-tab-panel > ul.nav-tabs > li:first-child > a,
.inline-tab-panel > ul.nav-tabs > li:first-child > a:active,
@ -705,6 +695,10 @@ div.rolmembership {
}
.inline-tab-panel {
float: left; width: 100%;
background-color: $header-bg;
border: 1px solid $border-color;
border-radius: $card-border-radius;
& > .tab-content {
padding: 0px;
margin: 0px;
@ -717,10 +711,6 @@ div.rolmembership {
}
}
.inline-tab-panel > .tab-content > div.tab-pane {
padding: 0px;
}
.inline-tab-panel > ul.tab-content > div.tab-pane {
min-height: 150px; padding: 0px !important;
}
@ -734,6 +724,7 @@ div.rolmembership {
}
.inline-tab-panel > .tab-content > div.tab-pane {
padding: 0px;
& > .pgadmin-control-group {
& > div.subnode {
border: none !important;

View File

@ -73,10 +73,6 @@
top: $title-height;
}
.wcLayoutGrid, .wcLayoutGrid tr, .wcLayoutGrid td {
border: 1px solid $panel-border-color;
}
.wcPanelTab, .wcFrameTitle{
color: $color-fg;
padding: $tabs-padding;

View File

@ -7,11 +7,6 @@
background-color: $color-gray-light;
}
#schema-diff-grid {
font-family: $font-family-primary;
font-size: $tree-font-size;
}
#schema-diff-grid .slick-header .slick-header-columns {
background: $color-bg;
height: 40px;
@ -25,6 +20,8 @@
}
#schema-diff-grid {
font-family: $font-family-primary;
font-size: $tree-font-size;
.ui-widget-content {
background-color: $input-bg;
color: $input-color;

View File

@ -170,10 +170,6 @@ li {
display: table-cell;
}
.column-description {
display: table-cell;
}
.long_text_editor {
margin-left: 5px;
font-size: 12px !important;