mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-12 21:30:39 +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'
|
// for 'groups'
|
||||||
isGroupsLoading: true,
|
isGroupsLoading: true,
|
||||||
groupsErrorMsg: '',
|
groupsErrorMsg: '',
|
||||||
groupList: []
|
groupList: [],
|
||||||
|
|
||||||
|
// for 'shared'
|
||||||
|
sharedRepoList:[],
|
||||||
|
isSharedLoading: true,
|
||||||
|
|
||||||
|
// for 'public'
|
||||||
|
publicRepoList: [],
|
||||||
|
isPublicLoading: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,18 +60,34 @@ class Libraries extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
listMyLibs = () => {
|
listMyLibs = () => {
|
||||||
seafileAPI.listRepos({type: 'mine'}).then((res) => {
|
seafileAPI.listRepos({'type':['mine', 'shared', 'public']}).then((res) => {
|
||||||
let repoList = res.data.repos.map((item) => {
|
let allRepoList = res.data.repos.map((item) => {
|
||||||
return new Repo(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({
|
this.setState({
|
||||||
isLoading: false,
|
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) => {
|
}).catch((error) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
isLoading: false,
|
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">
|
<div className="pb-3">
|
||||||
<SharedLibs inAllLibs={true} />
|
{!this.state.isSharedLoading &&
|
||||||
|
<SharedLibs
|
||||||
|
inAllLibs={true}
|
||||||
|
repoList={this.state.sharedRepoList} />
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{canViewOrg && (
|
{canViewOrg && !this.state.isPublicLoading && (
|
||||||
<div className="pb-3">
|
<div className="pb-3">
|
||||||
<SharedWithAll inAllLibs={true} />
|
<SharedWithAll
|
||||||
|
inAllLibs={true}
|
||||||
|
repoList={this.state.publicRepoList}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
@@ -407,6 +407,7 @@ class SharedLibraries extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
if (!this.props.repoList) {
|
||||||
seafileAPI.listRepos({type:'shared'}).then((res) => {
|
seafileAPI.listRepos({type:'shared'}).then((res) => {
|
||||||
let repoList = res.data.repos.map((item) => {
|
let repoList = res.data.repos.map((item) => {
|
||||||
return new Repo(item);
|
return new Repo(item);
|
||||||
@@ -418,9 +419,15 @@ class SharedLibraries extends Component {
|
|||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
loading: false,
|
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) => {
|
sortItems = (sortBy, sortOrder) => {
|
||||||
@@ -516,7 +523,8 @@ class SharedLibraries extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SharedLibraries.propTypes = {
|
SharedLibraries.propTypes = {
|
||||||
inAllLibs: PropTypes.bool
|
inAllLibs: PropTypes.bool,
|
||||||
|
repoList: PropTypes.array,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default SharedLibraries;
|
export default SharedLibraries;
|
||||||
|
@@ -16,7 +16,8 @@ import TopToolbar from './top-toolbar';
|
|||||||
const propTypes = {
|
const propTypes = {
|
||||||
onShowSidePanel: PropTypes.func,
|
onShowSidePanel: PropTypes.func,
|
||||||
onSearchedClick: PropTypes.func,
|
onSearchedClick: PropTypes.func,
|
||||||
inAllLibs: PropTypes.bool
|
inAllLibs: PropTypes.bool,
|
||||||
|
repoList: PropTypes.array,
|
||||||
};
|
};
|
||||||
|
|
||||||
class PublicSharedView extends React.Component {
|
class PublicSharedView extends React.Component {
|
||||||
@@ -35,10 +36,10 @@ class PublicSharedView extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
seafileAPI.listRepos({type: 'public'}).then((res) => {
|
if (!this.props.repoList) {
|
||||||
let repoList = res.data.repos.map(item => {
|
seafileAPI.listRepos({type:'public'}).then((res) => {
|
||||||
let repo = new Repo(item);
|
let repoList = res.data.repos.map((item) => {
|
||||||
return repo;
|
return new Repo(item);
|
||||||
});
|
});
|
||||||
this.setState({
|
this.setState({
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
@@ -47,9 +48,15 @@ class PublicSharedView extends React.Component {
|
|||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
isLoading: false,
|
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) => {
|
onItemUnshare = (repo) => {
|
||||||
|
Reference in New Issue
Block a user