mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-10 08:04:36 -06:00
Stability and bug fixes for the react schema view framework.
This commit is contained in:
parent
74cec6594e
commit
f7b8969c72
@ -161,12 +161,12 @@ 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(
|
||||
this.nodeInfo['table'] || this.nodeInfo['view'] ||
|
||||
this.nodeInfo['mview']
|
||||
return obj.top?.nodeInfo && _.isUndefined(
|
||||
obj.top.nodeInfo['table'] || obj.top.nodeInfo['view'] ||
|
||||
obj.top?.nodeInfo['mview']
|
||||
);
|
||||
},
|
||||
disabled: (state)=>{
|
||||
readonly: (state)=>{
|
||||
// Disable it, when one of this:
|
||||
// - Primary key already exist
|
||||
// - Table is a partitioned table
|
||||
@ -208,9 +208,10 @@ export default class ColumnSchema extends BaseUISchema {
|
||||
|
||||
// If table is partitioned table then disable
|
||||
if(
|
||||
'is_partitioned' in obj.top.origData
|
||||
obj.top && (
|
||||
'is_partitioned' in obj.top.origData
|
||||
&& obj.top.origData['is_partitioned']
|
||||
&& obj.getServerVersion() < 11000
|
||||
&& obj.getServerVersion() < 11000)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
@ -384,7 +385,7 @@ export default class ColumnSchema extends BaseUISchema {
|
||||
type: 'switch', minWidth: 80,
|
||||
group: gettext('Constraints'), editable: this.editableCheckForTable,
|
||||
deps: ['colconstype'],
|
||||
disabled: (state) => {
|
||||
readonly: (state) => {
|
||||
return obj.inSchemaWithColumnCheck(state);
|
||||
}, depChange:(state)=>{
|
||||
if (state.colconstype == 'i') {
|
||||
|
@ -158,7 +158,7 @@ export default class VacuumSettingsSchema extends BaseUISchema {
|
||||
type: 'collection',
|
||||
fixedRows: this.toastTableVars,
|
||||
editable: function(state) {
|
||||
return state.isNew();
|
||||
return obj.isNew(state);
|
||||
},
|
||||
canEdit: false, canAdd: false, canDelete: false, group: gettext('TOAST table'),
|
||||
schema: this.vacuumToastTableObj,
|
||||
|
@ -24,7 +24,7 @@ import _ from 'lodash';
|
||||
|
||||
import gettext from 'sources/gettext';
|
||||
import { SCHEMA_STATE_ACTIONS, StateUtilsContext } from '.';
|
||||
import FormView from './FormView';
|
||||
import FormView, { getFieldMetaData } from './FormView';
|
||||
import { confirmDeleteRow } from '../helpers/legacyConnector';
|
||||
import CustomPropTypes from 'sources/custom_prop_types';
|
||||
import { evalFunc } from 'sources/utils';
|
||||
@ -81,6 +81,7 @@ const useStyles = makeStyles((theme)=>({
|
||||
overflow: 'hidden',
|
||||
textOverflow: 'ellipsis',
|
||||
whiteSpace: 'nowrap',
|
||||
textAlign: 'center',
|
||||
},
|
||||
tableCellHeader: {
|
||||
fontWeight: theme.typography.fontWeightBold,
|
||||
@ -335,43 +336,21 @@ export default function DataGridView({
|
||||
/* Make sure to take the latest field info from schema */
|
||||
field = _.find(schemaRef.current.fields, (f)=>f.id==field.id) || field;
|
||||
|
||||
let {visible, editable, readonly, ..._field} = field;
|
||||
let {editable} = getFieldMetaData(field, schemaRef.current, row.original || {}, viewHelperProps);
|
||||
|
||||
let verInLimit = (_.isUndefined(viewHelperProps.serverInfo) ? true :
|
||||
((_.isUndefined(field.server_type) ? true :
|
||||
(viewHelperProps.serverInfo.type in field.server_type)) &&
|
||||
(_.isUndefined(field.min_version) ? true :
|
||||
(viewHelperProps.serverInfo.version >= field.min_version)) &&
|
||||
(_.isUndefined(field.max_version) ? true :
|
||||
(viewHelperProps.serverInfo.version <= field.max_version))));
|
||||
let _readonly = viewHelperProps.inCatalog || (viewHelperProps.mode == 'properties');
|
||||
if(!_readonly) {
|
||||
_readonly = evalFunc(schemaRef.current, readonly, row.original || {});
|
||||
}
|
||||
|
||||
visible = _.isUndefined(visible) ? true : visible;
|
||||
let _visible = true;
|
||||
if(visible) {
|
||||
_visible = evalFunc(schemaRef.current, visible, row.original || {});
|
||||
}
|
||||
_visible = _visible && verInLimit;
|
||||
|
||||
editable = _.isUndefined(editable) ? true : editable;
|
||||
editable = evalFunc(schemaRef.current, editable, row.original || {});
|
||||
|
||||
if(_.isUndefined(_field.cell)) {
|
||||
console.error('cell is required ', _field);
|
||||
if(_.isUndefined(field.cell)) {
|
||||
console.error('cell is required ', field);
|
||||
}
|
||||
|
||||
return <MappedCellControl rowIndex={row.index} value={value}
|
||||
row={row.original} {..._field}
|
||||
readonly={_readonly}
|
||||
disabled={!editable}
|
||||
visible={_visible}
|
||||
row={row.original} {...field}
|
||||
readonly={!editable}
|
||||
disabled={false}
|
||||
visible={true}
|
||||
onCellChange={(value)=>{
|
||||
dataDispatch({
|
||||
type: SCHEMA_STATE_ACTIONS.SET_VALUE,
|
||||
path: accessPath.concat([row.index, _field.id]),
|
||||
path: accessPath.concat([row.index, field.id]),
|
||||
value: value,
|
||||
});
|
||||
}}
|
||||
|
@ -81,6 +81,7 @@ export function getFieldMetaData(field, schema, value, viewHelperProps, onlyMode
|
||||
readonly: false,
|
||||
disabled: false,
|
||||
visible: true,
|
||||
editable: true,
|
||||
canAdd: true,
|
||||
canEdit: false,
|
||||
canDelete: true,
|
||||
@ -99,7 +100,7 @@ export function getFieldMetaData(field, schema, value, viewHelperProps, onlyMode
|
||||
return retData;
|
||||
}
|
||||
|
||||
let {visible, disabled, readonly} = field;
|
||||
let {visible, disabled, readonly, editable} = field;
|
||||
|
||||
let verInLimit = (_.isUndefined(viewHelperProps.serverInfo) ? true :
|
||||
((_.isUndefined(field.server_type) ? true :
|
||||
@ -120,6 +121,7 @@ export function getFieldMetaData(field, schema, value, viewHelperProps, onlyMode
|
||||
retData.visible = Boolean(_visible);
|
||||
|
||||
retData.disabled = Boolean(evalFunc(schema, disabled, value));
|
||||
retData.editable = evalFunc(schema, _.isUndefined(editable) ? true : editable, value);
|
||||
|
||||
let {canAdd, canEdit, canDelete, canAddRow } = field;
|
||||
retData.canAdd = _.isUndefined(canAdd) ? retData.canAdd : evalFunc(schema, canAdd, value);
|
||||
|
@ -314,6 +314,7 @@ export const InputText = forwardRef(({
|
||||
};
|
||||
|
||||
let finalValue = (_.isNull(value) || _.isUndefined(value)) ? '' : value;
|
||||
|
||||
if(controlProps?.formatter) {
|
||||
finalValue = controlProps.formatter.fromRaw(finalValue);
|
||||
}
|
||||
@ -350,7 +351,7 @@ InputText.propTypes = {
|
||||
readonly: PropTypes.bool,
|
||||
disabled: PropTypes.bool,
|
||||
maxlength: PropTypes.number,
|
||||
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||||
value: PropTypes.any,
|
||||
onChange: PropTypes.func,
|
||||
controlProps: PropTypes.object,
|
||||
type: PropTypes.string,
|
||||
|
Loading…
Reference in New Issue
Block a user