mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-07 14:05:52 +01:00
(refs #32)Add plugins page into the system admin tools
This commit is contained in:
@@ -72,6 +72,10 @@ trait SystemSettingsControllerBase extends ControllerBase {
|
|||||||
redirect("/admin/system")
|
redirect("/admin/system")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
get("/admin/plugins")(adminOnly {
|
||||||
|
admin.html.plugins(plugin.PluginSystem.plugins)
|
||||||
|
})
|
||||||
|
|
||||||
get("/admin/script")(adminOnly {
|
get("/admin/script")(adminOnly {
|
||||||
admin.html.script()
|
admin.html.script()
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -14,20 +14,22 @@ object PluginSystem {
|
|||||||
|
|
||||||
private val logger = LoggerFactory.getLogger(PluginSystem.getClass)
|
private val logger = LoggerFactory.getLogger(PluginSystem.getClass)
|
||||||
|
|
||||||
private val plugins = scala.collection.mutable.Map[String, Plugin]()
|
private val pluginsMap = scala.collection.mutable.Map[String, Plugin]()
|
||||||
|
|
||||||
def install(id: String, plugin: Plugin): Unit = {
|
def install(plugin: Plugin): Unit = {
|
||||||
plugins.put(id, plugin)
|
pluginsMap.put(plugin.id, plugin)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def plugins: List[Plugin] = pluginsMap.values.toList
|
||||||
|
|
||||||
def uninstall(id: String): Unit = {
|
def uninstall(id: String): Unit = {
|
||||||
plugins.remove(id)
|
pluginsMap.remove(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
def repositoryMenus : List[RepositoryMenu] = plugins.values.flatMap(_.repositoryMenuList).toList
|
def repositoryMenus : List[RepositoryMenu] = pluginsMap.values.flatMap(_.repositoryMenuList).toList
|
||||||
def globalMenus : List[GlobalMenu] = plugins.values.flatMap(_.globalMenuList).toList
|
def globalMenus : List[GlobalMenu] = pluginsMap.values.flatMap(_.globalMenuList).toList
|
||||||
def repositoryActions : List[Action] = plugins.values.flatMap(_.repositoryActionList).toList
|
def repositoryActions : List[Action] = pluginsMap.values.flatMap(_.repositoryActionList).toList
|
||||||
def globalActions : List[Action] = plugins.values.flatMap(_.globalActionList).toList
|
def globalActions : List[Action] = pluginsMap.values.flatMap(_.globalActionList).toList
|
||||||
|
|
||||||
// Case classes to hold plug-ins information internally in GitBucket
|
// Case classes to hold plug-ins information internally in GitBucket
|
||||||
case class GlobalMenu(label: String, url: String, icon: String, condition: Context => Boolean)
|
case class GlobalMenu(label: String, url: String, icon: String, condition: Context => Boolean)
|
||||||
@@ -37,7 +39,7 @@ object PluginSystem {
|
|||||||
/**
|
/**
|
||||||
* This is a plug-in definition class.
|
* This is a plug-in definition class.
|
||||||
*/
|
*/
|
||||||
class Plugin {
|
class Plugin(val id: String, val author: String, val url: String, val description: String) {
|
||||||
|
|
||||||
private[PluginSystem] val repositoryMenuList = ListBuffer[RepositoryMenu]()
|
private[PluginSystem] val repositoryMenuList = ListBuffer[RepositoryMenu]()
|
||||||
private[PluginSystem] val globalMenuList = ListBuffer[GlobalMenu]()
|
private[PluginSystem] val globalMenuList = ListBuffer[GlobalMenu]()
|
||||||
|
|||||||
@@ -11,6 +11,9 @@
|
|||||||
<li@if(active=="system"){ class="active"}>
|
<li@if(active=="system"){ class="active"}>
|
||||||
<a href="@path/admin/system">System Settings</a>
|
<a href="@path/admin/system">System Settings</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li@if(active=="plugins"){ class="active"}>
|
||||||
|
<a href="@path/admin/plugins">Plugins</a>
|
||||||
|
</li>
|
||||||
<li@if(active=="script"){ class="active"}>
|
<li@if(active=="script"){ class="active"}>
|
||||||
<a href="@path/admin/script">JavaScript Console</a>
|
<a href="@path/admin/script">JavaScript Console</a>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
21
src/main/twirl/admin/plugins.scala.html
Normal file
21
src/main/twirl/admin/plugins.scala.html
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
@(plugins: List[plugin.PluginSystem.Plugin])(implicit context: app.Context)
|
||||||
|
@import context._
|
||||||
|
@import view.helpers._
|
||||||
|
@html.main("Plugins"){
|
||||||
|
@menu("plugins"){
|
||||||
|
<table class="table table-bordered">
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Provider</th>
|
||||||
|
<th>Description</th>
|
||||||
|
</tr>
|
||||||
|
@plugins.map { plugin =>
|
||||||
|
<tr>
|
||||||
|
<td>@plugin.id</td>
|
||||||
|
<td><a href="@plugin.url">@plugin.author</a></td>
|
||||||
|
<td>@plugin.description</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</table>
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="box-header">JavaScript Console</div>
|
<div class="box-header">JavaScript Console</div>
|
||||||
<div class="box-content">
|
<div class="box-content">
|
||||||
<div id="editor" style="width: 100%; height: 600px;"></div>
|
<div id="editor" style="width: 100%; height: 400px;"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
|
|||||||
Reference in New Issue
Block a user