1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-07-31 14:52:38 +00:00

optimize-code (#5667)

This commit is contained in:
杨顺强 2023-10-08 16:46:34 +08:00 committed by GitHub
parent a173d4fb66
commit 02c0b3dce1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 60 additions and 6 deletions

View File

@ -235,6 +235,15 @@ class OrgGroupsSearchGroups extends Component {
});
}
handleKeyDown = (e) => {
if (e.keyCode === 13) {
const { isSubmitBtnActive } = this.state;
if (isSubmitBtnActive) {
this.getItems();
}
}
}
render() {
const { query, isSubmitBtnActive } = this.state;
@ -251,7 +260,7 @@ class OrgGroupsSearchGroups extends Component {
<Form tag={'div'}>
<FormGroup row>
<Col sm={5}>
<Input type="text" name="query" value={query} placeholder={gettext('Search groups')} onChange={this.handleInputChange} />
<Input type="text" name="query" value={query} placeholder={gettext('Search groups')} onChange={this.handleInputChange} onKeyDown={this.handleKeyDown} />
</Col>
</FormGroup>
<FormGroup row>

View File

@ -142,6 +142,15 @@ class OrgUsersSearchUsers extends Component {
});
}
handleKeyDown = (e) => {
if (e.keyCode === 13) {
const { isSubmitBtnActive } = this.state;
if (isSubmitBtnActive) {
this.getItems();
}
}
}
render() {
const { query, isSubmitBtnActive } = this.state;
@ -158,7 +167,7 @@ class OrgUsersSearchUsers extends Component {
<Form tag={'div'}>
<FormGroup row>
<Col sm={5}>
<Input type="text" name="query" value={query} placeholder={gettext('Search users')} onChange={this.handleInputChange} />
<Input type="text" name="query" value={query} placeholder={gettext('Search users')} onChange={this.handleInputChange} onKeyDown={this.handleKeyDown} />
</Col>
</FormGroup>
<FormGroup row>

View File

@ -89,6 +89,15 @@ class SearchGroups extends Component {
});
}
handleKeyDown = (e) => {
if (e.keyCode === 13) {
const { isSubmitBtnActive } = this.state;
if (isSubmitBtnActive) {
this.getGroups();
}
}
}
render() {
const { name, isSubmitBtnActive } = this.state;
@ -108,7 +117,7 @@ class SearchGroups extends Component {
<FormGroup row>
<Label for="name" sm={1}>{gettext('Name')}</Label>
<Col sm={5}>
<Input type="text" name="name" id="name" value={name} onChange={this.handleNameInputChange} />
<Input type="text" name="name" id="name" value={name} onChange={this.handleNameInputChange} onKeyDown={this.handleKeyDown} />
</Col>
</FormGroup>
<FormGroup row>

View File

@ -86,6 +86,15 @@ class SearchOrgs extends Component {
});
}
handleKeyDown = (e) => {
if (e.keyCode === 13) {
const { isSubmitBtnActive } = this.state;
if (isSubmitBtnActive) {
this.getItems();
}
}
}
render() {
const { query, isSubmitBtnActive } = this.state;
return (
@ -104,7 +113,7 @@ class SearchOrgs extends Component {
<FormGroup row>
<Label for="name" sm={1}>{gettext('Name')}</Label>
<Col sm={5}>
<Input type="text" name="query" id="name" value={query} onChange={this.handleInputChange} />
<Input type="text" name="query" id="name" value={query} onChange={this.handleInputChange} onKeyDown={this.handleKeyDown} />
</Col>
</FormGroup>
<FormGroup row>

View File

@ -78,6 +78,15 @@ class SearchRepos extends Component {
});
}
handleKeyDown = (e) => {
if (e.keyCode === 13) {
const { isSubmitBtnActive } = this.state;
if (isSubmitBtnActive) {
this.searchRepos();
}
}
}
render() {
const { name, isSubmitBtnActive } = this.state;
return (
@ -96,7 +105,7 @@ class SearchRepos extends Component {
<FormGroup row>
<Label for="name" sm={1}>{gettext('Name or ID')}</Label>
<Col sm={5}>
<Input type="text" name="name" id="name" value={name} onChange={this.handleNameInputChange} />
<Input type="text" name="name" id="name" value={name} onChange={this.handleNameInputChange} onKeyDown={this.handleKeyDown} />
</Col>
</FormGroup>
<FormGroup row>

View File

@ -270,6 +270,15 @@ class SearchUsers extends Component {
this.getItems(this.state.pageInfo.current_page + 1);
}
handleKeyDown = (e) => {
if (e.keyCode === 13) {
const { isSubmitBtnActive } = this.state;
if (isSubmitBtnActive) {
this.getItems();
}
}
}
render() {
const { query, isSubmitBtnActive } = this.state;
const {
@ -299,7 +308,7 @@ class SearchUsers extends Component {
<Form tag={'div'}>
<FormGroup row>
<Col sm={5}>
<Input type="text" name="query" value={query} placeholder={gettext('Search users')} onChange={this.handleInputChange} />
<Input type="text" name="query" value={query} placeholder={gettext('Search users')} onChange={this.handleInputChange} onKeyDown={this.handleKeyDown} />
</Col>
</FormGroup>
<FormGroup row>