mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixes following code smell reported by SonarQube:
1) Replace this if-then-else flow by a single return statement 2) Remove the unnecessary boolean literals.
This commit is contained in:
parent
7086719640
commit
b8f63adf41
@ -104,11 +104,7 @@ export default class ExtensionsSchema extends BaseUISchema {
|
||||
controlProps: { allowClear: true }, editable: false,
|
||||
options: this.schemaList,
|
||||
disabled: function (state) {
|
||||
if (!obj.isNew(state) && !state.relocatable) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return !obj.isNew(state) && !state.relocatable;
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -34,22 +34,18 @@ export class DefaultWithSchema extends BaseUISchema {
|
||||
id: 'evnt_truncate', label: gettext('TRUNCATE'),
|
||||
type: 'switch', group: gettext('With'),
|
||||
visible: function() {
|
||||
if(!_.isUndefined(this.node_info['node_info'])
|
||||
&& !_.isUndefined(this.node_info['node_info'].version) &&
|
||||
this.node_info['node_info'].version >= 110000)
|
||||
return true;
|
||||
return false;
|
||||
return !_.isUndefined(this.node_info['node_info'])
|
||||
&& !_.isUndefined(this.node_info['node_info'].version)
|
||||
&& this.node_info['node_info'].version >= 110000;
|
||||
},
|
||||
|
||||
},{
|
||||
id: 'publish_via_partition_root', label: gettext('Publish via root?'),
|
||||
type: 'switch', group: gettext('With'),
|
||||
visible: function() {
|
||||
if(!_.isUndefined(this.node_info['node_info'])
|
||||
&& !_.isUndefined(this.node_info['node_info'].version) &&
|
||||
this.node_info['node_info'].version >= 130000)
|
||||
return true;
|
||||
return false;
|
||||
return !_.isUndefined(this.node_info['node_info'])
|
||||
&& !_.isUndefined(this.node_info['node_info'].version)
|
||||
&& this.node_info['node_info'].version >= 130000;
|
||||
},
|
||||
}];
|
||||
}
|
||||
@ -111,12 +107,9 @@ export default class PublicationSchema extends BaseUISchema {
|
||||
id: 'name', label: gettext('Name'), type: 'text',
|
||||
mode: ['properties', 'create', 'edit'], noEmpty: true,
|
||||
visible: function() {
|
||||
if(!_.isUndefined(this.node_info['node_info'])
|
||||
&& !_.isUndefined(this.node_info['node_info'].version)
|
||||
&& this.node_info['node_info'].version >= 100000) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return !_.isUndefined(this.node_info['node_info'])
|
||||
&& !_.isUndefined(this.node_info['node_info'].version)
|
||||
&& this.node_info['node_info'].version >= 100000;
|
||||
},
|
||||
},{
|
||||
id: 'oid', label: gettext('OID'), cell: 'string', mode: ['properties'],
|
||||
@ -125,9 +118,7 @@ export default class PublicationSchema extends BaseUISchema {
|
||||
id: 'pubowner', label: gettext('Owner'), type: 'select',
|
||||
options: this.fieldOptions.role,
|
||||
disabled: () => {
|
||||
if (obj.isNew())
|
||||
return true;
|
||||
return false;
|
||||
return obj.isNew();
|
||||
},
|
||||
mode: ['edit', 'properties', 'create'], controlProps: { allowClear: false},
|
||||
},{
|
||||
|
@ -79,9 +79,7 @@ export default class CollationSchema extends BaseUISchema {
|
||||
// Enable copy_collation only if locale & lc_* is not provided
|
||||
if (state.locale)
|
||||
return true;
|
||||
if (state.lc_collate || state.lc_type)
|
||||
return true;
|
||||
return false;
|
||||
return state.lc_collate || state.lc_type;
|
||||
},
|
||||
deps: ['locale', 'lc_collate', 'lc_type'],
|
||||
},
|
||||
@ -94,9 +92,7 @@ export default class CollationSchema extends BaseUISchema {
|
||||
// Enable localy only if lc_* & copy_collation is not provided
|
||||
if (state.lc_collate || state.lc_type)
|
||||
return true;
|
||||
if (state.copy_collation)
|
||||
return true;
|
||||
return false;
|
||||
return state.copy_collation;
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -51,10 +51,7 @@ export default class DomainConstraintSchema extends BaseUISchema {
|
||||
cell:'boolean', group: gettext('Definition'), min_version: 90200,
|
||||
mode: ['properties', 'create', 'edit'],
|
||||
readonly: function(state) {
|
||||
if (!obj.isNew(state) && obj._origData.convalidated) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return !obj.isNew(state) && obj._origData.convalidated;
|
||||
}
|
||||
}
|
||||
];
|
||||
|
@ -59,10 +59,7 @@ export default class ForeignTableSchema extends BaseUISchema {
|
||||
}
|
||||
|
||||
canEditDeleteRowColumns(colstate) {
|
||||
if (!isEmptyString(colstate.inheritedfrom)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return isEmptyString(colstate.inheritedfrom);
|
||||
}
|
||||
|
||||
getTableOid(tabId) {
|
||||
@ -183,7 +180,7 @@ export default class ForeignTableSchema extends BaseUISchema {
|
||||
canAdd: true, canDelete: true, columns: ['conname','consrc', 'connoinherit', 'convalidated'],
|
||||
canEdit: true,
|
||||
canDeleteRow: function(state) {
|
||||
return (state.conislocal == true || _.isUndefined(state.conislocal)) ? true : false;
|
||||
return (state.conislocal || _.isUndefined(state.conislocal)) ? true : false;
|
||||
},
|
||||
canEditRow: function(state) {
|
||||
return obj.isNew(state);
|
||||
@ -430,10 +427,8 @@ export class ColumnSchema extends BaseUISchema {
|
||||
|| _.isNull(state.inheritedid)
|
||||
|| _.isUndefined(state.inheritedfrom)
|
||||
|| _.isNull(state.inheritedfrom))) { return false; }
|
||||
if (obj.nodeInfo.server.version < 90300){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
return obj.nodeInfo.server.version >= 90300;
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -531,10 +526,7 @@ export class CheckConstraintSchema extends BaseUISchema {
|
||||
editable: (state) => {
|
||||
if (_.isUndefined(obj.isNew)) { return true; }
|
||||
if (!obj.isNew(state)) {
|
||||
if(state.convalidated && obj.convalidated_default) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !(state.convalidated && obj.convalidated_default);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
@ -84,12 +84,9 @@ export class DefaultArgumentSchema extends BaseUISchema {
|
||||
}
|
||||
// Below will disable default value cell if argument mode is 'INOUT' or 'OUT' as
|
||||
// user cannot set default value for out parameters.
|
||||
if(!_.isUndefined(state.argmode) && !_.isUndefined(state.name) &&
|
||||
return !(!_.isUndefined(state.argmode) && !_.isUndefined(state.name) &&
|
||||
state.name == 'argdefval' &&
|
||||
(state.argmode == 'INOUT' || state.argmode == 'OUT')) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
(state.argmode == 'INOUT' || state.argmode == 'OUT'));
|
||||
}
|
||||
}
|
||||
|
||||
@ -149,8 +146,7 @@ export default class FunctionSchema extends BaseUISchema {
|
||||
|
||||
isVisible(state) {
|
||||
if(this.type !== 'procedure'){
|
||||
if (state.sysproc) { return false; }
|
||||
return true;
|
||||
return !state.sysproc;
|
||||
}else{
|
||||
if (state.sysfunc) {
|
||||
return false;
|
||||
@ -234,10 +230,7 @@ export default class FunctionSchema extends BaseUISchema {
|
||||
id: 'sysproc', label: gettext('System procedure?'),
|
||||
cell:'boolean', type: 'switch',
|
||||
mode: ['properties'], visible: () => {
|
||||
if(this.type === 'procedure'){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return this.type === 'procedure';
|
||||
},
|
||||
},{
|
||||
id: 'description', label: gettext('Comment'), cell: 'string',
|
||||
@ -268,25 +261,21 @@ export default class FunctionSchema extends BaseUISchema {
|
||||
if(this.type === 'procedure'){
|
||||
return this.node_info['node_info'].server.version < 110000;
|
||||
}
|
||||
if (this.node_info && 'catalog' in this.node_info) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
return this.node_info && 'catalog' in this.node_info;
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'probin', label: gettext('Object file'), cell: 'string',
|
||||
type: 'text', group: gettext('Definition'), deps: ['lanname'], visible:
|
||||
function(state) {
|
||||
if (state.lanname == 'c') { return true; }
|
||||
return false;
|
||||
return state.lanname == 'c';
|
||||
}, disabled: obj.inCatalog(),
|
||||
},{
|
||||
id: 'prosrc_c', label: gettext('Link symbol'), cell: 'string',
|
||||
type: 'text', group: gettext('Definition'), deps: ['lanname'], visible:
|
||||
function(state) {
|
||||
if (state.lanname == 'c') { return true; }
|
||||
return false;
|
||||
return state.lanname == 'c';
|
||||
}, disabled: obj.inCatalog(),
|
||||
},
|
||||
{
|
||||
@ -307,10 +296,7 @@ export default class FunctionSchema extends BaseUISchema {
|
||||
group: gettext('Code'), deps: ['lanname'],
|
||||
isFullTab: true,
|
||||
visible: function(state) {
|
||||
if (state.lanname === 'c') {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return state.lanname !== 'c';
|
||||
}, disabled: obj.inCatalog(),
|
||||
},{
|
||||
id: 'provolatile', label: gettext('Volatility'), cell: 'text',
|
||||
@ -361,7 +347,7 @@ export default class FunctionSchema extends BaseUISchema {
|
||||
deps: ['proretset'], visible: obj.isVisible,
|
||||
readonly: (state) => {
|
||||
let isReadonly = true;
|
||||
if(state.proretset == true) {
|
||||
if(state.proretset) {
|
||||
isReadonly = false;
|
||||
}
|
||||
return isReadonly;
|
||||
@ -380,9 +366,7 @@ export default class FunctionSchema extends BaseUISchema {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (obj.node_info['node_info'].server.user.is_superuser)
|
||||
return false;
|
||||
return true;
|
||||
return !(obj.node_info['node_info'].server.user.is_superuser);
|
||||
},
|
||||
group: gettext('Options'), visible: obj.isVisible,
|
||||
options: this.fieldOptions.getSupportFunctions, min_version: 120000,
|
||||
|
@ -45,10 +45,7 @@ define('pgadmin.node.trigger_function', [
|
||||
canEdit: function(itemData, item) {
|
||||
let node = pgBrowser.tree.findNodeByDomElement(item);
|
||||
|
||||
if (!node || node.parentNode.getData()._type === 'trigger')
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return !(!node || node.parentNode.getData()._type === 'trigger');
|
||||
},
|
||||
hasSQL: true,
|
||||
showMenu: function(itemData, item) {
|
||||
|
@ -75,15 +75,11 @@ export default class TriggerFunctionSchema extends BaseUISchema {
|
||||
|
||||
|
||||
isVisible(state) {
|
||||
if (state.name == 'sysproc') { return false; }
|
||||
return true;
|
||||
return state.name != 'sysproc';
|
||||
}
|
||||
|
||||
isDisabled() {
|
||||
if('catalog' in this.fieldOptions.nodeInfo) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return 'catalog' in this.fieldOptions.nodeInfo;
|
||||
}
|
||||
|
||||
|
||||
@ -166,26 +162,21 @@ export default class TriggerFunctionSchema extends BaseUISchema {
|
||||
mode: ['properties', 'create', 'edit'],
|
||||
group: gettext('Code'), deps: ['lanname'],
|
||||
visible: (state) => {
|
||||
if (state.lanname == 'c') {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return state.lanname !== 'c';
|
||||
},
|
||||
disabled: obj.isDisabled, readonly: obj.isReadonly,
|
||||
},{
|
||||
id: 'probin', label: gettext('Object file'), cell: 'string',
|
||||
type: 'text', group: gettext('Definition'), deps: ['lanname'],
|
||||
visible: (state) => {
|
||||
if (state.lanname == 'c') { return true; }
|
||||
return false;
|
||||
return state.lanname == 'c';
|
||||
},
|
||||
disabled: obj.isDisabled, readonly: obj.isReadonly,
|
||||
},{
|
||||
id: 'prosrc_c', label: gettext('Link symbol'), cell: 'string',
|
||||
type: 'text', group: gettext('Definition'), deps: ['lanname'],
|
||||
visible: (state) => {
|
||||
if (state.lanname == 'c') { return true; }
|
||||
return false;
|
||||
return state.lanname == 'c';
|
||||
},
|
||||
disabled: obj.isDisabled, readonly: obj.isReadonly,
|
||||
},{
|
||||
@ -220,7 +211,7 @@ export default class TriggerFunctionSchema extends BaseUISchema {
|
||||
group: gettext('Options'),
|
||||
disabled: (state) => {
|
||||
let isDisabled = true;
|
||||
if(state.proretset == true) {
|
||||
if(state.proretset) {
|
||||
isDisabled = false;
|
||||
}
|
||||
return isDisabled;
|
||||
|
@ -33,9 +33,7 @@ export default class EDBFuncSchema extends BaseUISchema {
|
||||
}
|
||||
|
||||
isVisible(state) {
|
||||
if (state.name == 'sysfunc') { return true; }
|
||||
else if (state.name == 'sysproc') { return true; }
|
||||
return false;
|
||||
return state.name == 'sysfunc' || state.name == 'sysproc';
|
||||
}
|
||||
|
||||
get idAttribute() {
|
||||
@ -77,10 +75,7 @@ export default class EDBFuncSchema extends BaseUISchema {
|
||||
group: gettext('Code'),
|
||||
type: 'sql', isFullTab: true,
|
||||
visible: function(state) {
|
||||
if (state.lanname == 'c') {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return state.lanname !== 'c';
|
||||
},
|
||||
disabled: true,
|
||||
}];
|
||||
|
@ -75,7 +75,7 @@ define('pgadmin.node.package', [
|
||||
},
|
||||
canCreate: function(itemData, item, data) {
|
||||
//If check is false then , we will allow create menu
|
||||
if (data && data.check == false)
|
||||
if (data && !data.check)
|
||||
return true;
|
||||
|
||||
let treeData = pgBrowser.tree.getTreeNodeHierarchy(item),
|
||||
@ -85,11 +85,7 @@ define('pgadmin.node.package', [
|
||||
return false;
|
||||
|
||||
// If it is catalog then don't allow user to create package
|
||||
if (treeData['catalog'] != undefined)
|
||||
return false;
|
||||
|
||||
// by default we want to allow create menu
|
||||
return true;
|
||||
return treeData['catalog'] == undefined;
|
||||
},
|
||||
getSchema: (treeNodeInfo, itemNodeData) => {
|
||||
let nodeObj = pgBrowser.Nodes['package'];
|
||||
|
@ -82,10 +82,7 @@ define('pgadmin.node.sequence', [
|
||||
role: ()=>getNodeListByName('role', treeNodeInfo, itemNodeData),
|
||||
schema: ()=>getNodeListByName('schema', treeNodeInfo, itemNodeData, {}, (m)=>{
|
||||
// If schema name start with pg_* then we need to exclude them
|
||||
if (m.label.match(/^pg_/)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !(m.label.match(/^pg_/));
|
||||
}),
|
||||
allTables: ()=>getNodeListByName('table', treeNodeInfo, itemNodeData, {includeItemKeys: ['_id']}),
|
||||
getColumns: (params)=>{
|
||||
|
@ -175,10 +175,7 @@ define('pgadmin.node.schema', [
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!m.top.inSchema.apply(this, [m])) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return m.top.inSchema.apply(this, [m]);
|
||||
},
|
||||
},{
|
||||
id: 'autovacuum_enabled', label: gettext('Autovacuum Enabled?'),
|
||||
@ -192,9 +189,7 @@ define('pgadmin.node.schema', [
|
||||
],
|
||||
deps: ['autovacuum_custom'],
|
||||
disabled: function(m) {
|
||||
if(!m.top.inSchema.apply(this, [m]) &&
|
||||
m.get('autovacuum_custom') == true) {
|
||||
|
||||
if(!m.top.inSchema.apply(this, [m]) && m.get('autovacuum_custom')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -243,11 +238,8 @@ define('pgadmin.node.schema', [
|
||||
disabled: function(m) {
|
||||
// We need to check additional condition to toggle enable/disable
|
||||
// for table auto-vacuum
|
||||
if(!m.top.inSchema.apply(this, [m]) &&
|
||||
(m.isNew() || (m.get('toast_autovacuum_enabled') === true || m.top.get('hastoasttable') === true))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !(!m.top.inSchema.apply(this, [m]) &&
|
||||
(m.isNew() || (m.get('toast_autovacuum_enabled') === true || m.top.get('hastoasttable') === true)));
|
||||
},
|
||||
},{
|
||||
id: 'toast_autovacuum_enabled', label: gettext('Autovacuum Enabled?'),
|
||||
|
@ -102,7 +102,7 @@ define('pgadmin.node.synonym', [
|
||||
},
|
||||
canCreate: function(itemData, item, data) {
|
||||
//If check is false then , we will allow create menu
|
||||
if (data && data.check == false)
|
||||
if (data && !data.check)
|
||||
return true;
|
||||
|
||||
let treeData = pgBrowser.tree.getTreeNodeHierarchy(item),
|
||||
@ -112,11 +112,7 @@ define('pgadmin.node.synonym', [
|
||||
return false;
|
||||
|
||||
// If it is catalog then don't allow user to create synonyms
|
||||
if (treeData['catalog'] != undefined)
|
||||
return false;
|
||||
|
||||
// by default we do not want to allow create menu
|
||||
return true;
|
||||
return treeData['catalog'] == undefined;
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -105,27 +105,19 @@ export default class ColumnSchema extends BaseUISchema {
|
||||
// Check whether the column is identity column or not
|
||||
isIdentityColumn(state) {
|
||||
let isIdentity = state.attidentity;
|
||||
if(!_.isUndefined(isIdentity) && !_.isNull(isIdentity) && !_.isEmpty(isIdentity))
|
||||
return false;
|
||||
return true;
|
||||
return !(!_.isUndefined(isIdentity) && !_.isNull(isIdentity) && !_.isEmpty(isIdentity));
|
||||
}
|
||||
|
||||
// Check whether the column is a identity column
|
||||
isTypeIdentity(state) {
|
||||
let colconstype = state.colconstype;
|
||||
if (!_.isUndefined(colconstype) && !_.isNull(colconstype) && colconstype == 'i') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return (!_.isUndefined(colconstype) && !_.isNull(colconstype) && colconstype == 'i');
|
||||
}
|
||||
|
||||
// Check whether the column is a generated column
|
||||
isTypeGenerated(state) {
|
||||
let colconstype = state.colconstype;
|
||||
if (!_.isUndefined(colconstype) && !_.isNull(colconstype) && colconstype == 'g') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return (!_.isUndefined(colconstype) && !_.isNull(colconstype) && colconstype == 'g');
|
||||
}
|
||||
|
||||
// We will check if we are under schema node & in 'create' mode
|
||||
@ -200,11 +192,8 @@ export default class ColumnSchema extends BaseUISchema {
|
||||
|
||||
let name = state.name;
|
||||
|
||||
if(!obj.inSchemaWithColumnCheck(state)
|
||||
&& (_.isUndefined(name) || _.isNull(name) || name == '')) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return (!obj.inSchemaWithColumnCheck(state)
|
||||
&& (_.isUndefined(name) || _.isNull(name) || name == ''));
|
||||
},
|
||||
editable: function(state) {
|
||||
// If primary key already exist then disable.
|
||||
@ -229,10 +218,7 @@ export default class ColumnSchema extends BaseUISchema {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!obj.inSchemaWithColumnCheck(state)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return !obj.inSchemaWithColumnCheck(state);
|
||||
},
|
||||
},{
|
||||
id: 'attnum', label: gettext('Position'), cell: 'text',
|
||||
@ -401,10 +387,7 @@ export default class ColumnSchema extends BaseUISchema {
|
||||
}
|
||||
}, editable: function(state) {
|
||||
// inheritedfrom has value then we should disable it
|
||||
if (!isEmptyString(state.inheritedfrom) || !this.editableCheckForTable(state)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !(!isEmptyString(state.inheritedfrom) || !this.editableCheckForTable(state));
|
||||
},
|
||||
},{
|
||||
id: 'attnotnull', label: gettext('Not NULL?'), cell: 'switch',
|
||||
@ -451,10 +434,7 @@ export default class ColumnSchema extends BaseUISchema {
|
||||
};
|
||||
},
|
||||
disabled: function(state) {
|
||||
if (!this.isNew(state) && state.colconstype == 'g') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return (!this.isNew(state) && state.colconstype == 'g');
|
||||
}, min_version: 100000,
|
||||
}, {
|
||||
id: 'attidentity', label: gettext('Identity'),
|
||||
|
@ -191,7 +191,7 @@ define('pgadmin.node.compound_trigger', [
|
||||
|
||||
canCreate: function(itemData, item, data) {
|
||||
//If check is false then , we will allow create menu
|
||||
if (data && data.check == false)
|
||||
if (data && !data.check)
|
||||
return true;
|
||||
|
||||
let treeData = pgBrowser.tree.getTreeNodeHierarchy(item),
|
||||
@ -201,11 +201,7 @@ define('pgadmin.node.compound_trigger', [
|
||||
return false;
|
||||
|
||||
// If it is catalog then don't allow user to create package
|
||||
if (treeData['catalog'] != undefined)
|
||||
return false;
|
||||
|
||||
// by default we want to allow create menu
|
||||
return true;
|
||||
return treeData['catalog'] == undefined;
|
||||
},
|
||||
// Check to whether trigger is disable ?
|
||||
canCreate_with_compound_trigger_enable: function(itemData, item, data) {
|
||||
|
@ -57,10 +57,7 @@ export default class CheckConstraintSchema extends BaseUISchema {
|
||||
id: 'comment', label: gettext('Comment'), type: 'multiline', cell: 'text',
|
||||
mode: ['properties', 'create', 'edit'],
|
||||
deps:['name'], disabled: function(state) {
|
||||
if(isEmptyString(state.name)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return isEmptyString(state.name);
|
||||
},
|
||||
depChange: (state)=>{
|
||||
if(isEmptyString(state.name)) {
|
||||
@ -77,10 +74,7 @@ export default class CheckConstraintSchema extends BaseUISchema {
|
||||
deps: [['is_partitioned']],
|
||||
disabled: function() {
|
||||
// Disabled if table is a partitioned table.
|
||||
if(obj.inTable && obj.top?.sessData.is_partitioned) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return obj.inTable && obj.top?.sessData.is_partitioned;
|
||||
},
|
||||
depChange: ()=>{
|
||||
if(obj.inTable && obj.top?.sessData.is_partitioned) {
|
||||
@ -96,10 +90,7 @@ export default class CheckConstraintSchema extends BaseUISchema {
|
||||
if(obj.inTable && obj.top && !obj.top.isNew()) {
|
||||
return !(_.isUndefined(state.oid) || state.convalidated);
|
||||
}
|
||||
if(!obj.isNew(state) && !obj.origData.convalidated) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return !obj.isNew(state) && !obj.origData.convalidated;
|
||||
},
|
||||
mode: ['properties', 'create', 'edit'],
|
||||
}];
|
||||
|
@ -219,10 +219,7 @@ export default class ExclusionConstraintSchema extends BaseUISchema {
|
||||
}
|
||||
|
||||
get inTable() {
|
||||
if(this.top && this.top instanceof TableSchema) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return this.top && this.top instanceof TableSchema;
|
||||
}
|
||||
|
||||
initialise(data) {
|
||||
@ -262,10 +259,7 @@ export default class ExclusionConstraintSchema extends BaseUISchema {
|
||||
id: 'comment', label: gettext('Comment'), cell: 'text',
|
||||
type: 'multiline', mode: ['properties', 'create', 'edit'],
|
||||
deps:['name'], disabled:function(state) {
|
||||
if(isEmptyString(state.name)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return isEmptyString(state.name);
|
||||
}, depChange: (state)=>{
|
||||
if(isEmptyString(state.name)) {
|
||||
return {comment: ''};
|
||||
|
@ -160,10 +160,7 @@ export default class ForeignKeySchema extends BaseUISchema {
|
||||
}
|
||||
|
||||
get inTable() {
|
||||
if(this.top && this.top instanceof TableSchema) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return this.top && this.top instanceof TableSchema;
|
||||
}
|
||||
|
||||
changeColumnOptions(columns) {
|
||||
@ -194,10 +191,7 @@ export default class ForeignKeySchema extends BaseUISchema {
|
||||
id: 'comment', label: gettext('Comment'), cell: 'text',
|
||||
type: 'multiline', mode: ['properties', 'create', 'edit'],
|
||||
deps:['name'], disabled:function(state) {
|
||||
if(isEmptyString(state.name)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return isEmptyString(state.name);
|
||||
}, depChange: (state)=>{
|
||||
if(isEmptyString(state.name)) {
|
||||
return {comment: ''};
|
||||
@ -252,10 +246,7 @@ export default class ForeignKeySchema extends BaseUISchema {
|
||||
return true;
|
||||
}
|
||||
// If we are in table edit mode then
|
||||
if(state.hasindex) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return state.hasindex;
|
||||
},
|
||||
depChange: (state, source, topState, actionObj)=>{
|
||||
if(!obj.isNew(state)) {
|
||||
|
@ -53,7 +53,7 @@ define('pgadmin.node.primary_key', [
|
||||
},
|
||||
canCreate: function(itemData, item, data) {
|
||||
// If check is false then , we will allow create menu
|
||||
if (data && data.check == false)
|
||||
if (data && !data.check)
|
||||
return true;
|
||||
|
||||
let t = pgBrowser.tree, i = item, d = itemData, parents = [],
|
||||
@ -164,11 +164,7 @@ define('pgadmin.node.primary_key', [
|
||||
}
|
||||
|
||||
// We can't update columns of existing index constraint.
|
||||
if (!m.isNew()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return !m.isNew();
|
||||
},
|
||||
// Define the schema for the index constraint node
|
||||
schema: [{
|
||||
@ -451,12 +447,9 @@ define('pgadmin.node.primary_key', [
|
||||
visible: function(m) {
|
||||
/* In table properties, m.node_info is not available */
|
||||
m = m.top;
|
||||
if(!_.isUndefined(m.node_info) && !_.isUndefined(m.node_info.server)
|
||||
return (!_.isUndefined(m.node_info) && !_.isUndefined(m.node_info.server)
|
||||
&& !_.isUndefined(m.node_info.server.version) &&
|
||||
m.node_info.server.version >= 110000)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
m.node_info.server.version >= 110000);
|
||||
},
|
||||
control: Backform.MultiSelectAjaxControl.extend({
|
||||
defaults: _.extend(
|
||||
@ -602,7 +595,7 @@ define('pgadmin.node.primary_key', [
|
||||
},
|
||||
disabled: function(m) {
|
||||
// Disable if condeferred is false or unselected.
|
||||
if(m.get('condeferrable') == true) {
|
||||
if(m.get('condeferrable')) {
|
||||
return false;
|
||||
} else {
|
||||
setTimeout(function(){
|
||||
|
@ -37,10 +37,7 @@ export default class PrimaryKeySchema extends BaseUISchema {
|
||||
}
|
||||
|
||||
get inTable() {
|
||||
if(this.top && this.top instanceof TableSchema) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return this.top && this.top instanceof TableSchema;
|
||||
}
|
||||
|
||||
changeColumnOptions(columns) {
|
||||
@ -64,10 +61,7 @@ export default class PrimaryKeySchema extends BaseUISchema {
|
||||
id: 'comment', label: gettext('Comment'), cell: 'multiline',
|
||||
type: 'multiline', mode: ['properties', 'create', 'edit'],
|
||||
deps:['name'], disabled: (state)=>{
|
||||
if(isEmptyString(state.name)){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return isEmptyString(state.name);
|
||||
}, depChange: (state)=>{
|
||||
if(isEmptyString(state.name)){
|
||||
return {comment: ''};
|
||||
@ -159,10 +153,7 @@ export default class PrimaryKeySchema extends BaseUISchema {
|
||||
mode: ['properties', 'create', 'edit'],
|
||||
visible: function() {
|
||||
/* In table properties, nodeInfo is not available */
|
||||
if(this.getServerVersion() >= 110000)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return this.getServerVersion() >= 110000;
|
||||
},
|
||||
deps: ['index'],
|
||||
readonly: function(state) {
|
||||
|
@ -38,10 +38,7 @@ export default class UniqueConstraintSchema extends BaseUISchema {
|
||||
}
|
||||
|
||||
get inTable() {
|
||||
if(this.top && this.top instanceof TableSchema) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return this.top && this.top instanceof TableSchema;
|
||||
}
|
||||
|
||||
changeColumnOptions(columns) {
|
||||
@ -65,10 +62,7 @@ export default class UniqueConstraintSchema extends BaseUISchema {
|
||||
id: 'comment', label: gettext('Comment'), cell: 'multiline',
|
||||
type: 'multiline', mode: ['properties', 'create', 'edit'],
|
||||
deps:['name'], disabled: (state)=>{
|
||||
if(isEmptyString(state.name)){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return isEmptyString(state.name);
|
||||
}, depChange: (state)=>{
|
||||
if(isEmptyString(state.name)){
|
||||
return {comment: ''};
|
||||
@ -158,12 +152,9 @@ export default class UniqueConstraintSchema extends BaseUISchema {
|
||||
mode: ['properties', 'create', 'edit'],
|
||||
visible: function() {
|
||||
/* In table properties, nodeInfo is not available */
|
||||
if(!_.isUndefined(this.nodeInfo) && !_.isUndefined(this.nodeInfo.server)
|
||||
return (!_.isUndefined(this.nodeInfo) && !_.isUndefined(this.nodeInfo.server)
|
||||
&& !_.isUndefined(this.nodeInfo.server.version) &&
|
||||
this.nodeInfo.server.version >= 110000)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
this.nodeInfo.server.version >= 110000);
|
||||
},
|
||||
deps: ['index'],
|
||||
readonly: function(state) {
|
||||
|
@ -163,7 +163,7 @@ export class ColumnSchema extends BaseUISchema {
|
||||
if(isEmptyString(topState.amname) || topState.amname === 'btree') {
|
||||
// We need to set nulls to true if sort_order is set to desc
|
||||
// nulls first is default for desc
|
||||
if(state.sort_order == true && actionObj.oldState.sort_order == false) {
|
||||
if(state.sort_order && !actionObj.oldState.sort_order) {
|
||||
setTimeout(function() {
|
||||
state.nulls = true;
|
||||
}, 10);
|
||||
@ -195,11 +195,7 @@ export class ColumnSchema extends BaseUISchema {
|
||||
}
|
||||
|
||||
function inSchema(node_info) {
|
||||
if(node_info && 'catalog' in node_info)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return node_info && 'catalog' in node_info;
|
||||
}
|
||||
|
||||
export default class IndexSchema extends BaseUISchema {
|
||||
@ -257,12 +253,9 @@ export default class IndexSchema extends BaseUISchema {
|
||||
}
|
||||
|
||||
isVisible() {
|
||||
if(!_.isUndefined(this.node_info) && !_.isUndefined(this.node_info.server)
|
||||
return (!_.isUndefined(this.node_info) && !_.isUndefined(this.node_info.server)
|
||||
&& !_.isUndefined(this.node_info.server.version) &&
|
||||
this.node_info.server.version >= 110000)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
this.node_info.server.version >= 110000);
|
||||
}
|
||||
|
||||
get baseFields() {
|
||||
|
@ -34,11 +34,7 @@ export function getNodePartitionTableSchema(treeNodeInfo, itemNodeData, pgBrowse
|
||||
cacheNode: 'database',
|
||||
}, (d)=>{
|
||||
// If schema name start with pg_* then we need to exclude them
|
||||
if(d && d.label.match(/^pg_/))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !(d && d.label.match(/^pg_/));
|
||||
}),
|
||||
spcname: spcname,
|
||||
coll_inherits: ()=>getNodeAjaxOptions('get_inherits', partNode, treeNodeInfo, itemNodeData),
|
||||
@ -186,18 +182,14 @@ export default class PartitionTableSchema extends BaseUISchema {
|
||||
mode: ['edit', 'create'], min_version: 100000,
|
||||
visible: function(state) {
|
||||
// Always show in case of create mode
|
||||
if (obj.isNew(state) || state.is_partitioned)
|
||||
return true;
|
||||
return false;
|
||||
return obj.isNew(state) || state.is_partitioned;
|
||||
},
|
||||
},{
|
||||
id: 'is_partitioned', label:gettext('Partitioned table?'), cell: 'switch',
|
||||
type: 'switch', mode: ['properties', 'create', 'edit'],
|
||||
min_version: 100000,
|
||||
readonly: function(state) {
|
||||
if (!obj.isNew(state))
|
||||
return true;
|
||||
return false;
|
||||
return !obj.isNew(state);
|
||||
},
|
||||
},{
|
||||
id: 'is_sys_table', label: gettext('System table?'), cell: 'switch',
|
||||
@ -297,9 +289,7 @@ export default class PartitionTableSchema extends BaseUISchema {
|
||||
mode:['create'],
|
||||
min_version: 100000,
|
||||
disabled: function(state) {
|
||||
if (!state.is_partitioned)
|
||||
return true;
|
||||
return false;
|
||||
return !state.is_partitioned;
|
||||
},
|
||||
readonly: function(state) {return !obj.isNew(state);},
|
||||
},
|
||||
@ -311,9 +301,7 @@ export default class PartitionTableSchema extends BaseUISchema {
|
||||
deps: ['is_partitioned', 'partition_type', 'typname'],
|
||||
canEdit: false, canDelete: true,
|
||||
canAdd: function(state) {
|
||||
if (obj.isNew(state) && state.is_partitioned)
|
||||
return true;
|
||||
return false;
|
||||
return obj.isNew(state) && state.is_partitioned;
|
||||
},
|
||||
canAddRow: function(state) {
|
||||
let columnsExist = false;
|
||||
@ -384,9 +372,7 @@ export default class PartitionTableSchema extends BaseUISchema {
|
||||
customDeleteMsg: gettext('Are you sure you wish to detach this partition?'),
|
||||
columns:['is_attach', 'partition_name', 'is_default', 'values_from', 'values_to', 'values_in', 'values_modulus', 'values_remainder'],
|
||||
canAdd: function(state) {
|
||||
if (state.is_partitioned)
|
||||
return true;
|
||||
return false;
|
||||
return state.is_partitioned;
|
||||
},
|
||||
min_version: 100000,
|
||||
},
|
||||
|
@ -96,11 +96,7 @@ define('pgadmin.node.row_security_policy', [
|
||||
return false;
|
||||
|
||||
// If server is less than 9.5 then do not allow 'create' menu
|
||||
if (server && server.version < 90500)
|
||||
return false;
|
||||
|
||||
// by default we want to allow create menu
|
||||
return true;
|
||||
return server && server.version >= 90500;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
@ -40,10 +40,7 @@ export default class RowSecurityPolicySchema extends BaseUISchema {
|
||||
}
|
||||
|
||||
disableUsingField(state){
|
||||
if (state.event == 'INSERT'){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return state.event == 'INSERT';
|
||||
}
|
||||
|
||||
disableWithCheckField(state){
|
||||
@ -69,10 +66,7 @@ export default class RowSecurityPolicySchema extends BaseUISchema {
|
||||
{
|
||||
id: 'event', label: gettext('Event'), type: 'select',
|
||||
group: gettext('Commands'),disabled: () => {
|
||||
if(obj.isNew()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !obj.isNew();
|
||||
},
|
||||
controlProps: { allowClear: false },
|
||||
options:[
|
||||
@ -126,10 +120,7 @@ export default class RowSecurityPolicySchema extends BaseUISchema {
|
||||
{label: 'RESTRICTIVE', value: 'RESTRICTIVE'},
|
||||
],
|
||||
visible: () => {
|
||||
if(obj.nodeInfo.server.version >= 100000)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return obj.nodeInfo.server.version >= 100000;
|
||||
},
|
||||
},
|
||||
];
|
||||
|
@ -42,10 +42,7 @@ export default class RuleSchema extends BaseUISchema {
|
||||
if (state.name == '_RETURN') {
|
||||
return true;
|
||||
}
|
||||
if (obj.isNew(state) || obj.fieldOptions.nodeInfo.server.version >= 90400) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !(obj.isNew(state) || obj.fieldOptions.nodeInfo.server.version >= 90400);
|
||||
}, noEmpty: true
|
||||
},
|
||||
{
|
||||
@ -71,10 +68,7 @@ export default class RuleSchema extends BaseUISchema {
|
||||
mode: ['edit', 'properties'], group: gettext('Definition'),
|
||||
type: 'select',
|
||||
disabled: () => {
|
||||
if('catalog' in obj.fieldOptions.nodeInfo || 'view' in obj.fieldOptions.nodeInfo) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return 'catalog' in obj.fieldOptions.nodeInfo || 'view' in obj.fieldOptions.nodeInfo;
|
||||
},
|
||||
options: [
|
||||
{label: gettext('Enable'), value: 'O'},
|
||||
|
@ -27,10 +27,7 @@ export class PartitionKeysSchema extends BaseUISchema {
|
||||
}
|
||||
|
||||
isEditable(state) {
|
||||
if(state.key_type == 'expression') {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return state.key_type != 'expression';
|
||||
}
|
||||
|
||||
get baseFields() {
|
||||
@ -75,10 +72,7 @@ export class PartitionKeysSchema extends BaseUISchema {
|
||||
}
|
||||
},
|
||||
editable: function(state) {
|
||||
if(state.key_type == 'expression') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return state.key_type == 'expression';
|
||||
},
|
||||
},{
|
||||
id: 'collationame', label: gettext('Collation'), cell: 'select',
|
||||
@ -144,19 +138,13 @@ export class PartitionsSchema extends BaseUISchema {
|
||||
}
|
||||
|
||||
isEditable(state, type) {
|
||||
if(this.top && this.top.sessData.partition_type == type && this.isNew(state)
|
||||
&& state.is_default !== true) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return (this.top && this.top.sessData.partition_type == type && this.isNew(state)
|
||||
&& state.is_default !== true);
|
||||
}
|
||||
|
||||
isDisable(state, type) {
|
||||
if(this.top && this.top.sessData.partition_type == type && this.isNew(state)
|
||||
&& state.is_default !== true) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !(this.top && this.top.sessData.partition_type == type && this.isNew(state)
|
||||
&& state.is_default !== true);
|
||||
}
|
||||
|
||||
get baseFields() {
|
||||
@ -171,16 +159,10 @@ export class PartitionsSchema extends BaseUISchema {
|
||||
{label: gettext('Create'), value: false},
|
||||
], controlProps: {allowClear: false},
|
||||
editable: function(state) {
|
||||
if(obj.isNew(state) && !obj.top.isNew()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return obj.isNew(state) && !obj.top.isNew();
|
||||
},
|
||||
readonly: function(state) {
|
||||
if(obj.isNew(state) && !obj.top.isNew()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !(obj.isNew(state) && !obj.top.isNew());
|
||||
},
|
||||
},{
|
||||
id: 'partition_name', label: gettext('Name'), deps: ['is_attach'],
|
||||
@ -211,35 +193,23 @@ export class PartitionsSchema extends BaseUISchema {
|
||||
}
|
||||
},
|
||||
editable: function(state) {
|
||||
if(obj.isNew(state)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return obj.isNew(state);
|
||||
},
|
||||
readonly: function(state) {
|
||||
if(obj.isNew(state)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !obj.isNew(state);
|
||||
}, noEmpty: true,
|
||||
},{
|
||||
id: 'is_default', label: gettext('Default'), type: 'switch', cell:'switch',
|
||||
width: 55, disableResizing: true, min_version: 110000,
|
||||
editable: function(state) {
|
||||
if(obj.top && (obj.top.sessData.partition_type == 'range' ||
|
||||
return (obj.top && (obj.top.sessData.partition_type == 'range' ||
|
||||
obj.top.sessData.partition_type == 'list') && obj.isNew(state)
|
||||
&& obj.getServerVersion() >= 110000) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
&& obj.getServerVersion() >= 110000);
|
||||
},
|
||||
readonly: function(state) {
|
||||
if(obj.top && (obj.top.sessData.partition_type == 'range' ||
|
||||
return !(obj.top && (obj.top.sessData.partition_type == 'range' ||
|
||||
obj.top.sessData.partition_type == 'list') && obj.isNew(state)
|
||||
&& obj.getServerVersion() >= 110000) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
&& obj.getServerVersion() >= 110000);
|
||||
},
|
||||
},{
|
||||
id: 'values_from', label: gettext('From'), type:'text', cell: 'text',
|
||||
@ -280,17 +250,11 @@ export class PartitionsSchema extends BaseUISchema {
|
||||
},{
|
||||
id: 'values_remainder', label: gettext('Remainder'), type:'int', cell: 'int',
|
||||
editable: function(state) {
|
||||
if(obj.top && obj.top.sessData.partition_type == 'hash' && obj.isNew(state)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return obj.top && obj.top.sessData.partition_type == 'hash' && obj.isNew(state);
|
||||
},
|
||||
disabled: function(state) {
|
||||
if(obj.top && obj.top.sessData.partition_type == 'hash' && obj.isNew(state)
|
||||
&& state.is_default !== true) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !(obj.top && obj.top.sessData.partition_type == 'hash' && obj.isNew(state)
|
||||
&& state.is_default !== true);
|
||||
},
|
||||
},{
|
||||
id: 'is_sub_partitioned', label:gettext('Partitioned table?'), cell: 'switch',
|
||||
@ -299,10 +263,7 @@ export class PartitionsSchema extends BaseUISchema {
|
||||
if(!obj.isNew(state)) {
|
||||
return true;
|
||||
}
|
||||
if(state.is_attach) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return state.is_attach;
|
||||
},
|
||||
depChange: (state)=>{
|
||||
if(state.is_attach) {
|
||||
@ -338,9 +299,7 @@ export class PartitionsSchema extends BaseUISchema {
|
||||
deps: ['is_sub_partitioned', 'sub_partition_type', ['typname']],
|
||||
canEdit: false, canDelete: true,
|
||||
canAdd: function(state) {
|
||||
if (obj.isNew(state) && state.is_sub_partitioned)
|
||||
return true;
|
||||
return false;
|
||||
return obj.isNew(state) && state.is_sub_partitioned;
|
||||
},
|
||||
canAddRow: function(state) {
|
||||
let columnsExist = false;
|
||||
@ -376,10 +335,7 @@ export class PartitionsSchema extends BaseUISchema {
|
||||
text: state.sub_partition_scheme,
|
||||
}),
|
||||
visible: function(state) {
|
||||
if(obj.isNew(state) && !isEmptyString(state.sub_partition_scheme)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return obj.isNew(state) && !isEmptyString(state.sub_partition_scheme);
|
||||
},
|
||||
}];
|
||||
}
|
||||
|
@ -316,9 +316,7 @@ define('pgadmin.node.table', [
|
||||
type: 'switch', mode: ['properties', 'create', 'edit'],
|
||||
visible: 'isVersionGreaterThan96',
|
||||
readonly: function(m) {
|
||||
if (!m.isNew())
|
||||
return true;
|
||||
return false;
|
||||
return !m.isNew();
|
||||
},
|
||||
},{
|
||||
id: 'description', label: gettext('Comment'), type: 'multiline',
|
||||
@ -336,11 +334,7 @@ define('pgadmin.node.table', [
|
||||
},
|
||||
// We will disable everything if we are under catalog node
|
||||
inSchema: function() {
|
||||
if(this.node_info && 'catalog' in this.node_info)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return this.node_info && 'catalog' in this.node_info;
|
||||
},
|
||||
}),
|
||||
// Check to whether table has disable trigger(s)
|
||||
|
@ -39,11 +39,7 @@ export function getNodeTableSchema(treeNodeInfo, itemNodeData, pgBrowser) {
|
||||
cacheNode: 'database',
|
||||
}, (d)=>{
|
||||
// If schema name start with pg_* then we need to exclude them
|
||||
if(d && d.label.match(/^pg_/))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !(d && d.label.match(/^pg_/));
|
||||
}),
|
||||
spcname: spcname,
|
||||
coll_inherits: ()=>getNodeAjaxOptions('get_inherits', tableNode, treeNodeInfo, itemNodeData),
|
||||
@ -106,10 +102,7 @@ export class ConstraintsSchema extends BaseUISchema {
|
||||
}
|
||||
|
||||
canAdd(state) {
|
||||
if (state.is_partitioned && this.top.getServerVersion() < 110000) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !(state.is_partitioned && this.top.getServerVersion() < 110000);
|
||||
}
|
||||
|
||||
get baseFields() {
|
||||
@ -219,17 +212,11 @@ export class LikeSchema extends BaseUISchema {
|
||||
}
|
||||
|
||||
isLikeDisable(state) {
|
||||
if(!this.top.inSchemaWithModelCheck(state) && isEmptyString(state.typname)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !(!this.top.inSchemaWithModelCheck(state) && isEmptyString(state.typname));
|
||||
}
|
||||
|
||||
isRelationDisable(state) {
|
||||
if(isEmptyString(state.like_relation)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return isEmptyString(state.like_relation);
|
||||
}
|
||||
|
||||
resetVals(state) {
|
||||
@ -396,20 +383,14 @@ export default class TableSchema extends BaseUISchema {
|
||||
canAddRowColumns(state) {
|
||||
if(!this.inCatalog()) {
|
||||
// if of_type then disable add in grid
|
||||
if (!isEmptyString(state.typname)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return isEmptyString(state.typname);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for column grid when to edit/delete (for each row)
|
||||
canEditDeleteRowColumns(colstate) {
|
||||
if (!isEmptyString(colstate.inheritedfrom)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return isEmptyString(colstate.inheritedfrom);
|
||||
}
|
||||
|
||||
isPartitioned(state) {
|
||||
@ -464,18 +445,14 @@ export default class TableSchema extends BaseUISchema {
|
||||
return false;
|
||||
}
|
||||
// Always show in case of create mode
|
||||
if (obj.isNew(state) || state.is_partitioned)
|
||||
return true;
|
||||
return false;
|
||||
return (obj.isNew(state) || state.is_partitioned);
|
||||
},
|
||||
},{
|
||||
id: 'is_partitioned', label:gettext('Partitioned table?'), cell: 'switch',
|
||||
type: 'switch', mode: ['properties', 'create', 'edit'],
|
||||
min_version: 100000, visible: !this.inErd,
|
||||
readonly: function(state) {
|
||||
if (!obj.isNew(state))
|
||||
return true;
|
||||
return false;
|
||||
return !obj.isNew(state);
|
||||
},
|
||||
},{
|
||||
id: 'is_sys_table', label: gettext('System table?'), cell: 'switch',
|
||||
@ -495,10 +472,7 @@ export default class TableSchema extends BaseUISchema {
|
||||
if(state.adding_inherit_cols || state.is_partitioned){
|
||||
return true;
|
||||
}
|
||||
if(!obj.inCatalog() && isEmptyString(state.typname)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !(!obj.inCatalog() && isEmptyString(state.typname));
|
||||
},
|
||||
depChange: (state, source, topState, actionObj)=>{
|
||||
if(actionObj.type == SCHEMA_STATE_ACTIONS.SET_VALUE && actionObj.path[0] == 'coll_inherits') {
|
||||
@ -703,10 +677,7 @@ export default class TableSchema extends BaseUISchema {
|
||||
mode: ['properties', 'create', 'edit'], group: 'advanced', deps: ['coll_inherits'],
|
||||
visible: !this.inErd,
|
||||
disabled: (state)=>{
|
||||
if(!obj.inSchemaWithModelCheck(state) && isEmptyString(state.coll_inherits)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !(!obj.inSchemaWithModelCheck(state) && isEmptyString(state.coll_inherits));
|
||||
}, options: this.fieldOptions.typname, optionsLoaded: (res)=>{
|
||||
obj.ofTypeTables = res;
|
||||
},
|
||||
@ -836,9 +807,7 @@ export default class TableSchema extends BaseUISchema {
|
||||
mode:['create'],
|
||||
min_version: 100000,
|
||||
disabled: function(state) {
|
||||
if (!state.is_partitioned)
|
||||
return true;
|
||||
return false;
|
||||
return !state.is_partitioned;
|
||||
},
|
||||
readonly: function(state) {return !obj.isNew(state);},
|
||||
},
|
||||
@ -851,9 +820,7 @@ export default class TableSchema extends BaseUISchema {
|
||||
deps: ['is_partitioned', 'partition_type', 'typname'],
|
||||
canEdit: false, canDelete: true,
|
||||
canAdd: function(state) {
|
||||
if (obj.isNew(state) && state.is_partitioned)
|
||||
return true;
|
||||
return false;
|
||||
return obj.isNew(state) && state.is_partitioned;
|
||||
},
|
||||
canAddRow: function(state) {
|
||||
let columnsExist = false;
|
||||
@ -924,9 +891,7 @@ export default class TableSchema extends BaseUISchema {
|
||||
customDeleteMsg: gettext('Are you sure you wish to detach this partition?'),
|
||||
columns:['is_attach', 'partition_name', 'is_default', 'values_from', 'values_to', 'values_in', 'values_modulus', 'values_remainder'],
|
||||
canAdd: function(state) {
|
||||
if (state.is_partitioned)
|
||||
return true;
|
||||
return false;
|
||||
return state.is_partitioned;
|
||||
},
|
||||
min_version: 100000,
|
||||
},
|
||||
|
@ -84,7 +84,7 @@ export class EventSchema extends BaseUISchema {
|
||||
let is_constraint_trigger = state.is_constraint_trigger,
|
||||
is_row_trigger = state.is_row_trigger,
|
||||
server_type = obj.nodeInfo ? obj.nodeInfo.server.server_type: null;
|
||||
if (is_row_trigger == true){
|
||||
if (is_row_trigger){
|
||||
state.evnt_truncate = false;
|
||||
return true;
|
||||
}
|
||||
@ -189,10 +189,7 @@ export default class TriggerSchema extends BaseUISchema {
|
||||
}
|
||||
|
||||
isDisable(state) {
|
||||
if(!state.is_constraint_trigger) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return !state.is_constraint_trigger;
|
||||
}
|
||||
|
||||
get baseFields() {
|
||||
@ -208,10 +205,7 @@ export default class TriggerSchema extends BaseUISchema {
|
||||
mode: ['edit', 'properties'], group: gettext('Definition'),
|
||||
type: 'select',
|
||||
disabled: () => {
|
||||
if('catalog' in obj.nodeInfo || 'view' in obj.nodeInfo) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return 'catalog' in obj.nodeInfo || 'view' in obj.nodeInfo;
|
||||
},
|
||||
options: [
|
||||
{label: gettext('Enable'), value: 'O'},
|
||||
@ -252,11 +246,7 @@ export default class TriggerSchema extends BaseUISchema {
|
||||
} else {
|
||||
// Check if it is row trigger then enabled it.
|
||||
let is_row_trigger = state.is_row_trigger;
|
||||
if (!_.isUndefined(is_row_trigger) && obj.nodeInfo.server.server_type == 'ppas') {
|
||||
return false;
|
||||
}
|
||||
// Disable it
|
||||
return true;
|
||||
return !(!_.isUndefined(is_row_trigger) && obj.nodeInfo.server.server_type == 'ppas');
|
||||
}
|
||||
},
|
||||
},{
|
||||
@ -278,10 +268,7 @@ export default class TriggerSchema extends BaseUISchema {
|
||||
return obj.inSchemaWithModelCheck(state);
|
||||
},
|
||||
disabled: () => {
|
||||
if('view' in obj.nodeInfo) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return 'view' in obj.nodeInfo;
|
||||
}
|
||||
},{
|
||||
id: 'tgdeferrable', label: gettext('Deferrable?'),
|
||||
@ -403,11 +390,7 @@ export default class TriggerSchema extends BaseUISchema {
|
||||
} else {
|
||||
// Check if it is row trigger then enabled it.
|
||||
let fires_ = state.fires;
|
||||
if (!_.isUndefined(fires_) && obj.nodeInfo.server.server_type == 'ppas') {
|
||||
return false;
|
||||
}
|
||||
// Disable it
|
||||
return true;
|
||||
return !(!_.isUndefined(fires_) && obj.nodeInfo.server.server_type == 'ppas');
|
||||
}
|
||||
},
|
||||
},{
|
||||
@ -435,10 +418,7 @@ export default class TriggerSchema extends BaseUISchema {
|
||||
}
|
||||
// Enable column only if update event is set true
|
||||
let isUpdate = state.evnt_update;
|
||||
if(!_.isUndefined(isUpdate) && isUpdate) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !(!_.isUndefined(isUpdate) && isUpdate);
|
||||
},
|
||||
},{
|
||||
id: 'tgoldtable', label: gettext('Old table'),
|
||||
|
@ -191,10 +191,7 @@ function getDataTypeSchema(nodeObj, treeNodeInfo, itemNodeData) {
|
||||
}
|
||||
|
||||
function isVisible(state, type) {
|
||||
if(state.typtype === type) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return state.typtype === type;
|
||||
}
|
||||
|
||||
class EnumerationSchema extends BaseUISchema {
|
||||
@ -1413,10 +1410,7 @@ export default class TypeSchema extends BaseUISchema {
|
||||
type: 'text', mode: ['properties'], group: gettext('Definition'),
|
||||
disabled: () => obj.inCatalog(),
|
||||
visible: function(state) {
|
||||
if(state.typtype === 'N' || state.typtype === 'V') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return state.typtype === 'N' || state.typtype === 'V';
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -36,10 +36,7 @@ export default class ViewSchema extends BaseUISchema {
|
||||
}
|
||||
|
||||
notInSchema() {
|
||||
if(this.nodeInfo && 'catalog' in this.nodeInfo) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return this.nodeInfo && 'catalog' in this.nodeInfo;
|
||||
}
|
||||
|
||||
|
||||
|
@ -118,24 +118,20 @@ define('pgadmin.node.database', [
|
||||
server = treeData['server'];
|
||||
|
||||
// If server is less than 10 then do not allow 'create' menu
|
||||
if (server && server.version < 100000)
|
||||
return false;
|
||||
|
||||
// by default we want to allow create menu
|
||||
return true;
|
||||
return server && server.version >= 100000;
|
||||
},
|
||||
|
||||
is_not_connected: function(node) {
|
||||
return (node && node.connected != true && node.allowConn == true);
|
||||
return (node && !node.connected && node.allowConn);
|
||||
},
|
||||
is_connected: function(node) {
|
||||
return (node && node.connected == true && node.canDisconn == true);
|
||||
return (node && node.connected && node.canDisconn);
|
||||
},
|
||||
is_psql_enabled: function(node) {
|
||||
return (node && node.connected == true) && pgAdmin['enable_psql'];
|
||||
return (node && node.connected) && pgAdmin['enable_psql'];
|
||||
},
|
||||
is_conn_allow: function(node) {
|
||||
return (node && node.allowConn == true);
|
||||
return (node && node.allowConn);
|
||||
},
|
||||
connection_lost: function(i, resp, server_connected) {
|
||||
if (pgBrowser.tree) {
|
||||
|
@ -53,9 +53,7 @@ export default class SubscriptionSchema extends BaseUISchema{
|
||||
get SSL_MODES() { return ['prefer', 'require', 'verify-ca', 'verify-full']; }
|
||||
|
||||
isDisable(){
|
||||
if (this.isNew())
|
||||
return false;
|
||||
return true;
|
||||
return !this.isNew();
|
||||
}
|
||||
isSameDB(state){
|
||||
let host = state.host,
|
||||
@ -76,9 +74,7 @@ export default class SubscriptionSchema extends BaseUISchema{
|
||||
db = state.db,
|
||||
port = state.port,
|
||||
username = state.username;
|
||||
if ((!_.isUndefined(host) && host) && (!_.isUndefined(db) && db) && (!_.isUndefined(port) && port) && (!_.isUndefined(username) && username))
|
||||
return false;
|
||||
return true;
|
||||
return !((!_.isUndefined(host) && host) && (!_.isUndefined(db) && db) && (!_.isUndefined(port) && port) && (!_.isUndefined(username) && username));
|
||||
}
|
||||
isConnect(state){
|
||||
if(!_.isUndefined(state.connect) && !state.connect){
|
||||
@ -106,12 +102,9 @@ export default class SubscriptionSchema extends BaseUISchema{
|
||||
id: 'name', label: gettext('Name'), type: 'text',
|
||||
mode: ['properties', 'create', 'edit'], noEmpty: true,
|
||||
visible: function() {
|
||||
if(!_.isUndefined(this.node_info['node_info'])
|
||||
return (!_.isUndefined(this.node_info['node_info'])
|
||||
&& !_.isUndefined(this.node_info['node_info'].version)
|
||||
&& this.node_info['node_info'].version >= 100000) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
&& this.node_info['node_info'].version >= 100000);
|
||||
},
|
||||
},{
|
||||
id: 'oid', label: gettext('OID'), cell: 'string', mode: ['properties'],
|
||||
@ -123,9 +116,7 @@ export default class SubscriptionSchema extends BaseUISchema{
|
||||
type: 'select',
|
||||
mode: ['edit', 'properties', 'create'], controlProps: { allowClear: false},
|
||||
disabled: function(){
|
||||
if(obj.isNew())
|
||||
return true;
|
||||
return false;
|
||||
return obj.isNew();
|
||||
},
|
||||
},{
|
||||
id: 'host', label: gettext('Host name/address'), type: 'text', group: gettext('Connection'),
|
||||
|
@ -60,9 +60,7 @@ define('pgadmin.node.server', [
|
||||
label: gettext('Server'),
|
||||
canDrop: function(node){
|
||||
let serverOwner = node.user_id;
|
||||
if (serverOwner != current_user.id && !_.isUndefined(serverOwner))
|
||||
return false;
|
||||
return true;
|
||||
return !(serverOwner != current_user.id && !_.isUndefined(serverOwner));
|
||||
},
|
||||
dropAsRemove: true,
|
||||
dropPriority: 5,
|
||||
@ -146,11 +144,8 @@ define('pgadmin.node.server', [
|
||||
label: gettext('Clear Saved Password'), icon: 'fa fa-eraser',
|
||||
priority: 11,
|
||||
enable: function(node) {
|
||||
if (node && node._type === 'server' &&
|
||||
node.is_password_saved) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return (node && node._type === 'server' &&
|
||||
node.is_password_saved);
|
||||
},
|
||||
},{
|
||||
name: 'clear_sshtunnel_password', node: 'server', module: this,
|
||||
@ -158,11 +153,8 @@ define('pgadmin.node.server', [
|
||||
label: gettext('Clear SSH Tunnel Password'), icon: 'fa fa-eraser',
|
||||
priority: 12,
|
||||
enable: function(node) {
|
||||
if (node && node._type === 'server' &&
|
||||
node.is_tunnel_password_saved) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return (node && node._type === 'server' &&
|
||||
node.is_tunnel_password_saved);
|
||||
},
|
||||
data: {
|
||||
data_disabled: gettext('SSH Tunnel password is not saved for selected server.'),
|
||||
@ -175,54 +167,38 @@ define('pgadmin.node.server', [
|
||||
);
|
||||
},
|
||||
is_not_connected: function(node) {
|
||||
return (node && node.connected != true);
|
||||
return (node && !node.connected);
|
||||
},
|
||||
canCreate: function(node){
|
||||
let serverOwner = node.user_id;
|
||||
if (serverOwner == current_user.id || _.isUndefined(serverOwner))
|
||||
return true;
|
||||
return false;
|
||||
return (serverOwner == current_user.id || _.isUndefined(serverOwner));
|
||||
|
||||
},
|
||||
is_connected: function(node) {
|
||||
return (node && node.connected == true);
|
||||
return (node && node.connected);
|
||||
},
|
||||
enable_reload_config: function(node) {
|
||||
// Must be connected & is Super user
|
||||
if (node && node._type == 'server' &&
|
||||
node.connected && node.user.is_superuser) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return (node && node._type == 'server' &&
|
||||
node.connected && node.user.is_superuser);
|
||||
},
|
||||
is_applicable: function(node) {
|
||||
// Must be connected & super user & not in recovery mode
|
||||
if (node && node._type == 'server' &&
|
||||
return (node && node._type == 'server' &&
|
||||
node.connected && node.user.is_superuser
|
||||
&& node.in_recovery == false) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
&& !node.in_recovery);
|
||||
},
|
||||
wal_pause_enabled: function(node) {
|
||||
// Must be connected & is Super user & in Recovery mode
|
||||
if (node && node._type == 'server' &&
|
||||
return (node && node._type == 'server' &&
|
||||
node.connected && node.user.is_superuser
|
||||
&& node.in_recovery == true
|
||||
&& node.wal_pause == false) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
&& node.in_recovery && !node.wal_pause);
|
||||
},
|
||||
wal_resume_enabled: function(node) {
|
||||
// Must be connected & is Super user & in Recovery mode
|
||||
if (node && node._type == 'server' &&
|
||||
return (node && node._type == 'server' &&
|
||||
node.connected && node.user.is_superuser
|
||||
&& node.in_recovery == true
|
||||
&& node.wal_pause == true) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
&& node.in_recovery && node.wal_pause);
|
||||
},
|
||||
callbacks: {
|
||||
/* Connect the server */
|
||||
|
@ -74,11 +74,7 @@ export default class VacuumSettingsSchema extends BaseUISchema {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(obj.inCatalog)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !obj.inCatalog;
|
||||
},
|
||||
depChange(state) {
|
||||
if(state.is_partitioned) {
|
||||
@ -96,10 +92,7 @@ export default class VacuumSettingsSchema extends BaseUISchema {
|
||||
],
|
||||
deps: ['autovacuum_custom'],
|
||||
disabled: function(state) {
|
||||
if(obj.inCatalog && state.autovacuum_custom) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !(obj.inCatalog && state.autovacuum_custom);
|
||||
},
|
||||
depChange: function(state) {
|
||||
if(obj.inCatalog && state.autovacuum_custom) {
|
||||
@ -122,10 +115,7 @@ export default class VacuumSettingsSchema extends BaseUISchema {
|
||||
disabled: function(state) {
|
||||
// We need to check additional condition to toggle enable/disable
|
||||
// for table auto-vacuum
|
||||
if(obj.inCatalog && (obj.top.isNew() || state.hastoasttable)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !(obj.inCatalog && (obj.top.isNew() || state.hastoasttable));
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -139,10 +129,7 @@ export default class VacuumSettingsSchema extends BaseUISchema {
|
||||
],
|
||||
deps:['toast_autovacuum'],
|
||||
disabled: function(state) {
|
||||
if(obj.inCatalog && state.toast_autovacuum) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !(obj.inCatalog && state.toast_autovacuum);
|
||||
},
|
||||
depChange: function(state) {
|
||||
if(obj.inCatalog && state.toast_autovacuum) {
|
||||
|
@ -40,18 +40,14 @@ define('pgadmin.node.server_group', [
|
||||
getSchema: ()=>new ServerGroupSchema(),
|
||||
canDrop: function(itemData) {
|
||||
let serverOwner = itemData.user_id;
|
||||
if (serverOwner != current_user.id && !_.isUndefined(serverOwner))
|
||||
return false;
|
||||
return true; },
|
||||
return !(serverOwner != current_user.id && !_.isUndefined(serverOwner));
|
||||
},
|
||||
dropAsRemove: true,
|
||||
canDelete: function(i) {
|
||||
let s = pgAdmin.Browser.tree.siblings(i, true);
|
||||
|
||||
/* This is the only server group - we can't remove it*/
|
||||
if (!s || s.length == 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !(!s || s.length == 0);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
@ -337,11 +337,8 @@ define([
|
||||
return false;
|
||||
}
|
||||
|
||||
if ('validate' in self && _.isFunction(self.validate) &&
|
||||
_.isString(self.validate.apply(self))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !('validate' in self && _.isFunction(self.validate) &&
|
||||
_.isString(self.validate.apply(self)));
|
||||
},
|
||||
set: function(key, val, options) {
|
||||
let opts = _.isObject(key) ? val : options;
|
||||
@ -445,7 +442,7 @@ define([
|
||||
let self = this,
|
||||
res, isNew = self.isNew();
|
||||
|
||||
session = (typeof(session) != 'undefined' && session == true);
|
||||
session = (typeof(session) != 'undefined' && session);
|
||||
|
||||
if (!session || isNew) {
|
||||
res = Backbone.Model.prototype.toJSON.call(this, arguments);
|
||||
@ -1040,7 +1037,7 @@ define([
|
||||
*/
|
||||
toJSON: function(session) {
|
||||
let self = this;
|
||||
session = (typeof(session) != 'undefined' && session == true);
|
||||
session = (typeof(session) != 'undefined' && session);
|
||||
|
||||
if (!session) {
|
||||
return Backbone.Collection.prototype.toJSON.call(self);
|
||||
|
@ -463,10 +463,7 @@ class AzureDatabaseSchema extends BaseUISchema {
|
||||
}
|
||||
|
||||
validate(data, setErrMsg) {
|
||||
if (this.validateDbUserName(data, setErrMsg) || this.validateDbPassword(data, setErrMsg)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return this.validateDbUserName(data, setErrMsg) || this.validateDbPassword(data, setErrMsg);
|
||||
}
|
||||
|
||||
get baseFields() {
|
||||
@ -729,10 +726,7 @@ class AzureClusterSchema extends BaseUISchema {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(this.validateProjectDetails(data, setErr) || this.validateInstanceDetails(data, setErr) || this.validateNetworkDetails(data, setErr)){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return (this.validateProjectDetails(data, setErr) || this.validateInstanceDetails(data, setErr) || this.validateNetworkDetails(data, setErr));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -287,8 +287,7 @@ export class StorageSchema extends BaseUISchema {
|
||||
id: 'storage_IOPS', label: gettext('Provisioned IOPS'), type: 'text',
|
||||
mode: ['create'],
|
||||
visible: (state) => {
|
||||
if(state.storage_type === 'io1') return true;
|
||||
return false;
|
||||
return state.storage_type === 'io1';
|
||||
} , deps: ['storage_type'],
|
||||
depChange: (state, source) => {
|
||||
if (source[0] !== 'storage_IOPS') {
|
||||
@ -488,7 +487,7 @@ class BigAnimalDatabaseSchema extends BaseUISchema {
|
||||
setErrMsg('confirm_password', gettext('Password must be 12 characters or more.'));
|
||||
return true;
|
||||
}
|
||||
if (data.high_availability == true && (isEmptyString(data.replicas) || data.replicas <= 0)) {
|
||||
if (data.high_availability && (isEmptyString(data.replicas) || data.replicas <= 0)) {
|
||||
setErrMsg('replicas', gettext('Please select number of stand by replicas.'));
|
||||
return true;
|
||||
}
|
||||
@ -630,8 +629,7 @@ class BigAnimalHighAvailSchema extends BaseUISchema {
|
||||
{'label': gettext('2'), 'value': 2},
|
||||
], noEmpty: true,
|
||||
disabled: (state) => {
|
||||
if (state.high_availability == true) return false;
|
||||
return true;
|
||||
return !state.high_availability;
|
||||
}
|
||||
},
|
||||
];
|
||||
|
@ -139,18 +139,12 @@ export default class BaseUISchema {
|
||||
|
||||
/* Check if node in catalog */
|
||||
inCatalog() {
|
||||
if(this.nodeInfo && 'catalog' in this.nodeInfo) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return this.nodeInfo && 'catalog' in this.nodeInfo;
|
||||
}
|
||||
|
||||
/* Check readonly on the basis of new state */
|
||||
isReadOnly(state) {
|
||||
if(!this.isNew(state)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return !this.isNew(state);
|
||||
}
|
||||
|
||||
/* Get the server version */
|
||||
|
@ -117,10 +117,7 @@
|
||||
//this reg will check the token should be in format as - IF condition or IF(condition)
|
||||
let reg = `\\b\\${startToken}\\s*\\(\\w*\\)(?!\\w)|\\b\\${startToken}\\(\\w*\\)(?!\\w)|\\b\\${startToken}\\s*(?!\\w)`;
|
||||
let regex = RegExp(reg, 'g');
|
||||
if(regex.exec(text) !== null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return regex.exec(text) !== null;
|
||||
}
|
||||
|
||||
CodeMirror.registerHelper('fold', 'sql', function(cm, start) {
|
||||
|
@ -347,10 +347,7 @@ export default function PgTable({ columns, data, isSelectRow, caveTable=true, sc
|
||||
setHiddenColumns(
|
||||
columns
|
||||
.filter((column) => {
|
||||
if (column.isVisible === undefined || column.isVisible === true) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !(column.isVisible === undefined || column.isVisible === true);
|
||||
}
|
||||
)
|
||||
.map((column) => column.accessor)
|
||||
|
@ -194,9 +194,7 @@ export function getSaveOptSchema(fieldOptions) {
|
||||
}
|
||||
|
||||
function isVisible () {
|
||||
if (!_.isUndefined(this.backupType) && this.backupType === 'server')
|
||||
return false;
|
||||
return true;
|
||||
return !(!_.isUndefined(this.backupType) && this.backupType === 'server');
|
||||
}
|
||||
|
||||
export class QueryOptionSchema extends BaseUISchema {
|
||||
@ -240,9 +238,7 @@ export class QueryOptionSchema extends BaseUISchema {
|
||||
disabled: false,
|
||||
group: gettext('Queries'),
|
||||
visible: function() {
|
||||
if (!_.isUndefined(obj.backupType) && obj.backupType === 'server')
|
||||
return false;
|
||||
return true;
|
||||
return !(!_.isUndefined(obj.backupType) && obj.backupType === 'server');
|
||||
},
|
||||
}, {
|
||||
id: 'include_drop_database',
|
||||
|
@ -74,10 +74,7 @@ export default class ImportExportSelectionSchema extends BaseUISchema {
|
||||
}
|
||||
},
|
||||
disabled: function (state) {
|
||||
if (state.imp_exp == 'e') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return state.imp_exp == 'e';
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
@ -331,11 +331,7 @@ export function initialize(gettext, url_for, $, _, pgAdmin, csrfToken, Browser)
|
||||
document.execCommand('copy');
|
||||
}
|
||||
|
||||
if (e.ctrlKey && platform == 'win32') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return !(e.ctrlKey && platform == 'win32');
|
||||
});
|
||||
|
||||
term.textarea.addEventListener('paste', function() {
|
||||
|
@ -48,10 +48,7 @@ class UserManagementCollection extends BaseUISchema {
|
||||
}
|
||||
|
||||
isUserNameEnabled(state) {
|
||||
if (this.authOnlyInternal || state.auth_source == authConstant['INTERNAL']) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !(this.authOnlyInternal || state.auth_source == authConstant['INTERNAL']);
|
||||
}
|
||||
|
||||
isEditable(state) {
|
||||
@ -70,9 +67,7 @@ class UserManagementCollection extends BaseUISchema {
|
||||
first_empty: false,
|
||||
},
|
||||
visible: function() {
|
||||
if (obj.authOnlyInternal)
|
||||
return false;
|
||||
return true;
|
||||
return !obj.authOnlyInternal;
|
||||
},
|
||||
editable: function(state) {
|
||||
return (obj.isNew(state) && !obj.authOnlyInternal);
|
||||
@ -96,10 +91,7 @@ class UserManagementCollection extends BaseUISchema {
|
||||
if (obj.isNew(state))
|
||||
return true;
|
||||
|
||||
if (obj.isEditable(state) && state.auth_source != authConstant['INTERNAL'])
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return obj.isEditable(state) && state.auth_source != authConstant['INTERNAL'];
|
||||
}
|
||||
}, {
|
||||
id: 'role', label: gettext('Role'), cell: 'select',
|
||||
@ -246,9 +238,7 @@ class UserManagementSchema extends BaseUISchema {
|
||||
id: 'userManagement', label: '', type: 'collection', schema: obj.userManagementCollObj,
|
||||
canAdd: true, canDelete: true, isFullTab: true, group: 'temp_user',
|
||||
canDeleteRow: (row)=>{
|
||||
if (row['id'] == current_user['id'])
|
||||
return false;
|
||||
return true;
|
||||
return row['id'] != current_user['id'];
|
||||
},
|
||||
onDelete: (row, deleteRow)=> {
|
||||
let deletedUser = {'id': row['id'], 'name': !isEmptyString(row['email']) ? row['email'] : row['username']};
|
||||
|
Loading…
Reference in New Issue
Block a user