mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-11-22 08:46:39 -06:00
- Fix codemirror cursor issue. - Fix foreign table jasmine test cases.
This commit is contained in:
parent
c8026873b4
commit
2a76027cce
@ -51,6 +51,7 @@ export default class ForeignTableSchema extends BaseUISchema {
|
||||
...fieldOptions,
|
||||
};
|
||||
|
||||
this.columnsObj = getNodeColumnSchema(this.fieldOptions.nodeInfo, this.fieldOptions.nodeData, this.fieldOptions.pgBrowser);
|
||||
}
|
||||
|
||||
get idAttribute() {
|
||||
@ -133,7 +134,7 @@ export default class ForeignTableSchema extends BaseUISchema {
|
||||
if(tabColsResponse) {
|
||||
tabColsResponse.then((res)=>{
|
||||
resolve((state)=>{
|
||||
let finalCols = res.map((col)=> col);
|
||||
let finalCols = res.map((col)=>obj.columnsObj.getNewData(col));
|
||||
finalCols = [...state.columns, ...finalCols];
|
||||
return {
|
||||
adding_inherit_cols: false,
|
||||
@ -170,7 +171,7 @@ export default class ForeignTableSchema extends BaseUISchema {
|
||||
{
|
||||
id: 'columns', label: gettext('Columns'), cell: 'text',
|
||||
type: 'collection', group: gettext('Columns'), mode: ['edit', 'create'],
|
||||
schema: new getNodeColumnSchema(obj.fieldOptions.nodeInfo, obj.fieldOptions.nodeData, obj.fieldOptions.pgBrowser),
|
||||
schema: this.columnsObj,
|
||||
canAdd: true, canDelete: true, canEdit: true, columns: ['attname', 'datatype', 'inheritedfrom'],
|
||||
// For each row edit/delete button enable/disable
|
||||
canEditRow: this.canEditDeleteRowColumns,
|
||||
|
@ -42,7 +42,9 @@ export default function CodeMirror({currEditor, name, value, options, events, cl
|
||||
|
||||
useMemo(() => {
|
||||
if(editor.current) {
|
||||
editor.current.setValue(value);
|
||||
if(value != editor.current.getValue()) {
|
||||
editor.current.setValue(value);
|
||||
}
|
||||
}
|
||||
}, [value]);
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
//////////////////////////////////////////////////////////////
|
||||
/* Common form components used in pgAdmin */
|
||||
|
||||
import React, { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import React, { forwardRef, useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import { Box, FormControl, OutlinedInput, FormHelperText,
|
||||
Grid, IconButton, FormControlLabel, Switch, Checkbox, useTheme, InputLabel, Paper } from '@material-ui/core';
|
||||
@ -149,7 +149,7 @@ export function InputSQL({value, options, onChange, readonly, className, ...prop
|
||||
}
|
||||
}, [readonly]);
|
||||
|
||||
return useMemo(()=>(
|
||||
return (
|
||||
<CodeMirror
|
||||
currEditor={(obj)=>editor.current=obj}
|
||||
value={value||''}
|
||||
@ -166,13 +166,14 @@ export function InputSQL({value, options, onChange, readonly, className, ...prop
|
||||
}}
|
||||
{...props}
|
||||
/>
|
||||
), [value]);
|
||||
);
|
||||
}
|
||||
InputSQL.propTypes = {
|
||||
value: PropTypes.string,
|
||||
options: PropTypes.object,
|
||||
onChange: PropTypes.func,
|
||||
readonly: PropTypes.bool
|
||||
readonly: PropTypes.bool,
|
||||
className: CustomPropTypes.className,
|
||||
};
|
||||
|
||||
export function FormInputSQL({hasError, required, label, className, helpMessage, testcid, value, controlProps, noLabel, ...props}) {
|
||||
|
@ -176,13 +176,14 @@ describe('ForeignTableSchema', ()=>{
|
||||
|
||||
it('add first selection', (done)=>{
|
||||
let state = {columns: [], inherits: ['table1']};
|
||||
let newCol = schemaObj.columnsObj.getNewData(inheritCol);
|
||||
let deferredPromise = deferredDepChange(state, null, null, {
|
||||
oldState: {
|
||||
inherits: [],
|
||||
},
|
||||
});
|
||||
deferredPromise.then((depChange)=>{
|
||||
let finalCols = [{name: 'id'}];
|
||||
let finalCols = [newCol];
|
||||
expect(depChange(state)).toEqual({
|
||||
adding_inherit_cols: false,
|
||||
columns: finalCols,
|
||||
|
Loading…
Reference in New Issue
Block a user