Fixed issues in the Preferences:

1) Show a single note in the binary path.
  2) Resolved issue in the keyboard shortcut.

refs #7149
This commit is contained in:
Nikhil Mohite 2022-03-29 16:27:33 +05:30 committed by Akshay Joshi
parent 02e799c917
commit 931a399890
3 changed files with 13 additions and 9 deletions

View File

@ -233,6 +233,7 @@ export default function PreferencesComponent({ ...props }) {
});
}, []);
function setPreferences(node, subNode, nodeData, preferencesValues, preferencesData) {
let addBinaryPathNote = false;
subNode.preferences.forEach((element) => {
let note = '';
let type = getControlMappedForType(element.type);
@ -247,8 +248,11 @@ export default function PreferencesComponent({ ...props }) {
element.editable = false;
element.disabled = true;
preferencesValues[element.id] = JSON.parse(element.value);
if(addBinaryPathNote) {
addNote(node, subNode, nodeData, preferencesData, note);
}
addBinaryPathNote = true;
}
else if (type == 'select') {
setControlProps(element);
element.type = type;

View File

@ -60,7 +60,7 @@ export default function KeyboardShortcuts({ value, onChange, fields }) {
const onCtrlChange = (e) => {
let newVal = { ...value };
newVal.ctrl = e.target.checked;
newVal.control = e.target.checked;
onChange(newVal);
};
@ -105,7 +105,7 @@ export default function KeyboardShortcuts({ value, onChange, fields }) {
} 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}
<InputCheckbox id={ctrlCid} helpid={ctrlhelpid} value={value?.control}
controlProps={ctrlProps}
onChange={onCtrlChange}></InputCheckbox>
</Box>

View File

@ -22,7 +22,7 @@ import { InputCheckbox } from '../../../pgadmin/static/js/components/FormCompone
describe('KeyboardShortcuts', () => {
let mount;
let defult_value = {
'ctrl': true,
'control': true,
'alt': true,
'key': {
'char': 'a',
@ -85,26 +85,26 @@ describe('KeyboardShortcuts', () => {
it('Key change', (done) => {
ctrl.find(OutlinedInput).at(0).find('input').simulate('keydown', { key: '', keyCode: 32});
expect(onChange).toHaveBeenCalledWith({ ctrl: true, alt: true, key: { char: 'Space', key_code: 32 }, shift: false });
expect(onChange).toHaveBeenCalledWith({ control: true, alt: true, key: { char: 'Space', key_code: 32 }, shift: false });
done();
});
it('Shift option', (done) => {
ctrl.find(InputCheckbox).at(0).find('input').simulate('change', { target: { checked: true, name: 'shift' } });
expect(onChange).toHaveBeenCalledWith({ ctrl: true, alt: true, key: { char: 'a', key_code: 97 }, shift: true });
expect(onChange).toHaveBeenCalledWith({ control: true, alt: true, key: { char: 'a', key_code: 97 }, shift: true });
done();
});
it('Ctrl option', (done) => {
it('Control option', (done) => {
ctrl.find(InputCheckbox).at(1).find('input').simulate('change', { target: { checked: false, name: 'ctrl' } });
expect(onChange).toHaveBeenCalledWith({ ctrl: false, alt: true, key: { char: 'a', key_code: 97 }, shift: false });
expect(onChange).toHaveBeenCalledWith({ control: false, alt: true, key: { char: 'a', key_code: 97 }, shift: false });
done();
});
it('Alt option', (done) => {
ctrl.find(InputCheckbox).at(2).find('input').simulate('change', { target: { checked: false, name: 'alt' } });
expect(onChange).toHaveBeenCalledWith({ ctrl: true, alt: false, key: { char: 'a', key_code: 97 }, shift: false });
expect(onChange).toHaveBeenCalledWith({ control: true, alt: false, key: { char: 'a', key_code: 97 }, shift: false });
done();
});