mirror of
https://github.com/gitbucket/gitbucket.git
synced 2026-05-13 01:06:23 +02:00
(refs #2089)Fix the list of repositories on the sidebar
This commit is contained in:
@@ -22,13 +22,8 @@ trait DashboardControllerBase extends ControllerBase {
|
||||
self: IssuesService with PullRequestService with RepositoryService with AccountService with UsersAuthenticator =>
|
||||
|
||||
get("/dashboard/repos")(usersOnly {
|
||||
val userName = context.loginAccount.get.userName
|
||||
|
||||
html.repos(
|
||||
getGroupNames(userName),
|
||||
getVisibleRepositories(None, withoutPhysicalInfo = true),
|
||||
getUserRepositories(userName, withoutPhysicalInfo = true)
|
||||
)
|
||||
val repos = getVisibleRepositories(context.loginAccount, withoutPhysicalInfo = true)
|
||||
html.repos(getGroupNames(context.loginAccount.get.userName), repos, repos)
|
||||
})
|
||||
|
||||
get("/dashboard/issues")(usersOnly {
|
||||
@@ -93,7 +88,7 @@ trait DashboardControllerBase extends ControllerBase {
|
||||
},
|
||||
filter,
|
||||
getGroupNames(userName),
|
||||
getVisibleRepositories(None, withoutPhysicalInfo = true)
|
||||
getVisibleRepositories(context.loginAccount, withoutPhysicalInfo = true)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -118,7 +113,7 @@ trait DashboardControllerBase extends ControllerBase {
|
||||
},
|
||||
filter,
|
||||
getGroupNames(userName),
|
||||
getVisibleRepositories(None, withoutPhysicalInfo = true)
|
||||
getVisibleRepositories(context.loginAccount, withoutPhysicalInfo = true)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ trait IndexControllerBase extends ControllerBase {
|
||||
val visibleOwnerSet: Set[String] = Set(account.userName) ++ getGroupsByUserName(account.userName)
|
||||
gitbucket.core.html.index(
|
||||
getRecentActivitiesByOwners(visibleOwnerSet),
|
||||
getVisibleRepositories(None, withoutPhysicalInfo = true),
|
||||
getVisibleRepositories(Some(account), withoutPhysicalInfo = true),
|
||||
showBannerToCreatePersonalAccessToken = hasAccountFederation(account.userName) && !hasAccessToken(
|
||||
account.userName
|
||||
)
|
||||
|
||||
@@ -371,6 +371,10 @@ trait RepositoryService { self: AccountService =>
|
||||
.list
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of repositories which are owned by the specified user.
|
||||
* This list includes group repositories if the specified user is a member of the group.
|
||||
*/
|
||||
def getUserRepositories(userName: String, withoutPhysicalInfo: Boolean = false)(
|
||||
implicit s: Session
|
||||
): List[RepositoryInfo] = {
|
||||
@@ -388,29 +392,7 @@ trait RepositoryService { self: AccountService =>
|
||||
}
|
||||
.sortBy(_.lastActivityDate desc)
|
||||
.list
|
||||
.map { repository =>
|
||||
new RepositoryInfo(
|
||||
if (withoutPhysicalInfo) {
|
||||
new JGitUtil.RepositoryInfo(repository.userName, repository.repositoryName)
|
||||
} else {
|
||||
JGitUtil.getRepositoryInfo(repository.userName, repository.repositoryName)
|
||||
},
|
||||
repository,
|
||||
if (withoutPhysicalInfo) {
|
||||
-1
|
||||
} else {
|
||||
getForkedCount(
|
||||
repository.originUserName.getOrElse(repository.userName),
|
||||
repository.originRepositoryName.getOrElse(repository.repositoryName)
|
||||
)
|
||||
},
|
||||
if (withoutPhysicalInfo) {
|
||||
Nil
|
||||
} else {
|
||||
getRepositoryManagers(repository.userName, repository.repositoryName)
|
||||
}
|
||||
)
|
||||
}
|
||||
.map(createRepositoryInfo(_, withoutPhysicalInfo))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -466,29 +448,33 @@ trait RepositoryService { self: AccountService =>
|
||||
}
|
||||
.sortBy(_.lastActivityDate desc)
|
||||
.list
|
||||
.map { repository =>
|
||||
new RepositoryInfo(
|
||||
if (withoutPhysicalInfo) {
|
||||
new JGitUtil.RepositoryInfo(repository.userName, repository.repositoryName)
|
||||
} else {
|
||||
JGitUtil.getRepositoryInfo(repository.userName, repository.repositoryName)
|
||||
},
|
||||
repository,
|
||||
if (withoutPhysicalInfo) {
|
||||
-1
|
||||
} else {
|
||||
getForkedCount(
|
||||
repository.originUserName.getOrElse(repository.userName),
|
||||
repository.originRepositoryName.getOrElse(repository.repositoryName)
|
||||
)
|
||||
},
|
||||
if (withoutPhysicalInfo) {
|
||||
Nil
|
||||
} else {
|
||||
getRepositoryManagers(repository.userName, repository.repositoryName)
|
||||
}
|
||||
.map(createRepositoryInfo(_, withoutPhysicalInfo))
|
||||
}
|
||||
|
||||
private def createRepositoryInfo(repository: Repository, withoutPhysicalInfo: Boolean = false)(
|
||||
implicit s: Session
|
||||
): RepositoryInfo = {
|
||||
new RepositoryInfo(
|
||||
if (withoutPhysicalInfo) {
|
||||
new JGitUtil.RepositoryInfo(repository.userName, repository.repositoryName)
|
||||
} else {
|
||||
JGitUtil.getRepositoryInfo(repository.userName, repository.repositoryName)
|
||||
},
|
||||
repository,
|
||||
if (withoutPhysicalInfo) {
|
||||
-1
|
||||
} else {
|
||||
getForkedCount(
|
||||
repository.originUserName.getOrElse(repository.userName),
|
||||
repository.originRepositoryName.getOrElse(repository.repositoryName)
|
||||
)
|
||||
},
|
||||
if (withoutPhysicalInfo) {
|
||||
Nil
|
||||
} else {
|
||||
getRepositoryManagers(repository.userName, repository.repositoryName)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
@(groups: List[String],
|
||||
recentRepositories: List[gitbucket.core.service.RepositoryService.RepositoryInfo],
|
||||
userRepositories: List[gitbucket.core.service.RepositoryService.RepositoryInfo])(implicit context: gitbucket.core.controller.Context)
|
||||
visibleRepositories: List[gitbucket.core.service.RepositoryService.RepositoryInfo],
|
||||
recentRepositories: List[gitbucket.core.service.RepositoryService.RepositoryInfo])(implicit context: gitbucket.core.controller.Context)
|
||||
@import gitbucket.core.view.helpers
|
||||
@gitbucket.core.html.main("Repositories"){
|
||||
@gitbucket.core.dashboard.html.sidebar(recentRepositories){
|
||||
@@ -13,15 +13,15 @@
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="javascript:void(0);" data-name=""><i class="octicon octicon-check"></i><span>All</span></a></li>
|
||||
@userRepositories.map(_.owner).distinct.map { userName =>
|
||||
@visibleRepositories.map(_.owner).distinct.map { userName =>
|
||||
<li><a href="javascript:void(0);" data-name="@userName"><i class="octicon"></i><span>@helpers.avatar(userName, 20) @userName</span></a></li>
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
@if(userRepositories.isEmpty){
|
||||
@if(visibleRepositories.isEmpty){
|
||||
No repositories
|
||||
} else {
|
||||
@userRepositories.map { repository =>
|
||||
@visibleRepositories.map { repository =>
|
||||
<div class="block" data-owner="@repository.owner">
|
||||
<div class="repository-icon">
|
||||
@gitbucket.core.helper.html.repositoryicon(repository, true)
|
||||
|
||||
Reference in New Issue
Block a user