mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-09 02:42:47 +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 = () => {
|
||||
return <Search
|
||||
placeholder={gettext('Search libraries by name')}
|
||||
placeholder={gettext('Search libraries by name or ID')}
|
||||
submit={this.searchRepos}
|
||||
/>;
|
||||
}
|
||||
|
||||
searchRepos = (repoName) => {
|
||||
navigate(`${siteRoot}sys/search-libraries/?name=${encodeURIComponent(repoName)}`);
|
||||
searchRepos = (repoNameOrID) => {
|
||||
navigate(`${siteRoot}sys/search-libraries/?name_or_id=${encodeURIComponent(repoNameOrID)}`);
|
||||
}
|
||||
|
||||
render() {
|
||||
|
@@ -23,7 +23,7 @@ class SearchRepos extends Component {
|
||||
componentDidMount() {
|
||||
let params = (new URL(document.location)).searchParams;
|
||||
this.setState({
|
||||
name: params.get('name') || ''
|
||||
name: params.get('name_or_id') || ''
|
||||
}, this.getRepos);
|
||||
}
|
||||
|
||||
@@ -90,10 +90,10 @@ class SearchRepos extends Component {
|
||||
<div className="cur-view-content">
|
||||
<div className="mt-4 mb-6">
|
||||
<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>
|
||||
<FormGroup row>
|
||||
<Label for="name" sm={1}>{gettext('Name')}</Label>
|
||||
<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} />
|
||||
</Col>
|
||||
|
@@ -43,7 +43,7 @@ class Search extends React.Component {
|
||||
<input
|
||||
type="text"
|
||||
className="form-control search-input h-6 mr-1"
|
||||
style={{width: '15rem'}}
|
||||
style={{width: '17rem'}}
|
||||
placeholder={this.props.placeholder}
|
||||
value={this.state.value}
|
||||
onChange={this.handleInputChange}
|
||||
|
@@ -482,7 +482,7 @@ class AdminSearchLibrary(APIView):
|
||||
permission_classes = (IsAdminUser,)
|
||||
|
||||
def get(self, request, format=None):
|
||||
""" Search library by name.
|
||||
""" Search library by name or id.
|
||||
|
||||
Permission checking:
|
||||
1. only admin can perform this action.
|
||||
@@ -497,6 +497,7 @@ class AdminSearchLibrary(APIView):
|
||||
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
||||
|
||||
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()
|
||||
repos = [r for r in repos if not r.is_virtual]
|
||||
|
Reference in New Issue
Block a user