diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/catalog.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/catalog.js
index 9b60f949d..c05c20de0 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/catalog.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/catalog.js
@@ -7,6 +7,8 @@
//
//////////////////////////////////////////////////////////////
+import CatalogSchema from './catalog.ui';
+
define('pgadmin.node.catalog', [
'sources/gettext', 'jquery', 'underscore', 'sources/pgadmin',
'pgadmin.browser', 'pgadmin.browser.collection',
@@ -41,14 +43,6 @@ define('pgadmin.node.catalog', [
},
model: pgBrowser.Node.Model.extend({
- defaults: {
- name: undefined,
- namespaceowner: undefined,
- nspacl: undefined,
- is_sys_obj: undefined,
- description: undefined,
- securitylabel: [],
- },
initialize: function(attrs, args) {
var isNew = (_.size(attrs) === 0);
@@ -65,30 +59,15 @@ define('pgadmin.node.catalog', [
},{
id: 'oid', label: gettext('OID'), cell: 'string', mode: ['properties'],
type: 'text',
- },{
- id: 'namespaceowner', label: gettext('Owner'), cell: 'string',
- type: 'text', readonly: true,
- },{
- id: 'acl', label: gettext('Privileges'), type: 'text',
- group: gettext('Security'), mode: ['properties'],
- },{
- id: 'is_sys_obj', label: gettext('System catalog?'),
- cell:'boolean', type: 'switch', mode: ['properties'],
- },{
- id: 'description', label: gettext('Comment'), cell: 'string',
- type: 'multiline',
- },{
- id: 'seclabels', label: gettext('Security labels'),
- model: pgBrowser.SecLabelModel, editable: false, type: 'collection',
- group: gettext('Security'), mode: ['edit', 'create'],
- min_version: 90200, canAdd: true,
- canEdit: false, canDelete: true, control: 'unique-col-collection',
- },
- ],
- validate: function() {
- return null;
- },
+ }]
}),
+ getSchema: function(treeNodeInfo) {
+ return new CatalogSchema(
+ {
+ namespaceowner: pgBrowser.serverInfo[treeNodeInfo.server._id].user.name
+ }
+ );
+ }
});
}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/catalog.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/catalog.ui.js
new file mode 100644
index 000000000..c31422185
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/catalog.ui.js
@@ -0,0 +1,64 @@
+/////////////////////////////////////////////////////////////
+//
+// pgAdmin 4 - PostgreSQL Tools
+//
+// Copyright (C) 2013 - 2021, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////
+
+import gettext from 'sources/gettext';
+import BaseUISchema from 'sources/SchemaView/base_schema.ui';
+import SecLabelSchema from '../../../../static/js/sec_label.ui';
+
+export default class CatalogSchema extends BaseUISchema {
+ constructor(fieldOptions = {}, initValues) {
+ super({
+ name: undefined,
+ namespaceowner: undefined,
+ nspacl: undefined,
+ is_sys_obj: undefined,
+ description: undefined,
+ securitylabel: [],
+ ...initValues
+ });
+ this.fieldOptions = {
+ ...fieldOptions,
+ };
+ }
+
+ get idAttribute() {
+ return 'oid';
+ }
+
+ get baseFields() {
+ return [
+ {
+ id: 'name', label: gettext('Name'), cell: 'string',
+ type: 'text', readonly: true,
+ },{
+ id: 'oid', label: gettext('OID'), cell: 'string', mode: ['properties'],
+ type: 'text',
+ },{
+ id: 'namespaceowner', label: gettext('Owner'), cell: 'string',
+ type: 'text', readonly: true,
+ },{
+ id: 'acl', label: gettext('Privileges'), type: 'text',
+ group: gettext('Security'), mode: ['properties'],
+ },{
+ id: 'is_sys_obj', label: gettext('System catalog?'),
+ cell:'boolean', type: 'switch', mode: ['properties'],
+ },{
+ id: 'description', label: gettext('Comment'), cell: 'string',
+ type: 'multiline',
+ },{
+ id: 'seclabels', label: gettext('Security labels'),
+ schema: new SecLabelSchema(),
+ editable: false, type: 'collection',
+ group: gettext('Security'), mode: ['edit', 'create'],
+ min_version: 90200,
+ canAdd: false, canEdit: false, canDelete: false,
+ },
+ ];
+ }
+}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema.js
index 740c9fff1..46e01185d 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema.js
@@ -7,6 +7,10 @@
//
//////////////////////////////////////////////////////////////
+import PGSchema from './schema.ui';
+import { getNodePrivilegeRoleSchema } from '../../../../static/js/privilege.ui';
+import { getNodeListByName } from '../../../../../../static/js/node_ajax';
+
define('pgadmin.node.schema', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backform', 'pgadmin.backgrid',
@@ -149,6 +153,8 @@ define('pgadmin.node.schema', [
},
});
+ /* As Backform.VacuumSettingsSchema is commonly used in table & partition, so keeping it as it is for now.
+ this and other supporting model can be removed after their migration to react. */
// Extend the browser's collection class for VacuumSettingsModel
Backform.VacuumSettingsSchema = [{
id: 'spacer_ctrl', group: gettext('Table'), mode: ['edit', 'create'], type: 'spacer',
@@ -357,12 +363,6 @@ define('pgadmin.node.schema', [
},
model: pgBrowser.Node.Model.extend({
idAttribute: 'oid',
- defaults: {
- name: undefined,
- namespaceowner: undefined,
- description: undefined,
- is_system_obj: undefined,
- },
initialize: function(attrs, args) {
var isNew = (_.size(attrs) === 0);
@@ -388,94 +388,24 @@ define('pgadmin.node.schema', [
cell: 'switch', type: 'switch', mode: ['properties'],
},{
id: 'description', label: gettext('Comment'), cell: 'string',
- type: 'multiline',
- },{
- id: 'acl', label: gettext('Privileges'), type: 'text',
- group: gettext('Security'), mode: ['properties'],
- },{
- id: 'tblacl', label: gettext('Default TABLE privileges'), type: 'text',
- group: gettext('Security'), mode: ['properties'],
- },{
- id: 'seqacl', label: gettext('Default SEQUENCE privileges'), type: 'text',
- group: gettext('Security'), mode: ['properties'],
- },{
- id: 'funcacl', label: gettext('Default FUNCTION privileges'),
- group: gettext('Security'), type: 'text', mode: ['properties'],
- },{
- id: 'typeacl', label: gettext('Default TYPE privileges'), type: 'text',
- group: gettext('Security'), mode: ['properties'], min_version: 90200,
- visible: function() {
- return this.version_compatible;
- },
- },{
- id: 'nspacl', label: gettext('Privileges'),
- model: pgBrowser.Node.PrivilegeRoleModel.extend(
- {privileges: ['C', 'U']}), uniqueCol : ['grantee', 'grantor'],
- editable: false, type: 'collection', group: gettext('Security'),
- mode: ['edit', 'create'],
- canAdd: true, canDelete: true, control: 'unique-col-collection',
- },{
- id: 'seclabels', label: gettext('Security labels'),
- model: pgBrowser.SecLabelModel, editable: false, type: 'collection',
- group: gettext('Security'), mode: ['edit', 'create'],
- min_version: 90200, canAdd: true,
- canEdit: false, canDelete: true, control: 'unique-col-collection',
- },{
- type: 'nested', control: 'tab', group: gettext('Default privileges'),
- mode: ['create','edit'],
- schema:[{
- id: 'deftblacl', model: pgBrowser.Node.PrivilegeRoleModel.extend(
- {privileges: ['a', 'r', 'w', 'd', 'D', 'x', 't']}),
- label: '',
- editable: false, type: 'collection', group: gettext('Tables'),
- mode: ['edit', 'create'], control: 'unique-col-collection',
- canAdd: true, canDelete: true, uniqueCol : ['grantee', 'grantor'],
- },{
- id: 'defseqacl', model: pgBrowser.Node.PrivilegeRoleModel.extend(
- {privileges: ['r', 'w', 'U']}),
- label: '',
- editable: false, type: 'collection', group: gettext('Sequences'),
- mode: ['edit', 'create'], control: 'unique-col-collection',
- canAdd: true, canDelete: true, uniqueCol : ['grantee', 'grantor'],
- },{
- id: 'deffuncacl', model: pgBrowser.Node.PrivilegeRoleModel.extend(
- {privileges: ['X']}),
- label: '',
- editable: false, type: 'collection', group: gettext('Functions'),
- mode: ['edit', 'create'], control: 'unique-col-collection',
- canAdd: true, canDelete: true, uniqueCol : ['grantee', 'grantor'],
- },{
- id: 'deftypeacl', model: pgBrowser.Node.PrivilegeRoleModel.extend(
- {privileges: ['U']}),
- label: '',
- editable: false, type: 'collection', group: gettext('Types'),
- mode: ['edit', 'create'], control: 'unique-col-collection',
- canAdd: true, canDelete: true, uniqueCol : ['grantee', 'grantor'],
- min_version: 90200,
- }],
- },
- ],
- validate: function() {
- var errmsg = null;
-
- // Validation of mandatory fields
- this.errorModel.clear();
- if (_.isUndefined(this.get('name')) ||
- _.isNull(this.get('name')) ||
- String(this.get('name')).replace(/^\s+|\s+$/g, '') == '') {
- errmsg = gettext('Name cannot be empty.');
- this.errorModel.set('name', errmsg);
- return errmsg;
- } else if (_.isUndefined(this.get('namespaceowner')) ||
- _.isNull(this.get('namespaceowner')) ||
- String(this.get('namespaceowner')).replace(/^\s+|\s+$/g, '') == '') {
- errmsg = gettext('Owner cannot be empty.');
- this.errorModel.set('namespaceowner', errmsg);
- return errmsg;
- }
- return null;
- },
+ type: 'multiline'
+ }]
}),
+ getSchema: function(treeNodeInfo, itemNodeData) {
+ var schemaObj = pgBrowser.Nodes['schema'];
+ return new PGSchema(
+ (privileges)=>getNodePrivilegeRoleSchema(schemaObj, treeNodeInfo, itemNodeData, privileges),
+ {
+ roles:() => getNodeListByName('role', treeNodeInfo, itemNodeData, {
+ cacheLevel: 'database'
+ }),
+ server_info: pgBrowser.serverInfo[treeNodeInfo.server._id]
+ },
+ {
+ namespaceowner: pgBrowser.serverInfo[treeNodeInfo.server._id].user.name
+ }
+ );
+ }
});
pgBrowser.tableChildTreeNodeHierarchy = function(i) {
@@ -483,6 +413,8 @@ define('pgadmin.node.schema', [
};
}
+ /* As TableChildSwitchCell is commonly used in index, column & TableDialog, so keeping it as it is for now.
+ this and other supporting model can be removed after their migration to react. */
// Switch Cell with Deps (specifically for table children)
Backgrid.Extension.TableChildSwitchCell = Backgrid.Extension.SwitchCell.extend({
initialize: function() {
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema.ui.js
new file mode 100644
index 000000000..6f716bd66
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema.ui.js
@@ -0,0 +1,112 @@
+/////////////////////////////////////////////////////////////
+//
+// pgAdmin 4 - PostgreSQL Tools
+//
+// Copyright (C) 2013 - 2021, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////
+
+import gettext from 'sources/gettext';
+import BaseUISchema from 'sources/SchemaView/base_schema.ui';
+import { DefaultPrivSchema } from '../../../static/js/database.ui';
+import SecLabelSchema from '../../../../static/js/sec_label.ui';
+import { isEmptyString } from 'sources/validators';
+
+export default class PGSchema extends BaseUISchema {
+ constructor(getPrivilegeRoleSchema, fieldOptions = {}, initValues) {
+ super({
+ name: undefined,
+ namespaceowner: undefined,
+ description: undefined,
+ is_system_obj: undefined,
+ ...initValues
+ });
+ this.fieldOptions = {
+ roles: [],
+ server_info: [],
+ ...fieldOptions,
+ };
+ this.getPrivilegeRoleSchema = getPrivilegeRoleSchema;
+ }
+
+ get idAttribute() {
+ return 'oid';
+ }
+
+ get baseFields() {
+ let pgSchemaObj = this;
+ return [
+ {
+ id: 'name', label: gettext('Name'), cell: 'string',
+ type: 'text',
+ },{
+ id: 'oid', label: gettext('OID'), cell: 'string',
+ type: 'text', mode: ['properties'],
+ },{
+ id: 'namespaceowner', label: gettext('Owner'), cell: 'string',
+ type: 'select',
+ options: pgSchemaObj.fieldOptions.roles,
+ controlProps: { allowClear: false }
+ },{
+ id: 'is_sys_obj', label: gettext('System schema?'),
+ cell: 'switch', type: 'switch', mode: ['properties'],
+ },{
+ id: 'description', label: gettext('Comment'), cell: 'string',
+ type: 'multiline',
+ },{
+ id: 'acl', label: gettext('Privileges'), type: 'text',
+ group: gettext('Security'), mode: ['properties'],
+ },{
+ id: 'tblacl', label: gettext('Default TABLE privileges'), type: 'text',
+ group: gettext('Security'), mode: ['properties'],
+ },{
+ id: 'seqacl', label: gettext('Default SEQUENCE privileges'), type: 'text',
+ group: gettext('Security'), mode: ['properties'],
+ },{
+ id: 'funcacl', label: gettext('Default FUNCTION privileges'),
+ group: gettext('Security'), type: 'text', mode: ['properties'],
+ },{
+ id: 'typeacl', label: gettext('Default TYPE privileges'), type: 'text',
+ group: gettext('Security'), mode: ['properties'], min_version: 90200
+ },
+ {
+ id: 'nspacl', label: gettext('Privileges'), type: 'collection',
+ schema: pgSchemaObj.getPrivilegeRoleSchema(['C', 'U']),
+ uniqueCol : ['grantee', 'grantor'], editable: false,
+ group: gettext('Security'), mode: ['edit', 'create'],
+ canAdd: true, canDelete: true,
+ },
+ {
+ id: 'seclabels', label: gettext('Security labels'),
+ schema: new SecLabelSchema(), editable: false, type: 'collection',
+ group: gettext('Security'), mode: ['edit', 'create'],
+ min_version: 90200, canAdd: true,
+ canEdit: false, canDelete: true,
+ },
+ {
+ type: 'nested-tab',
+ group: gettext('Default privileges'),
+ mode: ['create','edit'],
+ schema: new DefaultPrivSchema(pgSchemaObj.getPrivilegeRoleSchema)
+ }
+ ];
+ }
+
+ validate(state, setError) {
+ var errmsg = null;
+
+ // Validation of mandatory fields
+ if (isEmptyString(state.name)) {
+ errmsg = gettext('Name cannot be empty.');
+ setError('name', errmsg);
+ return true;
+ }
+ else if(isEmptyString(state.namespaceowner)) {
+ errmsg = gettext('Owner cannot be empty.');
+ setError('namespaceowner', errmsg);
+ return true;
+ }
+ return null;
+ }
+}
diff --git a/web/pgadmin/browser/static/js/node_view.jsx b/web/pgadmin/browser/static/js/node_view.jsx
index 9067b5a1b..a6829066c 100644
--- a/web/pgadmin/browser/static/js/node_view.jsx
+++ b/web/pgadmin/browser/static/js/node_view.jsx
@@ -195,6 +195,7 @@ export function getNodeView(nodeType, treeNodeInfo, actionType, itemNodeData, fo
hasSQL={nodeObj.hasSQL && (actionType === 'create' || actionType === 'edit')}
getSQLValue={getSQLValue}
disableSqlHelp={nodeObj.sqlAlterHelp == '' && nodeObj.sqlCreateHelp == ''}
+ disableDialogHelp={nodeObj.dialogHelp == undefined || nodeObj.dialogHelp == ''}
/>, container);
}
diff --git a/web/pgadmin/static/js/SchemaView/index.jsx b/web/pgadmin/static/js/SchemaView/index.jsx
index 3402d43e5..f125998b1 100644
--- a/web/pgadmin/static/js/SchemaView/index.jsx
+++ b/web/pgadmin/static/js/SchemaView/index.jsx
@@ -634,7 +634,8 @@ function SchemaDialogView({
{useMemo(()=>
props.onHelp(true, isNew)} icon={}
disabled={props.disableSqlHelp} className={classes.buttonMargin} title="SQL help for this object type."/>
- props.onHelp(false, isNew)} icon={} title="Help for this dialog."/>
+ props.onHelp(false, isNew)} icon={} title="Help for this dialog."
+ disabled={props.disableDialogHelp}/>
, [])}
} className={classes.buttonMargin}>
@@ -673,6 +674,7 @@ SchemaDialogView.propTypes = {
hasSQL: PropTypes.bool,
getSQLValue: PropTypes.func,
disableSqlHelp: PropTypes.bool,
+ disableDialogHelp: PropTypes.bool,
};
const usePropsStyles = makeStyles((theme)=>({
diff --git a/web/regression/javascript/schema_ui_files/cast.ui.spec.js b/web/regression/javascript/schema_ui_files/cast.ui.spec.js
index 1825d202d..516d9ca4d 100644
--- a/web/regression/javascript/schema_ui_files/cast.ui.spec.js
+++ b/web/regression/javascript/schema_ui_files/cast.ui.spec.js
@@ -60,6 +60,7 @@ describe('CastSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -79,6 +80,7 @@ describe('CastSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
diff --git a/web/regression/javascript/schema_ui_files/catalog.ui.spec.js b/web/regression/javascript/schema_ui_files/catalog.ui.spec.js
new file mode 100644
index 000000000..4efbfc935
--- /dev/null
+++ b/web/regression/javascript/schema_ui_files/catalog.ui.spec.js
@@ -0,0 +1,99 @@
+/////////////////////////////////////////////////////////////
+//
+// pgAdmin 4 - PostgreSQL Tools
+//
+// Copyright (C) 2013 - 2021, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////
+
+import jasmineEnzyme from 'jasmine-enzyme';
+import React from 'react';
+import '../helper/enzyme.helper';
+import { createMount } from '@material-ui/core/test-utils';
+import pgAdmin from 'sources/pgadmin';
+import {messages} from '../fake_messages';
+import SchemaView from '../../../pgadmin/static/js/SchemaView';
+import CatalogSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/static/js/catalog.ui';
+
+
+describe('CatalogSchema', ()=>{
+ let mount;
+ let catalogObj = new CatalogSchema(
+ {
+ namespaceowner: '',
+ }
+ );
+ let getInitData = ()=>Promise.resolve({});
+
+ /* Use createMount so that material ui components gets the required context */
+ /* https://material-ui.com/guides/testing/#api */
+ beforeAll(()=>{
+ mount = createMount();
+ });
+
+ afterAll(() => {
+ mount.cleanUp();
+ });
+
+ beforeEach(()=>{
+ jasmineEnzyme();
+ /* messages used by validators */
+ pgAdmin.Browser = pgAdmin.Browser || {};
+ pgAdmin.Browser.messages = pgAdmin.Browser.messages || messages;
+ pgAdmin.Browser.utils = pgAdmin.Browser.utils || {};
+ });
+
+ it('create', ()=>{
+ mount({}}
+ onClose={()=>{}}
+ onHelp={()=>{}}
+ onEdit={()=>{}}
+ onDataChange={()=>{}}
+ confirmOnCloseReset={false}
+ hasSQL={false}
+ disableSqlHelp={false}
+ disableDialogHelp={true}
+ />);
+ });
+
+ it('edit', ()=>{
+ mount({}}
+ onClose={()=>{}}
+ onHelp={()=>{}}
+ onEdit={()=>{}}
+ onDataChange={()=>{}}
+ confirmOnCloseReset={false}
+ hasSQL={false}
+ disableSqlHelp={false}
+ disableDialogHelp={true}
+ />);
+ });
+
+ it('properties', ()=>{
+ mount({}}
+ onEdit={()=>{}}
+ />);
+ });
+});
+
diff --git a/web/regression/javascript/schema_ui_files/collation.ui.spec.js b/web/regression/javascript/schema_ui_files/collation.ui.spec.js
index 3bec82d0c..3c8f8c570 100644
--- a/web/regression/javascript/schema_ui_files/collation.ui.spec.js
+++ b/web/regression/javascript/schema_ui_files/collation.ui.spec.js
@@ -66,6 +66,7 @@ describe('CollationsSchema', () => {
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -85,6 +86,7 @@ describe('CollationsSchema', () => {
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
diff --git a/web/regression/javascript/schema_ui_files/database.ui.spec.js b/web/regression/javascript/schema_ui_files/database.ui.spec.js
index f8a76799c..bfe40147a 100644
--- a/web/regression/javascript/schema_ui_files/database.ui.spec.js
+++ b/web/regression/javascript/schema_ui_files/database.ui.spec.js
@@ -77,6 +77,7 @@ describe('DatabaseSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -96,6 +97,7 @@ describe('DatabaseSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
diff --git a/web/regression/javascript/schema_ui_files/domain.ui.spec.js b/web/regression/javascript/schema_ui_files/domain.ui.spec.js
index b1161b403..c42d531fe 100644
--- a/web/regression/javascript/schema_ui_files/domain.ui.spec.js
+++ b/web/regression/javascript/schema_ui_files/domain.ui.spec.js
@@ -69,6 +69,7 @@ describe('DomainSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -88,6 +89,7 @@ describe('DomainSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -162,6 +164,7 @@ describe('DomainConstSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
/* Make sure you hit every corner */
@@ -184,6 +187,7 @@ describe('DomainConstSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
diff --git a/web/regression/javascript/schema_ui_files/domain_constraint.ui.spec.js b/web/regression/javascript/schema_ui_files/domain_constraint.ui.spec.js
index fdda11b8d..73e6da92f 100644
--- a/web/regression/javascript/schema_ui_files/domain_constraint.ui.spec.js
+++ b/web/regression/javascript/schema_ui_files/domain_constraint.ui.spec.js
@@ -54,6 +54,7 @@ describe('DomainConstraintSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -73,6 +74,7 @@ describe('DomainConstraintSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
diff --git a/web/regression/javascript/schema_ui_files/event_trigger.ui.spec.js b/web/regression/javascript/schema_ui_files/event_trigger.ui.spec.js
index 37d318bb4..70279fbc0 100644
--- a/web/regression/javascript/schema_ui_files/event_trigger.ui.spec.js
+++ b/web/regression/javascript/schema_ui_files/event_trigger.ui.spec.js
@@ -63,6 +63,7 @@ describe('EventTriggerSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -82,6 +83,7 @@ describe('EventTriggerSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
diff --git a/web/regression/javascript/schema_ui_files/extension.ui.spec.js b/web/regression/javascript/schema_ui_files/extension.ui.spec.js
index af498d880..ea20fb776 100644
--- a/web/regression/javascript/schema_ui_files/extension.ui.spec.js
+++ b/web/regression/javascript/schema_ui_files/extension.ui.spec.js
@@ -60,6 +60,7 @@ describe('ExtensionSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -79,6 +80,7 @@ describe('ExtensionSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
diff --git a/web/regression/javascript/schema_ui_files/foreign_data_wrapper.ui.spec.js b/web/regression/javascript/schema_ui_files/foreign_data_wrapper.ui.spec.js
index ee288e5dd..e2f2612ef 100644
--- a/web/regression/javascript/schema_ui_files/foreign_data_wrapper.ui.spec.js
+++ b/web/regression/javascript/schema_ui_files/foreign_data_wrapper.ui.spec.js
@@ -71,6 +71,7 @@ describe('ForeignDataWrapperSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -90,6 +91,7 @@ describe('ForeignDataWrapperSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
diff --git a/web/regression/javascript/schema_ui_files/foreign_server.ui.spec.js b/web/regression/javascript/schema_ui_files/foreign_server.ui.spec.js
index 495621d81..c52683a5a 100644
--- a/web/regression/javascript/schema_ui_files/foreign_server.ui.spec.js
+++ b/web/regression/javascript/schema_ui_files/foreign_server.ui.spec.js
@@ -69,6 +69,7 @@ describe('ForeignServerSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -88,6 +89,7 @@ describe('ForeignServerSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
diff --git a/web/regression/javascript/schema_ui_files/fts_dictionary.ui.spec.js b/web/regression/javascript/schema_ui_files/fts_dictionary.ui.spec.js
index a88cbbf77..dcf3021fa 100644
--- a/web/regression/javascript/schema_ui_files/fts_dictionary.ui.spec.js
+++ b/web/regression/javascript/schema_ui_files/fts_dictionary.ui.spec.js
@@ -65,6 +65,7 @@ describe('FTSDictionarySchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -84,6 +85,7 @@ describe('FTSDictionarySchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
diff --git a/web/regression/javascript/schema_ui_files/fts_parser.ui.spec.js b/web/regression/javascript/schema_ui_files/fts_parser.ui.spec.js
index f0999a831..b74d31ff1 100644
--- a/web/regression/javascript/schema_ui_files/fts_parser.ui.spec.js
+++ b/web/regression/javascript/schema_ui_files/fts_parser.ui.spec.js
@@ -67,6 +67,7 @@ describe('FTSParserSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -86,6 +87,7 @@ describe('FTSParserSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
diff --git a/web/regression/javascript/schema_ui_files/fts_template.ui.spec.js b/web/regression/javascript/schema_ui_files/fts_template.ui.spec.js
index a609b7d54..2c1663eb0 100644
--- a/web/regression/javascript/schema_ui_files/fts_template.ui.spec.js
+++ b/web/regression/javascript/schema_ui_files/fts_template.ui.spec.js
@@ -64,6 +64,7 @@ describe('FTSTemplateSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -83,6 +84,7 @@ describe('FTSTemplateSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
diff --git a/web/regression/javascript/schema_ui_files/language.ui.spec.js b/web/regression/javascript/schema_ui_files/language.ui.spec.js
index bc7989129..8ad431097 100644
--- a/web/regression/javascript/schema_ui_files/language.ui.spec.js
+++ b/web/regression/javascript/schema_ui_files/language.ui.spec.js
@@ -75,6 +75,7 @@ describe('LanguageSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -94,6 +95,7 @@ describe('LanguageSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
diff --git a/web/regression/javascript/schema_ui_files/mview.ui.spec.js b/web/regression/javascript/schema_ui_files/mview.ui.spec.js
index 66a9b48c0..520542d53 100644
--- a/web/regression/javascript/schema_ui_files/mview.ui.spec.js
+++ b/web/regression/javascript/schema_ui_files/mview.ui.spec.js
@@ -74,6 +74,7 @@ describe('MaterializedViewSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -93,6 +94,7 @@ describe('MaterializedViewSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
diff --git a/web/regression/javascript/schema_ui_files/privilege.ui.spec.js b/web/regression/javascript/schema_ui_files/privilege.ui.spec.js
index 5f93299f1..c55bcfbb6 100644
--- a/web/regression/javascript/schema_ui_files/privilege.ui.spec.js
+++ b/web/regression/javascript/schema_ui_files/privilege.ui.spec.js
@@ -63,6 +63,7 @@ describe('PrivilegeSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -82,6 +83,7 @@ describe('PrivilegeSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -123,6 +125,7 @@ describe('PrivilegeSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
/* Make sure you hit every corner */
ctrl.find('DataGridView').at(0).find('PgIconButton[data-test="add-row"]').find('button').simulate('click');
diff --git a/web/regression/javascript/schema_ui_files/publication.ui.spec.js b/web/regression/javascript/schema_ui_files/publication.ui.spec.js
index 7071979b4..2471268a6 100644
--- a/web/regression/javascript/schema_ui_files/publication.ui.spec.js
+++ b/web/regression/javascript/schema_ui_files/publication.ui.spec.js
@@ -70,6 +70,7 @@ describe('PublicationSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -89,6 +90,7 @@ describe('PublicationSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
diff --git a/web/regression/javascript/schema_ui_files/resource_group.ui.spec.js b/web/regression/javascript/schema_ui_files/resource_group.ui.spec.js
index 8f4aca0d7..03d971f64 100644
--- a/web/regression/javascript/schema_ui_files/resource_group.ui.spec.js
+++ b/web/regression/javascript/schema_ui_files/resource_group.ui.spec.js
@@ -54,6 +54,7 @@ describe('ResourceGroupSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -73,6 +74,7 @@ describe('ResourceGroupSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
diff --git a/web/regression/javascript/schema_ui_files/schema.ui.spec.js b/web/regression/javascript/schema_ui_files/schema.ui.spec.js
new file mode 100644
index 000000000..e2cad3a9f
--- /dev/null
+++ b/web/regression/javascript/schema_ui_files/schema.ui.spec.js
@@ -0,0 +1,114 @@
+/////////////////////////////////////////////////////////////
+//
+// pgAdmin 4 - PostgreSQL Tools
+//
+// Copyright (C) 2013 - 2021, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////
+
+import jasmineEnzyme from 'jasmine-enzyme';
+import React from 'react';
+import '../helper/enzyme.helper';
+import { createMount } from '@material-ui/core/test-utils';
+import pgAdmin from 'sources/pgadmin';
+import {messages} from '../fake_messages';
+import SchemaView from '../../../pgadmin/static/js/SchemaView';
+import {getNodePrivilegeRoleSchema} from '../../../pgadmin/browser/server_groups/servers/static/js/privilege.ui';
+import PGSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema.ui';
+
+
+describe('PGSchema', ()=>{
+ let mount;
+ let schemaObj = new PGSchema(
+ ()=>getNodePrivilegeRoleSchema({}, {server: {user: {name: 'postgres'}}}, {}),
+ {
+ roles:() => [],
+ namespaceowner: '',
+ }
+ );
+ let getInitData = ()=>Promise.resolve({});
+
+ /* Use createMount so that material ui components gets the required context */
+ /* https://material-ui.com/guides/testing/#api */
+ beforeAll(()=>{
+ mount = createMount();
+ });
+
+ afterAll(() => {
+ mount.cleanUp();
+ });
+
+ beforeEach(()=>{
+ jasmineEnzyme();
+ /* messages used by validators */
+ pgAdmin.Browser = pgAdmin.Browser || {};
+ pgAdmin.Browser.messages = pgAdmin.Browser.messages || messages;
+ pgAdmin.Browser.utils = pgAdmin.Browser.utils || {};
+ });
+
+ it('create', ()=>{
+ mount({}}
+ onClose={()=>{}}
+ onHelp={()=>{}}
+ onEdit={()=>{}}
+ onDataChange={()=>{}}
+ confirmOnCloseReset={false}
+ hasSQL={false}
+ disableSqlHelp={false}
+ disableDialogHelp={false}
+ />);
+ });
+
+ it('schema validate', () => {
+ let state = { name: 'abc' };
+ let setError = jasmine.createSpy('setError');
+
+ schemaObj.validate(state, setError);
+ expect(setError).toHaveBeenCalledWith('namespaceowner', 'Owner cannot be empty.');
+
+ state.namespaceowner = 'postgres';
+ let validate = schemaObj.validate(state, setError);
+ expect(validate).toBe(null);
+ });
+
+ it('edit', ()=>{
+ mount({}}
+ onClose={()=>{}}
+ onHelp={()=>{}}
+ onEdit={()=>{}}
+ onDataChange={()=>{}}
+ confirmOnCloseReset={false}
+ hasSQL={false}
+ disableSqlHelp={false}
+ disableDialogHelp={false}
+ />);
+ });
+
+ it('properties', ()=>{
+ mount({}}
+ onEdit={()=>{}}
+ />);
+ });
+});
+
diff --git a/web/regression/javascript/schema_ui_files/sequence.ui.spec.js b/web/regression/javascript/schema_ui_files/sequence.ui.spec.js
index e60ab5112..a01388130 100644
--- a/web/regression/javascript/schema_ui_files/sequence.ui.spec.js
+++ b/web/regression/javascript/schema_ui_files/sequence.ui.spec.js
@@ -70,6 +70,7 @@ describe('SequenceSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -89,6 +90,7 @@ describe('SequenceSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
diff --git a/web/regression/javascript/schema_ui_files/server.ui.spec.js b/web/regression/javascript/schema_ui_files/server.ui.spec.js
index cf676da50..b81343ba5 100644
--- a/web/regression/javascript/schema_ui_files/server.ui.spec.js
+++ b/web/regression/javascript/schema_ui_files/server.ui.spec.js
@@ -59,6 +59,7 @@ describe('ServerSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -78,6 +79,7 @@ describe('ServerSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
diff --git a/web/regression/javascript/schema_ui_files/server_group.ui.spec.js b/web/regression/javascript/schema_ui_files/server_group.ui.spec.js
index b30b031f2..0988a8d1b 100644
--- a/web/regression/javascript/schema_ui_files/server_group.ui.spec.js
+++ b/web/regression/javascript/schema_ui_files/server_group.ui.spec.js
@@ -53,6 +53,7 @@ describe('ServerGroupSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -72,6 +73,7 @@ describe('ServerGroupSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
diff --git a/web/regression/javascript/schema_ui_files/synonym.ui.spec.js b/web/regression/javascript/schema_ui_files/synonym.ui.spec.js
index e54c7ee2a..ecccd65c9 100644
--- a/web/regression/javascript/schema_ui_files/synonym.ui.spec.js
+++ b/web/regression/javascript/schema_ui_files/synonym.ui.spec.js
@@ -67,6 +67,7 @@ describe('SynonymSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -86,6 +87,7 @@ describe('SynonymSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
diff --git a/web/regression/javascript/schema_ui_files/tablespace.ui.spec.js b/web/regression/javascript/schema_ui_files/tablespace.ui.spec.js
index c9f1cda31..7ba92d432 100644
--- a/web/regression/javascript/schema_ui_files/tablespace.ui.spec.js
+++ b/web/regression/javascript/schema_ui_files/tablespace.ui.spec.js
@@ -70,6 +70,7 @@ describe('TablespaceSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -89,6 +90,7 @@ describe('TablespaceSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
diff --git a/web/regression/javascript/schema_ui_files/type.ui.spec.js b/web/regression/javascript/schema_ui_files/type.ui.spec.js
index 88c42ca81..33998f09a 100644
--- a/web/regression/javascript/schema_ui_files/type.ui.spec.js
+++ b/web/regression/javascript/schema_ui_files/type.ui.spec.js
@@ -73,6 +73,7 @@ describe('TypeSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
mount({
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -180,6 +182,7 @@ describe('TypeSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
mount({
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
});
@@ -225,6 +229,7 @@ describe('TypeSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
mount({
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -285,6 +291,7 @@ describe('TypeSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
mount({
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -337,6 +345,7 @@ describe('TypeSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
mount({
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -420,6 +430,7 @@ describe('TypeSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -439,6 +450,7 @@ describe('TypeSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
diff --git a/web/regression/javascript/schema_ui_files/user_mapping.ui.spec.js b/web/regression/javascript/schema_ui_files/user_mapping.ui.spec.js
index 8046a395b..788850485 100644
--- a/web/regression/javascript/schema_ui_files/user_mapping.ui.spec.js
+++ b/web/regression/javascript/schema_ui_files/user_mapping.ui.spec.js
@@ -69,6 +69,7 @@ describe('UserMappingSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -88,6 +89,7 @@ describe('UserMappingSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
diff --git a/web/regression/javascript/schema_ui_files/variable.ui.spec.js b/web/regression/javascript/schema_ui_files/variable.ui.spec.js
index d1a11b0c2..b20db851a 100644
--- a/web/regression/javascript/schema_ui_files/variable.ui.spec.js
+++ b/web/regression/javascript/schema_ui_files/variable.ui.spec.js
@@ -82,6 +82,7 @@ describe('VariableSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -101,6 +102,7 @@ describe('VariableSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -146,6 +148,7 @@ describe('VariableSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
/* Make sure you hit every corner */
ctrl.find('DataGridView').at(0).find('PgIconButton[data-test="add-row"]').find('button').simulate('click');
diff --git a/web/regression/javascript/schema_ui_files/view.ui.spec.js b/web/regression/javascript/schema_ui_files/view.ui.spec.js
index 244a55390..dbaa4673b 100644
--- a/web/regression/javascript/schema_ui_files/view.ui.spec.js
+++ b/web/regression/javascript/schema_ui_files/view.ui.spec.js
@@ -73,6 +73,7 @@ describe('ViewSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});
@@ -92,6 +93,7 @@ describe('ViewSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
+ disableDialogHelp={false}
/>);
});