mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-16 23:29:49 +00:00
[system admin] search repo: use new api (#4273)
This commit is contained in:
@@ -253,7 +253,12 @@ class Item extends Component {
|
||||
} = this.state;
|
||||
let iconUrl = Utils.getLibIconUrl(repo);
|
||||
let iconTitle = Utils.getLibIconTitle(repo);
|
||||
let isGroupOwnedRepo = repo.owner.indexOf('@seafile_group') != -1;
|
||||
const index = repo.owner_email.indexOf('@seafile_group');
|
||||
let isGroupOwnedRepo = index != -1;
|
||||
let departmentID;
|
||||
if (isGroupOwnedRepo) {
|
||||
departmentID = repo.owner_email.substring(0, index);
|
||||
}
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
@@ -264,7 +269,7 @@ class Item extends Component {
|
||||
<td>{repo.id}</td>
|
||||
<td>
|
||||
{isGroupOwnedRepo ?
|
||||
<Link to={`${siteRoot}sys/departments/${repo.owner_name}/`}>{repo.group_name}</Link> :
|
||||
<Link to={`${siteRoot}sys/departments/${departmentID}/`}>{repo.owner_name}</Link> :
|
||||
<UserLink email={repo.owner_email} name={repo.owner_name} />
|
||||
}
|
||||
</td>
|
||||
|
@@ -12,7 +12,6 @@ class SearchRepos extends Component {
|
||||
super(props);
|
||||
this.state = {
|
||||
name: '',
|
||||
owner: '',
|
||||
isSubmitBtnActive: false,
|
||||
loading: true,
|
||||
errorMsg: '',
|
||||
@@ -23,17 +22,16 @@ class SearchRepos extends Component {
|
||||
componentDidMount() {
|
||||
let params = (new URL(document.location)).searchParams;
|
||||
this.setState({
|
||||
name: params.get('name') || '',
|
||||
owner: params.get('owner') || ''
|
||||
name: params.get('name') || ''
|
||||
}, this.getRepos);
|
||||
}
|
||||
|
||||
getRepos = () => {
|
||||
const { name, owner } = this.state;
|
||||
seafileAPI.sysAdminSearchRepos(name, owner).then((res) => {
|
||||
const { name } = this.state;
|
||||
seafileAPI.sysAdminSearchRepos(name).then((res) => {
|
||||
this.setState({
|
||||
loading: false,
|
||||
repos: res.data.repos
|
||||
repos: res.data.repo_list
|
||||
});
|
||||
}).catch((error) => {
|
||||
if (error.response) {
|
||||
@@ -86,21 +84,15 @@ class SearchRepos extends Component {
|
||||
}, this.checkSubmitBtnActive);
|
||||
}
|
||||
|
||||
handleOwnerInputChange = (e) => {
|
||||
this.setState({
|
||||
owner: e.target.value
|
||||
}, this.checkSubmitBtnActive);
|
||||
}
|
||||
|
||||
checkSubmitBtnActive = () => {
|
||||
const { name, owner } = this.state;
|
||||
const { name } = this.state;
|
||||
this.setState({
|
||||
isSubmitBtnActive: name.trim() || owner.trim()
|
||||
isSubmitBtnActive: name.trim()
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
const { name, owner, isSubmitBtnActive } = this.state;
|
||||
const { name, isSubmitBtnActive } = this.state;
|
||||
return (
|
||||
<Fragment>
|
||||
<MainPanelTopbar />
|
||||
@@ -112,7 +104,7 @@ 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 or owner or both.')}</p>
|
||||
<p className="text-secondary small">{gettext('Tip: you can search by keyword in name.')}</p>
|
||||
<Form>
|
||||
<FormGroup row>
|
||||
<Label for="name" sm={1}>{gettext('Name')}</Label>
|
||||
@@ -120,12 +112,6 @@ class SearchRepos extends Component {
|
||||
<Input type="text" name="name" id="name" value={name} onChange={this.handleNameInputChange} />
|
||||
</Col>
|
||||
</FormGroup>
|
||||
<FormGroup row>
|
||||
<Label for="owner" sm={1}>{gettext('Owner')}</Label>
|
||||
<Col sm={5}>
|
||||
<Input type="text" name="owner" id="owner" value={owner} onChange={this.handleOwnerInputChange} />
|
||||
</Col>
|
||||
</FormGroup>
|
||||
<FormGroup row>
|
||||
<Col sm={{size: 5, offset: 1}}>
|
||||
<button className="btn btn-outline-primary" disabled={!isSubmitBtnActive} onClick={this.searchRepos}>{gettext('Submit')}</button>
|
||||
|
Reference in New Issue
Block a user