mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-27 16:57:00 -06:00
2f37f0ca51
1) Add server mode validation in the binary path. 2) Updated preferences tree rendering to avoid using the ReactDOM render. 3) Updated CSS for keyboard shortcuts checkbox border makes it consistent with input box border. 4) Fixed jasmine test case and improved code coverage. 5) Fixed SonarQube issues. 6) Added validation to disable "Maximum column with" option if "Column sized by" option is set to "Column name" in Query Tool -> Result grid. 7) Updated documentation with the latest screenshots. 8) Correct typo in the documentation. Fixes #7261 refs #7149
134 lines
4.1 KiB
JavaScript
134 lines
4.1 KiB
JavaScript
/////////////////////////////////////////////////////////////
|
|
//
|
|
// pgAdmin 4 - PostgreSQL Tools
|
|
//
|
|
// Copyright (C) 2013 - 2022, The pgAdmin Development Team
|
|
// This software is released under the PostgreSQL Licence
|
|
//
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
import _ from 'lodash';
|
|
import { makeStyles, Grid, Typography, Box } from '@material-ui/core';
|
|
import React from 'react';
|
|
import { InputCheckbox, InputText } from './FormComponents';
|
|
import PropTypes from 'prop-types';
|
|
|
|
const useStyles = makeStyles((theme) => ({
|
|
inputLabel: {
|
|
textAlign: 'center',
|
|
padding: 2,
|
|
paddingLeft: 10
|
|
},
|
|
inputCheckboxClass: {
|
|
border: '1px solid',
|
|
borderRadius: theme.shape.borderRadius,
|
|
borderColor: theme.otherVars.inputBorderColor,
|
|
padding: 3
|
|
}
|
|
}));
|
|
|
|
export default function KeyboardShortcuts({ value, onChange, fields }) {
|
|
const classes = useStyles();
|
|
const keyCid = _.uniqueId('c');
|
|
const keyhelpid = `h${keyCid}`;
|
|
const shiftCid = _.uniqueId('c');
|
|
const shifthelpid = `h${shiftCid}`;
|
|
const ctrlCid = _.uniqueId('c');
|
|
const ctrlhelpid = `h${ctrlCid}`;
|
|
const altCid = _.uniqueId('c');
|
|
const althelpid = `h${altCid}`;
|
|
const keyLabel = _.uniqueId('c');
|
|
|
|
const onKeyDown = (e) => {
|
|
let newVal = { ...value };
|
|
let _val = e.key;
|
|
if (e.keyCode == 32) {
|
|
_val = 'Space';
|
|
}
|
|
newVal.key = {
|
|
char: _val,
|
|
key_code: e.keyCode
|
|
};
|
|
onChange(newVal);
|
|
};
|
|
|
|
const onShiftChange = (e) => {
|
|
let newVal = { ...value };
|
|
newVal.shift = e.target.checked;
|
|
onChange(newVal);
|
|
};
|
|
|
|
const onCtrlChange = (e) => {
|
|
let newVal = { ...value };
|
|
newVal.ctrl = e.target.checked;
|
|
onChange(newVal);
|
|
};
|
|
|
|
const onAltChange = (e) => {
|
|
let newVal = { ...value };
|
|
newVal.alt = e.target.checked;
|
|
onChange(newVal);
|
|
};
|
|
|
|
return (
|
|
<Grid
|
|
container
|
|
direction="row"
|
|
alignItems="center"
|
|
key={_.uniqueId('c')}
|
|
>
|
|
{fields.map(element => {
|
|
let ctrlProps = {
|
|
label: element.label
|
|
};
|
|
if (element.type == 'keyCode') {
|
|
return <Grid item container lg={4} md={4} sm={4} xs={12} key={_.uniqueId('c')}>
|
|
<Grid item lg={4} md={4} sm={4} xs={12} className={classes.inputLabel}>
|
|
<Typography id={keyLabel}>{element.label}</Typography>
|
|
</Grid>
|
|
<Grid item lg={8} md={8} sm={8} xs={12}>
|
|
<InputText id={keyCid} helpid={keyhelpid} type='text' value={value?.key?.char} controlProps={
|
|
{
|
|
onKeyDown: onKeyDown,
|
|
}
|
|
}></InputText>
|
|
</Grid>
|
|
</Grid>;
|
|
} else if (element.name == 'shift') {
|
|
return <Grid item lg={2} md={2} sm={2} xs={12} className={classes.inputLabel} key={_.uniqueId('c')}>
|
|
<Box className={classes.inputCheckboxClass}>
|
|
<InputCheckbox id={shiftCid} helpid={shifthelpid} value={value?.shift}
|
|
controlProps={ctrlProps}
|
|
onChange={onShiftChange}></InputCheckbox>
|
|
</Box>
|
|
</Grid>;
|
|
} else if (element.name == 'control') {
|
|
return <Grid item lg={2} md={2} sm={2} xs={12} className={classes.inputLabel} key={_.uniqueId('c')}>
|
|
<Box className={classes.inputCheckboxClass}>
|
|
<InputCheckbox id={ctrlCid} helpid={ctrlhelpid} value={value?.ctrl}
|
|
controlProps={ctrlProps}
|
|
onChange={onCtrlChange}></InputCheckbox>
|
|
</Box>
|
|
</Grid>;
|
|
} else if (element.name == 'alt') {
|
|
return <Grid item lg={3} md={3} sm={3} xs={12} className={classes.inputLabel} key={_.uniqueId('c')}>
|
|
<Box className={classes.inputCheckboxClass}>
|
|
<InputCheckbox id={altCid} helpid={althelpid} value={value?.alt}
|
|
controlProps={ctrlProps}
|
|
onChange={onAltChange}></InputCheckbox>
|
|
</Box>
|
|
</Grid>;
|
|
}
|
|
|
|
})}
|
|
</Grid>
|
|
);
|
|
}
|
|
|
|
KeyboardShortcuts.propTypes = {
|
|
value: PropTypes.object,
|
|
onChange: PropTypes.func,
|
|
controlProps: PropTypes.object,
|
|
fields: PropTypes.array
|
|
};
|