mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-09 10:50:24 +00:00
admin search repo by id (#5221)
* admin search repo by id * id => ID Co-authored-by: lian <lian@seafile.com>
This commit is contained in:
@@ -114,13 +114,13 @@ class AllRepos extends Component {
|
|||||||
|
|
||||||
getSearch = () => {
|
getSearch = () => {
|
||||||
return <Search
|
return <Search
|
||||||
placeholder={gettext('Search libraries by name')}
|
placeholder={gettext('Search libraries by name or ID')}
|
||||||
submit={this.searchRepos}
|
submit={this.searchRepos}
|
||||||
/>;
|
/>;
|
||||||
}
|
}
|
||||||
|
|
||||||
searchRepos = (repoName) => {
|
searchRepos = (repoNameOrID) => {
|
||||||
navigate(`${siteRoot}sys/search-libraries/?name=${encodeURIComponent(repoName)}`);
|
navigate(`${siteRoot}sys/search-libraries/?name_or_id=${encodeURIComponent(repoNameOrID)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@@ -23,7 +23,7 @@ class SearchRepos extends Component {
|
|||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
let params = (new URL(document.location)).searchParams;
|
let params = (new URL(document.location)).searchParams;
|
||||||
this.setState({
|
this.setState({
|
||||||
name: params.get('name') || ''
|
name: params.get('name_or_id') || ''
|
||||||
}, this.getRepos);
|
}, this.getRepos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,10 +90,10 @@ class SearchRepos extends Component {
|
|||||||
<div className="cur-view-content">
|
<div className="cur-view-content">
|
||||||
<div className="mt-4 mb-6">
|
<div className="mt-4 mb-6">
|
||||||
<h4 className="border-bottom font-weight-normal mb-2 pb-1">{gettext('Search Libraries')}</h4>
|
<h4 className="border-bottom font-weight-normal mb-2 pb-1">{gettext('Search Libraries')}</h4>
|
||||||
<p className="text-secondary small">{gettext('Tip: you can search by keyword in name.')}</p>
|
<p className="text-secondary small">{gettext('Tip: you can search by keyword in name or ID.')}</p>
|
||||||
<Form>
|
<Form>
|
||||||
<FormGroup row>
|
<FormGroup row>
|
||||||
<Label for="name" sm={1}>{gettext('Name')}</Label>
|
<Label for="name" sm={1}>{gettext('Name or ID')}</Label>
|
||||||
<Col sm={5}>
|
<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} />
|
||||||
</Col>
|
</Col>
|
||||||
|
@@ -43,7 +43,7 @@ class Search extends React.Component {
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
className="form-control search-input h-6 mr-1"
|
className="form-control search-input h-6 mr-1"
|
||||||
style={{width: '15rem'}}
|
style={{width: '17rem'}}
|
||||||
placeholder={this.props.placeholder}
|
placeholder={this.props.placeholder}
|
||||||
value={this.state.value}
|
value={this.state.value}
|
||||||
onChange={this.handleInputChange}
|
onChange={this.handleInputChange}
|
||||||
|
@@ -482,7 +482,7 @@ class AdminSearchLibrary(APIView):
|
|||||||
permission_classes = (IsAdminUser,)
|
permission_classes = (IsAdminUser,)
|
||||||
|
|
||||||
def get(self, request, format=None):
|
def get(self, request, format=None):
|
||||||
""" Search library by name.
|
""" Search library by name or id.
|
||||||
|
|
||||||
Permission checking:
|
Permission checking:
|
||||||
1. only admin can perform this action.
|
1. only admin can perform this action.
|
||||||
@@ -497,6 +497,7 @@ class AdminSearchLibrary(APIView):
|
|||||||
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
||||||
|
|
||||||
repos = seafile_api.search_repos_by_name(query_str)
|
repos = seafile_api.search_repos_by_name(query_str)
|
||||||
|
repos += seafile_api.get_repos_by_id_prefix(query_str)
|
||||||
|
|
||||||
default_repo_id = get_system_default_repo_id()
|
default_repo_id = get_system_default_repo_id()
|
||||||
repos = [r for r in repos if not r.is_virtual]
|
repos = [r for r in repos if not r.is_virtual]
|
||||||
|
Reference in New Issue
Block a user