From 78c8fbbe0026e71f123d381c51af417be35b66c4 Mon Sep 17 00:00:00 2001 From: Aditya Toshniwal Date: Thu, 23 Sep 2021 10:42:50 +0530 Subject: [PATCH] Fixed an issue where the Properties panel was not loaded for catalog tables. Fixes #6778 --- .../tables/columns/static/js/column.ui.js | 8 +++----- .../schemas/tables/static/js/table.ui.js | 19 ++++++++++--------- web/pgadmin/static/js/SchemaView/FormView.jsx | 3 +++ 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/static/js/column.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/static/js/column.ui.js index 7fc53a242..337c5a0fa 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/static/js/column.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/static/js/column.ui.js @@ -363,11 +363,9 @@ export default class ColumnSchema extends BaseUISchema { },{ id: 'defval', label: gettext('Default'), cell: 'text', type: 'text', group: gettext('Constraints'), deps: ['cltype', 'colconstype'], + readonly: obj.inSchemaWithColumnCheck, disabled: function(state) { - var isDisabled = false; - if(!obj.inSchemaWithModelCheck(state)) { - isDisabled = ['serial', 'bigserial', 'smallserial'].indexOf(state.cltype) > -1; - } + var isDisabled = ['serial', 'bigserial', 'smallserial'].indexOf(state.cltype) > -1; isDisabled = isDisabled || state.colconstype != 'n'; return isDisabled; }, depChange: (state)=>{ @@ -381,7 +379,7 @@ export default class ColumnSchema extends BaseUISchema { } }, editable: function(state) { // inheritedfrom has value then we should disable it - if (!isEmptyString(state.inheritedfrom)) { + if (!isEmptyString(state.inheritedfrom) || !this.editableCheckForTable(state)) { return false; } return true; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.ui.js index d9525106a..d9c3f1fdf 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.ui.js @@ -61,7 +61,7 @@ export function getNodeTableSchema(treeNodeInfo, itemNodeData, pgBrowser) { ()=>getNodeAjaxOptions('get_op_class', pgBrowser.Nodes['table'], treeNodeInfo, itemNodeData), { relowner: pgBrowser.serverInfo[treeNodeInfo.server._id].user.name, - schema: treeNodeInfo.schema._label, + schema: treeNodeInfo.schema?._label, } ); } @@ -69,6 +69,7 @@ export function getNodeTableSchema(treeNodeInfo, itemNodeData, pgBrowser) { export class ConstraintsSchema extends BaseUISchema { constructor(nodeInfo, getFkObj, getExConsObj, otherOptions) { super(); + this.nodeInfo = nodeInfo; this.primaryKeyObj = new PrimaryKeySchema({ spcname: otherOptions.spcname, }, nodeInfo); @@ -99,6 +100,7 @@ export class ConstraintsSchema extends BaseUISchema { group: gettext('Primary Key'), mode: ['edit', 'create'], canEdit: true, canDelete: true, deps:['is_partitioned', 'typname'], columns : ['name', 'columns'], + disabled: this.inCatalog, canAdd: function(state) { if (state.is_partitioned && obj.top.getServerVersion() < 110000) { return false; @@ -135,6 +137,7 @@ export class ConstraintsSchema extends BaseUISchema { return true; }, columns : ['name', 'columns','references_table_name'], + disabled: this.inCatalog, canAddRow: obj.anyColumnAdded, depChange: (state)=>{ if (state.is_partitioned && obj.top.getServerVersion() < 110000 || state.columns?.length <= 0) { @@ -149,6 +152,7 @@ export class ConstraintsSchema extends BaseUISchema { canEdit: true, canDelete: true, deps:['is_partitioned'], canAdd: true, columns : ['name', 'consrc'], + disabled: this.inCatalog, },{ id: 'unique_constraint', label: '', schema: this.uniqueConsObj, @@ -156,6 +160,7 @@ export class ConstraintsSchema extends BaseUISchema { group: gettext('Unique'), mode: ['edit', 'create'], canEdit: true, canDelete: true, deps:['is_partitioned', 'typname'], columns : ['name', 'columns'], + disabled: this.inCatalog, canAdd: function(state) { if (state.is_partitioned && obj.top.getServerVersion() < 110000) { return false; @@ -175,6 +180,7 @@ export class ConstraintsSchema extends BaseUISchema { group: gettext('Exclude'), mode: ['edit', 'create'], canEdit: true, canDelete: true, deps:['is_partitioned'], columns : ['name', 'columns', 'constraint'], + disabled: this.inCatalog, canAdd: function(state) { if (state.is_partitioned && obj.top.getServerVersion() < 110000) { return false; @@ -350,8 +356,9 @@ export default class TableSchema extends BaseUISchema { if (!isEmptyString(state.typname)) { return false; } + return true; } - return true; + return false; } // Check for column grid when to edit/delete (for each row) @@ -559,13 +566,7 @@ export default class TableSchema extends BaseUISchema { group: gettext('Columns'), schema: this.columnsSchema, mode: ['create', 'edit'], - disabled: function() { - if(this.nodeInfo && 'catalog' in this.nodeInfo) - { - return true; - } - return false; - }, + disabled: this.inCatalog, deps: ['typname', 'is_partitioned'], depChange: (state, source, topState, actionObj)=>{ if(source[0] === 'columns') { diff --git a/web/pgadmin/static/js/SchemaView/FormView.jsx b/web/pgadmin/static/js/SchemaView/FormView.jsx index f872703ca..b9799f82f 100644 --- a/web/pgadmin/static/js/SchemaView/FormView.jsx +++ b/web/pgadmin/static/js/SchemaView/FormView.jsx @@ -125,8 +125,11 @@ export function getFieldMetaData(field, schema, value, viewHelperProps, onlyMode let {canAdd, canEdit, canDelete, canAddRow } = field; retData.canAdd = _.isUndefined(canAdd) ? retData.canAdd : evalFunc(schema, canAdd, value); + retData.canAdd = !disabled && retData.canAdd; retData.canEdit = _.isUndefined(canEdit) ? retData.canEdit : evalFunc(schema, canEdit, value); + retData.canEdit = !disabled && retData.canEdit; retData.canDelete = _.isUndefined(canDelete) ? retData.canDelete : evalFunc(schema, canDelete, value); + retData.canDelete = !disabled && retData.canDelete; retData.canAddRow = _.isUndefined(canAddRow) ? retData.canAddRow : evalFunc(schema, canAddRow, value); return retData; }