- Fix all the jasmine test case failures. - Show default value column in Table->Columns grid. Fixes #4353.

This commit is contained in:
Aditya Toshniwal 2021-08-24 13:40:37 +05:30 committed by Akshay Joshi
parent 2074534b72
commit c02705c53c
10 changed files with 48 additions and 17 deletions

View File

@ -161,7 +161,7 @@ export default class ColumnSchema extends BaseUISchema {
id: 'is_primary_key', label: gettext('Primary key?'), id: 'is_primary_key', label: gettext('Primary key?'),
cell: 'switch', type: 'switch', minWidth: 100, deps:['name'], cell: 'switch', type: 'switch', minWidth: 100, deps:['name'],
visible: ()=>{ visible: ()=>{
return _.isUndefined( return !_.isUndefined(
this.nodeInfo['table'] || this.nodeInfo['view'] || this.nodeInfo['table'] || this.nodeInfo['view'] ||
this.nodeInfo['mview'] this.nodeInfo['mview']
); );

View File

@ -55,7 +55,7 @@ define('pgadmin.node.table', [
sqlCreateHelp: 'sql-createtable.html', sqlCreateHelp: 'sql-createtable.html',
dialogHelp: url_for('help.static', {'filename': 'table_dialog.html'}), dialogHelp: url_for('help.static', {'filename': 'table_dialog.html'}),
hasScriptTypes: ['create', 'select', 'insert', 'update', 'delete'], hasScriptTypes: ['create', 'select', 'insert', 'update', 'delete'],
width: '650px', width: pgBrowser.stdW.lg + 'px',
Init: function() { Init: function() {
/* Avoid multiple registration of menus */ /* Avoid multiple registration of menus */
if (this.initialized) if (this.initialized)

View File

@ -568,7 +568,7 @@ export default class TableSchema extends BaseUISchema {
canEditRow: this.canEditDeleteRowColumns, canEditRow: this.canEditDeleteRowColumns,
canDeleteRow: this.canEditDeleteRowColumns, canDeleteRow: this.canEditDeleteRowColumns,
uniqueCol : ['name'], uniqueCol : ['name'],
columns : ['name' , 'cltype', 'attlen', 'attprecision', 'attnotnull', 'is_primary_key'], columns : ['name' , 'cltype', 'attlen', 'attprecision', 'attnotnull', 'is_primary_key', 'defval'],
allowMultipleEmptyRow: false, allowMultipleEmptyRow: false,
},{ },{
// Here we will create tab control for constraints // Here we will create tab control for constraints

View File

@ -38,11 +38,15 @@ const useStyles = makeStyles((theme)=>({
}, },
nestedControl: { nestedControl: {
height: 'unset', height: 'unset',
},
sqlTabInput: {
border: 0,
} }
})); }));
/* Optional SQL tab */ /* Optional SQL tab */
function SQLTab({active, getSQLValue}) { function SQLTab({active, getSQLValue}) {
const classes = useStyles();
const [sql, setSql] = useState('Loading...'); const [sql, setSql] = useState('Loading...');
useEffect(()=>{ useEffect(()=>{
let unmounted = false; let unmounted = false;
@ -63,6 +67,7 @@ function SQLTab({active, getSQLValue}) {
readOnly: true, readOnly: true,
}} }}
readonly={true} readonly={true}
className={classes.sqlTabInput}
/>; />;
} }

View File

@ -743,12 +743,17 @@ function SchemaPropertiesView({
const [loaderText, setLoaderText] = useState(''); const [loaderText, setLoaderText] = useState('');
useEffect(()=>{ useEffect(()=>{
let unmounted = false;
setLoaderText('Loading...'); setLoaderText('Loading...');
getInitData().then((data)=>{ getInitData().then((data)=>{
data = data || {}; data = data || {};
setOrigData(data || {}); if(!unmounted) {
setLoaderText(''); setOrigData(data || {});
setLoaderText('');
}
}); });
return ()=>unmounted=true;
}, [getInitData]); }, [getInitData]);
let fullTabs = []; let fullTabs = [];

View File

@ -61,6 +61,7 @@ const useStyles = makeStyles((theme) => ({
sql: { sql: {
border: '1px solid ' + theme.otherVars.inputBorderColor, border: '1px solid ' + theme.otherVars.inputBorderColor,
borderRadius: theme.shape.borderRadius, borderRadius: theme.shape.borderRadius,
height: '100%',
}, },
optionIcon: { optionIcon: {
...theme.mixins.nodeIcon, ...theme.mixins.nodeIcon,
@ -138,7 +139,7 @@ FormInput.propTypes = {
testcid: PropTypes.any, testcid: PropTypes.any,
}; };
export function InputSQL({value, options, onChange, readonly, ...props}) { export function InputSQL({value, options, onChange, readonly, className, ...props}) {
const classes = useStyles(); const classes = useStyles();
const editor = useRef(); const editor = useRef();
@ -157,7 +158,7 @@ export function InputSQL({value, options, onChange, readonly, ...props}) {
mode: 'text/x-pgsql', mode: 'text/x-pgsql',
...options, ...options,
}} }}
className={classes.sql} className={clsx(classes.sql, className)}
events={{ events={{
change: (cm)=>{ change: (cm)=>{
onChange && onChange(cm.getValue()); onChange && onChange(cm.getValue());
@ -706,7 +707,9 @@ export function InputSelect({
/* Apply filter if any */ /* Apply filter if any */
const filteredOptions = (controlProps.filter && controlProps.filter(finalOptions)) || finalOptions; const filteredOptions = (controlProps.filter && controlProps.filter(finalOptions)) || finalOptions;
let realValue = getRealValue(filteredOptions, value, controlProps.creatable, controlProps.formatter); let realValue = getRealValue(filteredOptions, value, controlProps.creatable, controlProps.formatter);
realValue = _.isNull(realValue) ? '' : realValue; if(realValue && _.isPlainObject(realValue) && _.isUndefined(realValue.value)) {
console.error('Undefined option value not allowed', realValue, filteredOptions);
}
const otherProps = { const otherProps = {
isSearchable: !readonly, isSearchable: !readonly,
isClearable: !readonly && (!_.isUndefined(controlProps.allowClear) ? controlProps.allowClear : true), isClearable: !readonly && (!_.isUndefined(controlProps.allowClear) ? controlProps.allowClear : true),

View File

@ -137,11 +137,13 @@ export default class SearchObjectsDialogWrapper extends DialogWrapper {
} }
setTypes(data, enabled=true) { setTypes(data, enabled=true) {
this.jquery(this.typesSelect).empty().select2({ if(this.typesSelect) {
data: data, this.jquery(this.typesSelect).empty().select2({
}); data: data,
});
this.typesSelect.disabled = !enabled; this.typesSelect.disabled = !enabled;
}
} }
setResultCount(count) { setResultCount(count) {

View File

@ -241,7 +241,7 @@ describe('ForeignTableColumnSchema', ()=>{
server: {user: {name:'postgres', id:0}, server_type: 'pg', version: 90400}, server: {user: {name:'postgres', id:0}, server_type: 'pg', version: 90400},
table: {} table: {}
}, },
[{is_collatable: false, label: '"char"', length: true, max_val: 0, min_val: 0, precision: true, typval: ' '}], [{is_collatable: false, label: '"char"', value: '"char"', length: true, max_val: 0, min_val: 0, precision: true, typval: ' '}],
()=>[], ()=>[],
); );
let getInitData = ()=>Promise.resolve({}); let getInitData = ()=>Promise.resolve({});

View File

@ -117,7 +117,7 @@ describe('LanguageSchema', ()=>{
let setError = jasmine.createSpy('setError'); let setError = jasmine.createSpy('setError');
state.lanproc = ''; state.lanproc = '';
state.isTemplate = true; schemaObj.isTemplate = true;
schemaObj.validate(state, setError); schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('lanproc', 'Handler function cannot be empty.'); expect(setError).toHaveBeenCalledWith('lanproc', 'Handler function cannot be empty.');

View File

@ -14,8 +14,25 @@ import { createMount } from '@material-ui/core/test-utils';
import pgAdmin from 'sources/pgadmin'; import pgAdmin from 'sources/pgadmin';
import {messages} from '../fake_messages'; import {messages} from '../fake_messages';
import SchemaView from '../../../pgadmin/static/js/SchemaView'; import SchemaView from '../../../pgadmin/static/js/SchemaView';
import MembershipSchema, {getMembershipSchema} from '../../../pgadmin/browser/server_groups/servers/static/js/membership.ui'; import MembershipSchema from '../../../pgadmin/browser/server_groups/servers/static/js/membership.ui';
import * as nodeAjax from '../../../pgadmin/browser/static/js/node_ajax'; import * as nodeAjax from '../../../pgadmin/browser/static/js/node_ajax';
import BaseUISchema from '../../../pgadmin/static/js/SchemaView/base_schema.ui';
class SchemaInColl extends BaseUISchema {
constructor(schemaObj) {
super();
this.schemaObj = schemaObj;
}
get baseFields() {
return [{
id: 'collection', label: '', type: 'collection',
schema: this.schemaObj,
editable: false,
canAdd: true, canEdit: false, canDelete: true, hasRole: true,
}];
}
}
describe('MembershipSchema', ()=>{ describe('MembershipSchema', ()=>{
let mount; let mount;
@ -96,10 +113,9 @@ describe('MembershipSchema', ()=>{
it('MembershipMemberSchema', ()=>{ it('MembershipMemberSchema', ()=>{
spyOn(nodeAjax, 'getNodeListByName').and.returnValue([]); spyOn(nodeAjax, 'getNodeListByName').and.returnValue([]);
let memberObj = new getMembershipSchema({}, {server: {user: {name: 'postgres'}}}, {});
let ctrl = mount(<SchemaView let ctrl = mount(<SchemaView
formType='dialog' formType='dialog'
schema={memberObj} schema={new SchemaInColl(schemaObj)}
viewHelperProps={{ viewHelperProps={{
mode: 'create', mode: 'create',
}} }}