mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-12 13:24:52 +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>
|
||||
)}
|
||||
|
||||
|
@@ -407,6 +407,7 @@ class SharedLibraries extends Component {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
if (!this.props.repoList) {
|
||||
seafileAPI.listRepos({type:'shared'}).then((res) => {
|
||||
let repoList = res.data.repos.map((item) => {
|
||||
return new Repo(item);
|
||||
@@ -418,9 +419,15 @@ class SharedLibraries extends Component {
|
||||
}).catch((error) => {
|
||||
this.setState({
|
||||
loading: false,
|
||||
errorMsg: Utils.getErrorMsg(error, true) // true: show login tip if 403
|
||||
errorMsg: Utils.getErrorMsg(error, true)
|
||||
});
|
||||
});
|
||||
} else {
|
||||
this.setState({
|
||||
loading: false,
|
||||
items: Utils.sortRepos(this.props.repoList, this.state.sortBy, this.state.sortOrder)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
sortItems = (sortBy, sortOrder) => {
|
||||
@@ -516,7 +523,8 @@ class SharedLibraries extends Component {
|
||||
}
|
||||
|
||||
SharedLibraries.propTypes = {
|
||||
inAllLibs: PropTypes.bool
|
||||
inAllLibs: PropTypes.bool,
|
||||
repoList: PropTypes.array,
|
||||
};
|
||||
|
||||
export default SharedLibraries;
|
||||
|
@@ -16,7 +16,8 @@ import TopToolbar from './top-toolbar';
|
||||
const propTypes = {
|
||||
onShowSidePanel: PropTypes.func,
|
||||
onSearchedClick: PropTypes.func,
|
||||
inAllLibs: PropTypes.bool
|
||||
inAllLibs: PropTypes.bool,
|
||||
repoList: PropTypes.array,
|
||||
};
|
||||
|
||||
class PublicSharedView extends React.Component {
|
||||
@@ -35,10 +36,10 @@ class PublicSharedView extends React.Component {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
if (!this.props.repoList) {
|
||||
seafileAPI.listRepos({type:'public'}).then((res) => {
|
||||
let repoList = res.data.repos.map(item => {
|
||||
let repo = new Repo(item);
|
||||
return repo;
|
||||
let repoList = res.data.repos.map((item) => {
|
||||
return new Repo(item);
|
||||
});
|
||||
this.setState({
|
||||
isLoading: false,
|
||||
@@ -47,9 +48,15 @@ class PublicSharedView extends React.Component {
|
||||
}).catch((error) => {
|
||||
this.setState({
|
||||
isLoading: false,
|
||||
errorMsg: Utils.getErrorMsg(error, true) // true: show login tip if 403
|
||||
errMessage: Utils.getErrorMsg(error, true)
|
||||
});
|
||||
});
|
||||
} else {
|
||||
this.setState({
|
||||
isLoading: false,
|
||||
repoList: Utils.sortRepos(this.props.repoList, this.state.sortBy, this.state.sortOrder)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
onItemUnshare = (repo) => {
|
||||
|
Reference in New Issue
Block a user