mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-09 19:01:42 +00:00
update homepage get repo (#6077)
* Merge to get repo API * add-public-repo-list --------- Co-authored-by: 孙永强 <11704063+s-yongqiang@user.noreply.gitee.com> Co-authored-by: r350178982 <32759763+r350178982@users.noreply.github.com>
This commit is contained in:
@@ -42,7 +42,15 @@ class Libraries extends Component {
|
||||
// for 'groups'
|
||||
isGroupsLoading: true,
|
||||
groupsErrorMsg: '',
|
||||
groupList: []
|
||||
groupList: [],
|
||||
|
||||
// for 'shared'
|
||||
sharedRepoList:[],
|
||||
isSharedLoading: true,
|
||||
|
||||
// for 'public'
|
||||
publicRepoList: [],
|
||||
isPublicLoading: true,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -52,18 +60,34 @@ class Libraries extends Component {
|
||||
}
|
||||
|
||||
listMyLibs = () => {
|
||||
seafileAPI.listRepos({type: 'mine'}).then((res) => {
|
||||
let repoList = res.data.repos.map((item) => {
|
||||
seafileAPI.listRepos({'type':['mine', 'shared', 'public']}).then((res) => {
|
||||
let allRepoList = res.data.repos.map((item) => {
|
||||
return new Repo(item);
|
||||
});
|
||||
let myRepoList = allRepoList.filter(item => {
|
||||
return item.type === 'mine';
|
||||
});
|
||||
let sharedRepoList = allRepoList.filter(item => {
|
||||
return item.type === 'shared';
|
||||
});
|
||||
let publicRepoList = allRepoList.filter(item => {
|
||||
return item.type === 'public';
|
||||
});
|
||||
this.setState({
|
||||
isLoading: false,
|
||||
repoList: Utils.sortRepos(repoList, this.state.sortBy, this.state.sortOrder)
|
||||
sharedRepoList: sharedRepoList,
|
||||
publicRepoList: publicRepoList,
|
||||
repoList: Utils.sortRepos(myRepoList, this.state.sortBy, this.state.sortOrder),
|
||||
},() => {
|
||||
this.setState({
|
||||
isSharedLoading: false,
|
||||
isPublicLoading: false
|
||||
});
|
||||
});
|
||||
}).catch((error) => {
|
||||
this.setState({
|
||||
isLoading: false,
|
||||
errorMsg: Utils.getErrorMsg(error, true) // true: show login tip if 403
|
||||
errorMsg: Utils.getErrorMsg(error, true), // true: show login tip if 403
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -256,12 +280,19 @@ class Libraries extends Component {
|
||||
)}
|
||||
|
||||
<div className="pb-3">
|
||||
<SharedLibs inAllLibs={true} />
|
||||
{!this.state.isSharedLoading &&
|
||||
<SharedLibs
|
||||
inAllLibs={true}
|
||||
repoList={this.state.sharedRepoList} />
|
||||
}
|
||||
</div>
|
||||
|
||||
{canViewOrg && (
|
||||
{canViewOrg && !this.state.isPublicLoading && (
|
||||
<div className="pb-3">
|
||||
<SharedWithAll inAllLibs={true} />
|
||||
<SharedWithAll
|
||||
inAllLibs={true}
|
||||
repoList={this.state.publicRepoList}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
Reference in New Issue
Block a user