Skip to content

Commit

Permalink
[keypress] replaced 'onKeyPress' with 'onKeyDown' as 'keypress' is de… (
Browse files Browse the repository at this point in the history
#5764)

* [keypress] replaced 'onKeyPress' with 'onKeyDown' as 'keypress' is deprecated

* cleaned up code
  • Loading branch information
llj authored Nov 14, 2023
1 parent c686288 commit a4e2e4a
Show file tree
Hide file tree
Showing 32 changed files with 60 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CreateDepartmentRepoDialog extends React.Component {
}
};

handleKeyPress = (e) => {
handleKeyDown = (e) => {
if (e.key === 'Enter') {
this.handleSubmit();
e.preventDefault();
Expand Down Expand Up @@ -81,7 +81,7 @@ class CreateDepartmentRepoDialog extends React.Component {
<Label for="repo-name">{gettext('Name')}</Label>
<Input
id="repo-name"
onKeyPress={this.handleKeyPress}
onKeyDown={this.handleKeyDown}
value={this.state.repoName}
onChange={this.handleChange}
maxLength={maxFileName}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/dialog/create-file-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class CreateFile extends React.Component {
}
};

handleKeyPress = (e) => {
handleKeyDown = (e) => {
if (e.key === 'Enter') {
this.handleSubmit();
e.preventDefault();
Expand Down Expand Up @@ -151,7 +151,7 @@ class CreateFile extends React.Component {
<Label for="fileName">{gettext('Name')}</Label>
<Input
id="fileName"
onKeyPress={this.handleKeyPress}
onKeyDown={this.handleKeyDown}
innerRef={this.newInput}
value={this.state.childName}
onChange={this.handleChange}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/dialog/create-folder-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class CreateForder extends React.Component {
}
};

handleKeyPress = (e) => {
handleKeyDown = (e) => {
if (e.key === 'Enter') {
this.handleSubmit();
e.preventDefault();
Expand All @@ -87,7 +87,7 @@ class CreateForder extends React.Component {
<Input
id="folderName"
value={this.state.childName}
onKeyPress={this.handleKeyPress}
onKeyDown={this.handleKeyDown}
onChange={this.handleChange}
autoFocus={true}
/>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/dialog/create-repo-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class CreateRepoDialog extends React.Component {
}
};

handleKeyPress = (e) => {
handleKeyDown = (e) => {
if (e.key === 'Enter') {
this.handleSubmit();
e.preventDefault();
Expand Down Expand Up @@ -180,7 +180,7 @@ class CreateRepoDialog extends React.Component {
<Label for="repoName">{gettext('Name')}</Label>
<Input
id="repoName"
onKeyPress={this.handleKeyPress}
onKeyDown={this.handleKeyDown}
value={this.state.repoName}
onChange={this.handleRepoNameChange}
autoFocus={true}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/dialog/create-tag-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class CreateTagDialog extends React.Component {
});
};

handleKeyPress = (e) => {
handleKeyDown = (e) => {
if (e.key === 'Enter') {
this.createTag();
}
Expand All @@ -77,7 +77,7 @@ class CreateTagDialog extends React.Component {
<div role="form" className="tag-create">
<div className="form-group">
<label className="form-label">{gettext('Name')}</label>
<Input onKeyPress={this.handleKeyPress} autoFocus={true} value={this.state.tagName} onChange={this.inputNewName}/>
<Input onKeyDown={this.handleKeyDown} autoFocus={true} value={this.state.tagName} onChange={this.inputNewName}/>
<div className="mt-2"><span className="error">{this.state.errorMsg}</span></div>
</div>
<div className="form-group">
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/dialog/lib-decrypt-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class LibDecryptDialog extends React.Component {
e.preventDefault();
};

handleKeyPress = (e) => {
handleKeyDown = (e) => {
if (e.key == 'Enter') {
this.handleSubmit(e);
}
Expand Down Expand Up @@ -63,7 +63,7 @@ class LibDecryptDialog extends React.Component {
{this.state.showError &&
<p className="error">{gettext('Wrong password')}</p>
}
<input type="password" name="password" className="form-control password-input" autoComplete="off" onKeyPress={this.handleKeyPress} placeholder={gettext('Password')} onChange={this.handleChange} />
<input type="password" name="password" className="form-control password-input" autoComplete="off" onKeyDown={this.handleKeyDown} placeholder={gettext('Password')} onChange={this.handleChange} />
<button type="submit" className="btn btn-primary submit" onClick={this.handleSubmit}>{gettext('Submit')}</button>
<p className="tip">{'* '}{gettext('The password will be kept in the server for only 1 hour.')}</p>
</Form>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/dialog/lib-history-setting-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class LibHistorySetting extends React.Component {
}
};

handleKeyPress = (e) => {
handleKeyDown = (e) => {
if (e.key === 'Enter') {
this.submit();
e.preventDefault();
Expand Down Expand Up @@ -139,7 +139,7 @@ class LibHistorySetting extends React.Component {
value={this.state.expireDays}
onChange={this.onChange}
disabled={this.state.disabled}
onKeyDown={this.handleKeyPress}
onKeyDown={this.handleKeyDown}
/>{' '}
<Label><span>{gettext('days')}</span></Label>
</FormGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class LibOldFilesAutoDelDialog extends React.Component {
});
};

handleKeyPress = (e) => {
handleKeyDown = (e) => {
if (e.key === 'Enter') {
this.submit();
e.preventDefault();
Expand Down Expand Up @@ -112,7 +112,7 @@ class LibOldFilesAutoDelDialog extends React.Component {
value={this.state.autoDelDays}
disabled={!this.state.isAutoDel}
onChange={this.onChange}
onKeyDown={this.handleKeyPress}
onKeyDown={this.handleKeyDown}
/>{' '}
<Label><span>{gettext('days')}</span></Label>
</FormGroup>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/dialog/new-wiki-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class NewWikiDialog extends React.Component {
});
};

handleKeyPress = (e) => {
handleKeyDown = (e) => {
if (e.key === 'Enter') {
this.handleSubmit();
}
Expand All @@ -54,7 +54,7 @@ class NewWikiDialog extends React.Component {
<ModalHeader toggle={this.toggle}>{gettext('New Wiki')}</ModalHeader>
<ModalBody>
<label className="form-label">{gettext('Name')}</label>
<Input onKeyPress={this.handleKeyPress} autoFocus={true} value={this.state.name} onChange={this.inputNewName}/>
<Input onKeyDown={this.handleKeyDown} autoFocus={true} value={this.state.name} onChange={this.inputNewName}/>
</ModalBody>
<ModalFooter>
<Button color="secondary" onClick={this.toggle}>{gettext('Cancel')}</Button>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/dialog/org-add-department-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class AddDepartDialog extends React.Component {
});
};

handleKeyPress = (e) => {
handleKeyDown = (e) => {
if (e.key === 'Enter') {
this.handleSubmit();
e.preventDefault();
Expand All @@ -73,7 +73,7 @@ class AddDepartDialog extends React.Component {
<Label for="departName">{gettext('Name')}</Label>
<Input
id="departName"
onKeyPress={this.handleKeyPress}
onKeyDown={this.handleKeyDown}
value={this.state.departName}
onChange={this.handleChange}
autoFocus={true}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/dialog/org-add-repo-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class AddRepoDialog extends React.Component {
});
};

handleKeyPress = (e) => {
handleKeyDown = (e) => {
if (e.key === 'Enter') {
this.handleSubmit();
e.preventDefault();
Expand All @@ -68,7 +68,7 @@ class AddRepoDialog extends React.Component {
<Label for="repoName">{gettext('Name')}</Label>
<Input
id="repoName"
onKeyPress={this.handleKeyPress}
onKeyDown={this.handleKeyDown}
value={this.state.repoName}
onChange={this.handleChange}
autoFocus={true}
Expand Down
7 changes: 0 additions & 7 deletions frontend/src/components/dialog/org-add-user-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ class AddOrgUserDialog extends React.Component {
}
};

handleKeyPress = (e) => {
e.preventDefault();
if (e.key == 'Enter') {
this.handleSubmit(e);
}
};

togglePasswordVisible = () => {
this.setState({isPasswordVisible: !this.state.isPasswordVisible}, () => {
if (this.state.isPasswordVisible) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class RenameDepartmentDialog extends React.Component {
});
};

handleKeyPress = (e) => {
handleKeyDown = (e) => {
if (e.key === 'Enter') {
this.handleSubmit();
e.preventDefault();
Expand All @@ -87,7 +87,7 @@ class RenameDepartmentDialog extends React.Component {
<Label for="departmentName">{gettext('Name')}</Label>
<Input
id="departmentName"
onKeyPress={this.handleKeyPress}
onKeyDown={this.handleKeyDown}
value={this.state.departmentName}
onChange={this.handleChange}
innerRef={this.newInput}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/dialog/org-set-group-quota-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class SetGroupQuotaDialog extends React.Component {
this.setState({ quota: quota });
};

handleKeyPress = (e) => {
handleKeyDown = (e) => {
if (e.key === 'Enter') {
this.setGroupQuota();
e.preventDefault();
Expand All @@ -60,7 +60,7 @@ class SetGroupQuotaDialog extends React.Component {
<ModalBody>
<InputGroup>
<Input
onKeyPress={this.handleKeyPress}
onKeyDown={this.handleKeyDown}
value={this.state.quota}
onChange={this.handleChange}
autoFocus={true}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/dialog/rename-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Rename extends React.Component {
}
};

handleKeyPress = (e) => {
handleKeyDown = (e) => {
if (e.key === 'Enter') {
this.handleSubmit();
}
Expand Down Expand Up @@ -121,7 +121,7 @@ class Rename extends React.Component {
<ModalHeader toggle={this.toggle}>{type === 'file' ? gettext('Rename File') : gettext('Rename Folder') }</ModalHeader>
<ModalBody>
<p>{type === 'file' ? gettext('New file name'): gettext('New folder name')}</p>
<Input onKeyPress={this.handleKeyPress} innerRef={this.newInput} placeholder="newName" value={this.state.newName} onChange={this.handleChange} />
<Input onKeyDown={this.handleKeyDown} innerRef={this.newInput} placeholder="newName" value={this.state.newName} onChange={this.handleChange} />
{this.state.errMessage && <Alert color="danger" className="mt-2">{this.state.errMessage}</Alert>}
</ModalBody>
<ModalFooter>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/dialog/rename-dirent.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Rename extends React.Component {
}
};

handleKeyPress = (e) => {
handleKeyDown = (e) => {
if (e.key === 'Enter') {
this.handleSubmit();
}
Expand Down Expand Up @@ -123,7 +123,7 @@ class Rename extends React.Component {
<ModalHeader toggle={this.toggle}>{type === 'file' ? gettext('Rename File') : gettext('Rename Folder') }</ModalHeader>
<ModalBody>
<p>{type === 'file' ? gettext('New file name'): gettext('New folder name')}</p>
<Input onKeyPress={this.handleKeyPress} innerRef={this.newInput} value={this.state.newName} onChange={this.handleChange} />
<Input onKeyDown={this.handleKeyDown} innerRef={this.newInput} value={this.state.newName} onChange={this.handleChange} />
{this.state.errMessage && <Alert color="danger" className="mt-2">{this.state.errMessage}</Alert>}
</ModalBody>
<ModalFooter>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/dialog/sysadmin-dialog/set-quota.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SetQuotaDialog extends React.Component {
});
};

handleKeyPress = (e) => {
handleKeyDown = (e) => {
if (e.key == 'Enter') {
this.handleSubmit();
e.preventDefault();
Expand All @@ -55,7 +55,7 @@ class SetQuotaDialog extends React.Component {
type="text"
className="form-control"
value={quota}
onKeyPress={this.handleKeyPress}
onKeyDown={this.handleKeyDown}
onChange={this.handleQuotaChange}
/>
<InputGroupAddon addonType="append">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SysAdminSetUploadDownloadRateLimitDialog extends React.Component {
});
};

handleKeyPress = (e) => {
handleKeyDown = (e) => {
if (e.key == 'Enter') {
this.handleSubmit();
e.preventDefault();
Expand All @@ -56,7 +56,7 @@ class SysAdminSetUploadDownloadRateLimitDialog extends React.Component {
type="text"
className="form-control"
value={rateLimit}
onKeyPress={this.handleKeyPress}
onKeyDown={this.handleKeyDown}
onChange={this.handleRateLimitChange}
/>
<InputGroupAddon addonType="append">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class AddDepartDialog extends React.Component {
});
};

handleKeyPress = (e) => {
handleKeyDown = (e) => {
if (e.key === 'Enter') {
this.handleSubmit();
e.preventDefault();
Expand All @@ -73,7 +73,7 @@ class AddDepartDialog extends React.Component {
<Label for="departName">{gettext('Name')}</Label>
<Input
id="departName"
onKeyPress={this.handleKeyPress}
onKeyDown={this.handleKeyDown}
value={this.state.departName}
onChange={this.handleChange}
autoFocus={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class AddRepoDialog extends React.Component {
});
};

handleKeyPress = (e) => {
handleKeyDown = (e) => {
if (e.key === 'Enter') {
this.handleSubmit();
e.preventDefault();
Expand All @@ -68,7 +68,7 @@ class AddRepoDialog extends React.Component {
<Label for="repoName">{gettext('Name')}</Label>
<Input
id="repoName"
onKeyPress={this.handleKeyPress}
onKeyDown={this.handleKeyDown}
value={this.state.repoName}
onChange={this.handleChange}
autoFocus={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ class SysAdminBatchAddAdminDialog extends React.Component {
this.toggle();
};

handleKeyPress = (e) => {
if (e.key === 'Enter') {
this.handleSubmit();
e.preventDefault();
}
};

render() {
return (
<Modal isOpen={true} toggle={this.toggle}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class SysAdminCreateGroupDialog extends React.Component {
});
};

handleKeyPress = (e) => {
handleKeyDown = (e) => {
if (e.key === 'Enter') {
this.handleSubmit();
e.preventDefault();
Expand All @@ -65,7 +65,7 @@ class SysAdminCreateGroupDialog extends React.Component {
<Label for="groupName">{gettext('Name')}</Label>
<Input
id="groupName"
onKeyPress={this.handleKeyPress}
onKeyDown={this.handleKeyDown}
value={this.state.groupName}
onChange={this.handleRepoNameChange}
autoFocus={true}
Expand Down
Loading

0 comments on commit a4e2e4a

Please sign in to comment.