mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-09 15:05:50 +01:00
Merge pull request #1638 from gitbucket/feature/repository-header-plugin
Add repositoryHeaderComponent extension point
This commit is contained in:
@@ -121,6 +121,16 @@ abstract class Plugin {
|
||||
*/
|
||||
def pullRequestHooks(registry: PluginRegistry, context: ServletContext, settings: SystemSettings): Seq[PullRequestHook] = Nil
|
||||
|
||||
/**
|
||||
* Override to add repository headers.
|
||||
*/
|
||||
val repositoryHeaders: Seq[(RepositoryInfo, Context) => Option[Html]] = Nil
|
||||
|
||||
/**
|
||||
* Override to add repository headers.
|
||||
*/
|
||||
def repositoryHeaders(registry: PluginRegistry, context: ServletContext, settings: SystemSettings): Seq[(RepositoryInfo, Context) => Option[Html]] = Nil
|
||||
|
||||
/**
|
||||
* Override to add global menus.
|
||||
*/
|
||||
@@ -266,6 +276,9 @@ abstract class Plugin {
|
||||
(pullRequestHooks ++ pullRequestHooks(registry, context, settings)).foreach { pullRequestHook =>
|
||||
registry.addPullRequestHook(pullRequestHook)
|
||||
}
|
||||
(repositoryHeaders ++ repositoryHeaders(registry, context, settings)).foreach { repositoryHeader =>
|
||||
registry.addRepositoryHeader(repositoryHeader)
|
||||
}
|
||||
(globalMenus ++ globalMenus(registry, context, settings)).foreach { globalMenu =>
|
||||
registry.addGlobalMenu(globalMenu)
|
||||
}
|
||||
@@ -287,8 +300,8 @@ abstract class Plugin {
|
||||
(dashboardTabs ++ dashboardTabs(registry, context, settings)).foreach { dashboardTab =>
|
||||
registry.addDashboardTab(dashboardTab)
|
||||
}
|
||||
(issueSidebars ++ issueSidebars(registry, context, settings)).foreach { issueSidebar =>
|
||||
registry.addIssueSidebar(issueSidebar)
|
||||
(issueSidebars ++ issueSidebars(registry, context, settings)).foreach { issueSidebarComponent =>
|
||||
registry.addIssueSidebar(issueSidebarComponent)
|
||||
}
|
||||
(assetsMappings ++ assetsMappings(registry, context, settings)).foreach { assetMapping =>
|
||||
registry.addAssetsMapping((assetMapping._1, assetMapping._2, getClass.getClassLoader))
|
||||
|
||||
@@ -44,6 +44,7 @@ class PluginRegistry {
|
||||
private val pullRequestHooks = new ListBuffer[PullRequestHook]
|
||||
pullRequestHooks += new gitbucket.core.util.Notifier.PullRequestHook()
|
||||
|
||||
private val repositoryHeaders = new ListBuffer[(RepositoryInfo, Context) => Option[Html]]
|
||||
private val globalMenus = new ListBuffer[(Context) => Option[Link]]
|
||||
private val repositoryMenus = new ListBuffer[(RepositoryInfo, Context) => Option[Link]]
|
||||
private val repositorySettingTabs = new ListBuffer[(RepositoryInfo, Context) => Option[Link]]
|
||||
@@ -128,6 +129,10 @@ class PluginRegistry {
|
||||
|
||||
def getPullRequestHooks: Seq[PullRequestHook] = pullRequestHooks.toSeq
|
||||
|
||||
def addRepositoryHeader(repositoryHeader: (RepositoryInfo, Context) => Option[Html]): Unit = repositoryHeaders += repositoryHeader
|
||||
|
||||
def getRepositoryHeaders: Seq[(RepositoryInfo, Context) => Option[Html]] = repositoryHeaders.toSeq
|
||||
|
||||
def addGlobalMenu(globalMenu: (Context) => Option[Link]): Unit = globalMenus += globalMenu
|
||||
|
||||
def getGlobalMenus: Seq[(Context) => Option[Link]] = globalMenus.toSeq
|
||||
|
||||
@@ -148,8 +148,8 @@
|
||||
<input type="hidden" name="assignedUserName" value=""/>
|
||||
}
|
||||
@issue.map { issue =>
|
||||
@gitbucket.core.plugin.PluginRegistry().getIssueSidebars.map { sidebar =>
|
||||
@sidebar(issue, repository, context)
|
||||
@gitbucket.core.plugin.PluginRegistry().getIssueSidebars.map { sidebarComponent =>
|
||||
@sidebarComponent(issue, repository, context)
|
||||
}
|
||||
<hr/>
|
||||
<div style="margin-bottom: 14px;">
|
||||
|
||||
@@ -74,6 +74,11 @@
|
||||
@gitbucket.core.helper.html.information(info)
|
||||
@gitbucket.core.helper.html.error(error)
|
||||
<div class="head">
|
||||
<div class="pull-right">
|
||||
@gitbucket.core.plugin.PluginRegistry().getRepositoryHeaders.map { repositoryHeaderComponent =>
|
||||
@repositoryHeaderComponent(repository, context)
|
||||
}
|
||||
</div>
|
||||
@gitbucket.core.helper.html.repositoryicon(repository, true)
|
||||
<a href="@helpers.url(repository.owner)">@repository.owner</a> / <a href="@helpers.url(repository)" class="strong">@repository.name</a>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user