mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-09 23:15:58 -06:00
- Fix all the jasmine test case failures. - Show default value column in Table->Columns grid. Fixes #4353.
This commit is contained in:
parent
2074534b72
commit
c02705c53c
@ -161,7 +161,7 @@ export default class ColumnSchema extends BaseUISchema {
|
||||
id: 'is_primary_key', label: gettext('Primary key?'),
|
||||
cell: 'switch', type: 'switch', minWidth: 100, deps:['name'],
|
||||
visible: ()=>{
|
||||
return _.isUndefined(
|
||||
return !_.isUndefined(
|
||||
this.nodeInfo['table'] || this.nodeInfo['view'] ||
|
||||
this.nodeInfo['mview']
|
||||
);
|
||||
|
@ -55,7 +55,7 @@ define('pgadmin.node.table', [
|
||||
sqlCreateHelp: 'sql-createtable.html',
|
||||
dialogHelp: url_for('help.static', {'filename': 'table_dialog.html'}),
|
||||
hasScriptTypes: ['create', 'select', 'insert', 'update', 'delete'],
|
||||
width: '650px',
|
||||
width: pgBrowser.stdW.lg + 'px',
|
||||
Init: function() {
|
||||
/* Avoid multiple registration of menus */
|
||||
if (this.initialized)
|
||||
|
@ -568,7 +568,7 @@ export default class TableSchema extends BaseUISchema {
|
||||
canEditRow: this.canEditDeleteRowColumns,
|
||||
canDeleteRow: this.canEditDeleteRowColumns,
|
||||
uniqueCol : ['name'],
|
||||
columns : ['name' , 'cltype', 'attlen', 'attprecision', 'attnotnull', 'is_primary_key'],
|
||||
columns : ['name' , 'cltype', 'attlen', 'attprecision', 'attnotnull', 'is_primary_key', 'defval'],
|
||||
allowMultipleEmptyRow: false,
|
||||
},{
|
||||
// Here we will create tab control for constraints
|
||||
|
@ -38,11 +38,15 @@ const useStyles = makeStyles((theme)=>({
|
||||
},
|
||||
nestedControl: {
|
||||
height: 'unset',
|
||||
},
|
||||
sqlTabInput: {
|
||||
border: 0,
|
||||
}
|
||||
}));
|
||||
|
||||
/* Optional SQL tab */
|
||||
function SQLTab({active, getSQLValue}) {
|
||||
const classes = useStyles();
|
||||
const [sql, setSql] = useState('Loading...');
|
||||
useEffect(()=>{
|
||||
let unmounted = false;
|
||||
@ -63,6 +67,7 @@ function SQLTab({active, getSQLValue}) {
|
||||
readOnly: true,
|
||||
}}
|
||||
readonly={true}
|
||||
className={classes.sqlTabInput}
|
||||
/>;
|
||||
}
|
||||
|
||||
|
@ -743,12 +743,17 @@ function SchemaPropertiesView({
|
||||
const [loaderText, setLoaderText] = useState('');
|
||||
|
||||
useEffect(()=>{
|
||||
let unmounted = false;
|
||||
setLoaderText('Loading...');
|
||||
getInitData().then((data)=>{
|
||||
data = data || {};
|
||||
setOrigData(data || {});
|
||||
setLoaderText('');
|
||||
if(!unmounted) {
|
||||
setOrigData(data || {});
|
||||
setLoaderText('');
|
||||
}
|
||||
});
|
||||
|
||||
return ()=>unmounted=true;
|
||||
}, [getInitData]);
|
||||
|
||||
let fullTabs = [];
|
||||
|
@ -61,6 +61,7 @@ const useStyles = makeStyles((theme) => ({
|
||||
sql: {
|
||||
border: '1px solid ' + theme.otherVars.inputBorderColor,
|
||||
borderRadius: theme.shape.borderRadius,
|
||||
height: '100%',
|
||||
},
|
||||
optionIcon: {
|
||||
...theme.mixins.nodeIcon,
|
||||
@ -138,7 +139,7 @@ FormInput.propTypes = {
|
||||
testcid: PropTypes.any,
|
||||
};
|
||||
|
||||
export function InputSQL({value, options, onChange, readonly, ...props}) {
|
||||
export function InputSQL({value, options, onChange, readonly, className, ...props}) {
|
||||
const classes = useStyles();
|
||||
const editor = useRef();
|
||||
|
||||
@ -157,7 +158,7 @@ export function InputSQL({value, options, onChange, readonly, ...props}) {
|
||||
mode: 'text/x-pgsql',
|
||||
...options,
|
||||
}}
|
||||
className={classes.sql}
|
||||
className={clsx(classes.sql, className)}
|
||||
events={{
|
||||
change: (cm)=>{
|
||||
onChange && onChange(cm.getValue());
|
||||
@ -706,7 +707,9 @@ export function InputSelect({
|
||||
/* Apply filter if any */
|
||||
const filteredOptions = (controlProps.filter && controlProps.filter(finalOptions)) || finalOptions;
|
||||
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 = {
|
||||
isSearchable: !readonly,
|
||||
isClearable: !readonly && (!_.isUndefined(controlProps.allowClear) ? controlProps.allowClear : true),
|
||||
|
@ -137,11 +137,13 @@ export default class SearchObjectsDialogWrapper extends DialogWrapper {
|
||||
}
|
||||
|
||||
setTypes(data, enabled=true) {
|
||||
this.jquery(this.typesSelect).empty().select2({
|
||||
data: data,
|
||||
});
|
||||
if(this.typesSelect) {
|
||||
this.jquery(this.typesSelect).empty().select2({
|
||||
data: data,
|
||||
});
|
||||
|
||||
this.typesSelect.disabled = !enabled;
|
||||
this.typesSelect.disabled = !enabled;
|
||||
}
|
||||
}
|
||||
|
||||
setResultCount(count) {
|
||||
|
@ -241,7 +241,7 @@ describe('ForeignTableColumnSchema', ()=>{
|
||||
server: {user: {name:'postgres', id:0}, server_type: 'pg', version: 90400},
|
||||
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({});
|
||||
|
@ -117,7 +117,7 @@ describe('LanguageSchema', ()=>{
|
||||
let setError = jasmine.createSpy('setError');
|
||||
|
||||
state.lanproc = '';
|
||||
state.isTemplate = true;
|
||||
schemaObj.isTemplate = true;
|
||||
schemaObj.validate(state, setError);
|
||||
expect(setError).toHaveBeenCalledWith('lanproc', 'Handler function cannot be empty.');
|
||||
|
||||
|
@ -14,8 +14,25 @@ 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 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 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', ()=>{
|
||||
let mount;
|
||||
@ -96,10 +113,9 @@ describe('MembershipSchema', ()=>{
|
||||
|
||||
it('MembershipMemberSchema', ()=>{
|
||||
spyOn(nodeAjax, 'getNodeListByName').and.returnValue([]);
|
||||
let memberObj = new getMembershipSchema({}, {server: {user: {name: 'postgres'}}}, {});
|
||||
let ctrl = mount(<SchemaView
|
||||
formType='dialog'
|
||||
schema={memberObj}
|
||||
schema={new SchemaInColl(schemaObj)}
|
||||
viewHelperProps={{
|
||||
mode: 'create',
|
||||
}}
|
||||
|
Loading…
Reference in New Issue
Block a user