From a4e2e4aba44f3155ab4334befa814bd135bb7301 Mon Sep 17 00:00:00 2001 From: llj Date: Tue, 14 Nov 2023 20:25:25 +0800 Subject: [PATCH] =?UTF-8?q?[keypress]=20replaced=20'onKeyPress'=20with=20'?= =?UTF-8?q?onKeyDown'=20as=20'keypress'=20is=20de=E2=80=A6=20(#5764)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [keypress] replaced 'onKeyPress' with 'onKeyDown' as 'keypress' is deprecated * cleaned up code --- .../src/components/dialog/create-department-repo-dialog.js | 4 ++-- frontend/src/components/dialog/create-file-dialog.js | 4 ++-- frontend/src/components/dialog/create-folder-dialog.js | 4 ++-- frontend/src/components/dialog/create-repo-dialog.js | 4 ++-- frontend/src/components/dialog/create-tag-dialog.js | 4 ++-- frontend/src/components/dialog/lib-decrypt-dialog.js | 4 ++-- .../src/components/dialog/lib-history-setting-dialog.js | 4 ++-- .../src/components/dialog/lib-old-files-auto-del-dialog.js | 4 ++-- frontend/src/components/dialog/new-wiki-dialog.js | 4 ++-- .../src/components/dialog/org-add-department-dialog.js | 4 ++-- frontend/src/components/dialog/org-add-repo-dialog.js | 4 ++-- frontend/src/components/dialog/org-add-user-dialog.js | 7 ------- .../src/components/dialog/org-rename-department-dialog.js | 4 ++-- .../src/components/dialog/org-set-group-quota-dialog.js | 4 ++-- frontend/src/components/dialog/rename-dialog.js | 4 ++-- frontend/src/components/dialog/rename-dirent.js | 4 ++-- .../src/components/dialog/sysadmin-dialog/set-quota.js | 4 ++-- .../sysadmin-dialog/set-upload-download-rate-limit.js | 4 ++-- .../sysadmin-dialog/sysadmin-add-department-dialog.js | 4 ++-- .../dialog/sysadmin-dialog/sysadmin-add-repo-dialog.js | 4 ++-- .../sysadmin-dialog/sysadmin-batch-add-admin-dialog.js | 7 ------- .../dialog/sysadmin-dialog/sysadmin-create-group-dialog.js | 4 ++-- .../dialog/sysadmin-dialog/sysadmin-create-repo-dialog.js | 4 ++-- .../sysadmin-dialog/sysadmin-lib-history-setting-dialog.js | 4 ++-- .../sysadmin-dialog/sysadmin-rename-department-dialog.js | 4 ++-- .../sysadmin-dialog/sysadmin-set-group-quota-dialog.js | 4 ++-- .../sysadmin-set-org-max-user-number-dialog.js | 4 ++-- .../dialog/sysadmin-dialog/sysadmin-set-org-name-dialog.js | 4 ++-- .../src/components/dialog/sysadmin-dialog/update-user.js | 4 ++-- frontend/src/pages/org-admin/org-groups.js | 4 ++-- frontend/src/pages/org-admin/org-users-users.js | 4 ++-- frontend/src/pages/sys-admin/search.js | 4 ++-- 32 files changed, 60 insertions(+), 74 deletions(-) diff --git a/frontend/src/components/dialog/create-department-repo-dialog.js b/frontend/src/components/dialog/create-department-repo-dialog.js index 6864ddab599..86a4265de7a 100644 --- a/frontend/src/components/dialog/create-department-repo-dialog.js +++ b/frontend/src/components/dialog/create-department-repo-dialog.js @@ -38,7 +38,7 @@ class CreateDepartmentRepoDialog extends React.Component { } }; - handleKeyPress = (e) => { + handleKeyDown = (e) => { if (e.key === 'Enter') { this.handleSubmit(); e.preventDefault(); @@ -81,7 +81,7 @@ class CreateDepartmentRepoDialog extends React.Component { { + handleKeyDown = (e) => { if (e.key === 'Enter') { this.handleSubmit(); e.preventDefault(); @@ -151,7 +151,7 @@ class CreateFile extends React.Component { { + handleKeyDown = (e) => { if (e.key === 'Enter') { this.handleSubmit(); e.preventDefault(); @@ -87,7 +87,7 @@ class CreateForder extends React.Component { diff --git a/frontend/src/components/dialog/create-repo-dialog.js b/frontend/src/components/dialog/create-repo-dialog.js index 1d1e74b0e1f..691e1a3b407 100644 --- a/frontend/src/components/dialog/create-repo-dialog.js +++ b/frontend/src/components/dialog/create-repo-dialog.js @@ -57,7 +57,7 @@ class CreateRepoDialog extends React.Component { } }; - handleKeyPress = (e) => { + handleKeyDown = (e) => { if (e.key === 'Enter') { this.handleSubmit(); e.preventDefault(); @@ -180,7 +180,7 @@ class CreateRepoDialog extends React.Component { { + handleKeyDown = (e) => { if (e.key === 'Enter') { this.createTag(); } @@ -77,7 +77,7 @@ class CreateTagDialog extends React.Component {
- +
{this.state.errorMsg}
diff --git a/frontend/src/components/dialog/lib-decrypt-dialog.js b/frontend/src/components/dialog/lib-decrypt-dialog.js index edd7482ace2..fd011396177 100644 --- a/frontend/src/components/dialog/lib-decrypt-dialog.js +++ b/frontend/src/components/dialog/lib-decrypt-dialog.js @@ -35,7 +35,7 @@ class LibDecryptDialog extends React.Component { e.preventDefault(); }; - handleKeyPress = (e) => { + handleKeyDown = (e) => { if (e.key == 'Enter') { this.handleSubmit(e); } @@ -63,7 +63,7 @@ class LibDecryptDialog extends React.Component { {this.state.showError &&

{gettext('Wrong password')}

} - +

{'* '}{gettext('The password will be kept in the server for only 1 hour.')}

diff --git a/frontend/src/components/dialog/lib-history-setting-dialog.js b/frontend/src/components/dialog/lib-history-setting-dialog.js index d16b56547fe..2361a503716 100644 --- a/frontend/src/components/dialog/lib-history-setting-dialog.js +++ b/frontend/src/components/dialog/lib-history-setting-dialog.js @@ -68,7 +68,7 @@ class LibHistorySetting extends React.Component { } }; - handleKeyPress = (e) => { + handleKeyDown = (e) => { if (e.key === 'Enter') { this.submit(); e.preventDefault(); @@ -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} />{' '} diff --git a/frontend/src/components/dialog/lib-old-files-auto-del-dialog.js b/frontend/src/components/dialog/lib-old-files-auto-del-dialog.js index 72923f5b96d..3ba5c939375 100644 --- a/frontend/src/components/dialog/lib-old-files-auto-del-dialog.js +++ b/frontend/src/components/dialog/lib-old-files-auto-del-dialog.js @@ -65,7 +65,7 @@ class LibOldFilesAutoDelDialog extends React.Component { }); }; - handleKeyPress = (e) => { + handleKeyDown = (e) => { if (e.key === 'Enter') { this.submit(); e.preventDefault(); @@ -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} />{' '} diff --git a/frontend/src/components/dialog/new-wiki-dialog.js b/frontend/src/components/dialog/new-wiki-dialog.js index 1f8d251b587..d8fb4313947 100644 --- a/frontend/src/components/dialog/new-wiki-dialog.js +++ b/frontend/src/components/dialog/new-wiki-dialog.js @@ -32,7 +32,7 @@ class NewWikiDialog extends React.Component { }); }; - handleKeyPress = (e) => { + handleKeyDown = (e) => { if (e.key === 'Enter') { this.handleSubmit(); } @@ -54,7 +54,7 @@ class NewWikiDialog extends React.Component { {gettext('New Wiki')} - + diff --git a/frontend/src/components/dialog/org-add-department-dialog.js b/frontend/src/components/dialog/org-add-department-dialog.js index 751e9b3f728..93d0ea8ee64 100644 --- a/frontend/src/components/dialog/org-add-department-dialog.js +++ b/frontend/src/components/dialog/org-add-department-dialog.js @@ -55,7 +55,7 @@ class AddDepartDialog extends React.Component { }); }; - handleKeyPress = (e) => { + handleKeyDown = (e) => { if (e.key === 'Enter') { this.handleSubmit(); e.preventDefault(); @@ -73,7 +73,7 @@ class AddDepartDialog extends React.Component { { + handleKeyDown = (e) => { if (e.key === 'Enter') { this.handleSubmit(); e.preventDefault(); @@ -68,7 +68,7 @@ class AddRepoDialog extends React.Component { { - e.preventDefault(); - if (e.key == 'Enter') { - this.handleSubmit(e); - } - }; - togglePasswordVisible = () => { this.setState({isPasswordVisible: !this.state.isPasswordVisible}, () => { if (this.state.isPasswordVisible) { diff --git a/frontend/src/components/dialog/org-rename-department-dialog.js b/frontend/src/components/dialog/org-rename-department-dialog.js index 64322ca0b6a..6de29d5aa32 100644 --- a/frontend/src/components/dialog/org-rename-department-dialog.js +++ b/frontend/src/components/dialog/org-rename-department-dialog.js @@ -63,7 +63,7 @@ class RenameDepartmentDialog extends React.Component { }); }; - handleKeyPress = (e) => { + handleKeyDown = (e) => { if (e.key === 'Enter') { this.handleSubmit(); e.preventDefault(); @@ -87,7 +87,7 @@ class RenameDepartmentDialog extends React.Component { { + handleKeyDown = (e) => { if (e.key === 'Enter') { this.setGroupQuota(); e.preventDefault(); @@ -60,7 +60,7 @@ class SetGroupQuotaDialog extends React.Component { { + handleKeyDown = (e) => { if (e.key === 'Enter') { this.handleSubmit(); } @@ -121,7 +121,7 @@ class Rename extends React.Component { {type === 'file' ? gettext('Rename File') : gettext('Rename Folder') }

{type === 'file' ? gettext('New file name'): gettext('New folder name')}

- + {this.state.errMessage && {this.state.errMessage}}
diff --git a/frontend/src/components/dialog/rename-dirent.js b/frontend/src/components/dialog/rename-dirent.js index 61a45cb2982..865994b90b2 100644 --- a/frontend/src/components/dialog/rename-dirent.js +++ b/frontend/src/components/dialog/rename-dirent.js @@ -63,7 +63,7 @@ class Rename extends React.Component { } }; - handleKeyPress = (e) => { + handleKeyDown = (e) => { if (e.key === 'Enter') { this.handleSubmit(); } @@ -123,7 +123,7 @@ class Rename extends React.Component { {type === 'file' ? gettext('Rename File') : gettext('Rename Folder') }

{type === 'file' ? gettext('New file name'): gettext('New folder name')}

- + {this.state.errMessage && {this.state.errMessage}}
diff --git a/frontend/src/components/dialog/sysadmin-dialog/set-quota.js b/frontend/src/components/dialog/sysadmin-dialog/set-quota.js index cd08cea927d..5be4f0c6ea1 100644 --- a/frontend/src/components/dialog/sysadmin-dialog/set-quota.js +++ b/frontend/src/components/dialog/sysadmin-dialog/set-quota.js @@ -30,7 +30,7 @@ class SetQuotaDialog extends React.Component { }); }; - handleKeyPress = (e) => { + handleKeyDown = (e) => { if (e.key == 'Enter') { this.handleSubmit(); e.preventDefault(); @@ -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} /> diff --git a/frontend/src/components/dialog/sysadmin-dialog/set-upload-download-rate-limit.js b/frontend/src/components/dialog/sysadmin-dialog/set-upload-download-rate-limit.js index 22b09a78bd2..88b0ec4a732 100644 --- a/frontend/src/components/dialog/sysadmin-dialog/set-upload-download-rate-limit.js +++ b/frontend/src/components/dialog/sysadmin-dialog/set-upload-download-rate-limit.js @@ -31,7 +31,7 @@ class SysAdminSetUploadDownloadRateLimitDialog extends React.Component { }); }; - handleKeyPress = (e) => { + handleKeyDown = (e) => { if (e.key == 'Enter') { this.handleSubmit(); e.preventDefault(); @@ -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} /> diff --git a/frontend/src/components/dialog/sysadmin-dialog/sysadmin-add-department-dialog.js b/frontend/src/components/dialog/sysadmin-dialog/sysadmin-add-department-dialog.js index 769000d3d58..b2c843439b5 100644 --- a/frontend/src/components/dialog/sysadmin-dialog/sysadmin-add-department-dialog.js +++ b/frontend/src/components/dialog/sysadmin-dialog/sysadmin-add-department-dialog.js @@ -55,7 +55,7 @@ class AddDepartDialog extends React.Component { }); }; - handleKeyPress = (e) => { + handleKeyDown = (e) => { if (e.key === 'Enter') { this.handleSubmit(); e.preventDefault(); @@ -73,7 +73,7 @@ class AddDepartDialog extends React.Component { { + handleKeyDown = (e) => { if (e.key === 'Enter') { this.handleSubmit(); e.preventDefault(); @@ -68,7 +68,7 @@ class AddRepoDialog extends React.Component { { - if (e.key === 'Enter') { - this.handleSubmit(); - e.preventDefault(); - } - }; - render() { return ( diff --git a/frontend/src/components/dialog/sysadmin-dialog/sysadmin-create-group-dialog.js b/frontend/src/components/dialog/sysadmin-dialog/sysadmin-create-group-dialog.js index fcf78ff7989..41ca3d2a74f 100644 --- a/frontend/src/components/dialog/sysadmin-dialog/sysadmin-create-group-dialog.js +++ b/frontend/src/components/dialog/sysadmin-dialog/sysadmin-create-group-dialog.js @@ -44,7 +44,7 @@ class SysAdminCreateGroupDialog extends React.Component { }); }; - handleKeyPress = (e) => { + handleKeyDown = (e) => { if (e.key === 'Enter') { this.handleSubmit(); e.preventDefault(); @@ -65,7 +65,7 @@ class SysAdminCreateGroupDialog extends React.Component { { + handleKeyDown = (e) => { if (e.key === 'Enter') { this.handleSubmit(); e.preventDefault(); @@ -63,7 +63,7 @@ class SysAdminCreateRepoDialog extends React.Component { { + handleKeyDown = (e) => { if (e.key === 'Enter') { this.submit(); e.preventDefault(); @@ -132,7 +132,7 @@ class SysAdminLibHistorySettingDialog extends React.Component { value={this.state.expireDays} onChange={this.onChange} disabled={this.state.disabled} - onKeyDown={this.handleKeyPress} + onKeyDown={this.handleKeyDown} />{' '} diff --git a/frontend/src/components/dialog/sysadmin-dialog/sysadmin-rename-department-dialog.js b/frontend/src/components/dialog/sysadmin-dialog/sysadmin-rename-department-dialog.js index ccf21d8c0d8..ef521fcb4b3 100644 --- a/frontend/src/components/dialog/sysadmin-dialog/sysadmin-rename-department-dialog.js +++ b/frontend/src/components/dialog/sysadmin-dialog/sysadmin-rename-department-dialog.js @@ -58,7 +58,7 @@ class RenameDepartmentDialog extends React.Component { }); }; - handleKeyPress = (e) => { + handleKeyDown = (e) => { if (e.key === 'Enter') { this.handleSubmit(); e.preventDefault(); @@ -82,7 +82,7 @@ class RenameDepartmentDialog extends React.Component { { + handleKeyDown = (e) => { if (e.key === 'Enter') { this.setGroupQuota(); e.preventDefault(); @@ -60,7 +60,7 @@ class SetGroupQuotaDialog extends React.Component { { + handleKeyDown = (e) => { if (e.key == 'Enter') { this.handleSubmit(); e.preventDefault(); @@ -55,7 +55,7 @@ class SysAdminSetOrgMaxUserNumberDialog extends React.Component { type="text" className="form-control" value={value} - onKeyPress={this.handleKeyPress} + onKeyDown={this.handleKeyDown} onChange={this.handleInputChange} /> diff --git a/frontend/src/components/dialog/sysadmin-dialog/sysadmin-set-org-name-dialog.js b/frontend/src/components/dialog/sysadmin-dialog/sysadmin-set-org-name-dialog.js index 4a9ad650cd6..ed2c98bb763 100644 --- a/frontend/src/components/dialog/sysadmin-dialog/sysadmin-set-org-name-dialog.js +++ b/frontend/src/components/dialog/sysadmin-dialog/sysadmin-set-org-name-dialog.js @@ -31,7 +31,7 @@ class SysAdminSetOrgNameDialog extends React.Component { }); }; - handleKeyPress = (e) => { + handleKeyDown = (e) => { if (e.key == 'Enter') { this.handleSubmit(); e.preventDefault(); @@ -54,7 +54,7 @@ class SysAdminSetOrgNameDialog extends React.Component { diff --git a/frontend/src/components/dialog/sysadmin-dialog/update-user.js b/frontend/src/components/dialog/sysadmin-dialog/update-user.js index bbabd40b9e8..438da85998d 100644 --- a/frontend/src/components/dialog/sysadmin-dialog/update-user.js +++ b/frontend/src/components/dialog/sysadmin-dialog/update-user.js @@ -27,7 +27,7 @@ class UpdateUser extends React.Component { }); }; - handleKeyPress = (e) => { + handleKeyDown = (e) => { if (e.key == 'Enter') { this.handleSubmit(); e.preventDefault(); @@ -50,7 +50,7 @@ class UpdateUser extends React.Component { diff --git a/frontend/src/pages/org-admin/org-groups.js b/frontend/src/pages/org-admin/org-groups.js index 1c4fa30760c..583a7f87cd1 100644 --- a/frontend/src/pages/org-admin/org-groups.js +++ b/frontend/src/pages/org-admin/org-groups.js @@ -24,7 +24,7 @@ class Search extends React.Component { }); }; - handleKeyPress = (e) => { + handleKeyDown = (e) => { if (e.key == 'Enter') { e.preventDefault(); this.handleSubmit(); @@ -50,7 +50,7 @@ class Search extends React.Component { placeholder={this.props.placeholder} value={this.state.value} onChange={this.handleInputChange} - onKeyPress={this.handleKeyPress} + onKeyDown={this.handleKeyDown} autoComplete="off" />
diff --git a/frontend/src/pages/org-admin/org-users-users.js b/frontend/src/pages/org-admin/org-users-users.js index 9f17e1756bf..5aa35138528 100644 --- a/frontend/src/pages/org-admin/org-users-users.js +++ b/frontend/src/pages/org-admin/org-users-users.js @@ -29,7 +29,7 @@ class Search extends React.Component { }); }; - handleKeyPress = (e) => { + handleKeyDown = (e) => { if (e.key == 'Enter') { e.preventDefault(); this.handleSubmit(); @@ -55,7 +55,7 @@ class Search extends React.Component { placeholder={this.props.placeholder} value={this.state.value} onChange={this.handleInputChange} - onKeyPress={this.handleKeyPress} + onKeyDown={this.handleKeyDown} autoComplete="off" />
diff --git a/frontend/src/pages/sys-admin/search.js b/frontend/src/pages/sys-admin/search.js index a651c75520d..a97b52e7c72 100644 --- a/frontend/src/pages/sys-admin/search.js +++ b/frontend/src/pages/sys-admin/search.js @@ -21,7 +21,7 @@ class Search extends React.Component { }); }; - handleKeyPress = (e) => { + handleKeyDown = (e) => { if (e.key == 'Enter') { e.preventDefault(); this.handleSubmit(); @@ -47,7 +47,7 @@ class Search extends React.Component { placeholder={this.props.placeholder} value={this.state.value} onChange={this.handleInputChange} - onKeyPress={this.handleKeyPress} + onKeyDown={this.handleKeyDown} autoComplete="off" />