mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-15 09:55:49 +01:00
Add the plugin reload button to the plugin list page
This commit is contained in:
@@ -181,9 +181,14 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
||||
})
|
||||
|
||||
get("/admin/plugins")(adminOnly {
|
||||
html.plugins(PluginRegistry().getPlugins())
|
||||
html.plugins(PluginRegistry().getPlugins(), flash.get("info"))
|
||||
})
|
||||
|
||||
post("/admin/plugins/_reload")(adminOnly {
|
||||
PluginRegistry.reload(request.getServletContext(), loadSystemSettings(), request2Session(request).conn)
|
||||
flash += "info" -> "All plugins are reloaded."
|
||||
redirect("/admin/plugins")
|
||||
})
|
||||
|
||||
get("/admin/users")(adminOnly {
|
||||
val includeRemoved = params.get("includeRemoved").map(_.toBoolean).getOrElse(false)
|
||||
|
||||
@@ -155,17 +155,26 @@ object PluginRegistry {
|
||||
|
||||
private val logger = LoggerFactory.getLogger(classOf[PluginRegistry])
|
||||
|
||||
private val instance = new PluginRegistry()
|
||||
private var instance = new PluginRegistry()
|
||||
|
||||
/**
|
||||
* Returns the PluginRegistry singleton instance.
|
||||
*/
|
||||
def apply(): PluginRegistry = instance
|
||||
|
||||
/**
|
||||
* Reload all plugins.
|
||||
*/
|
||||
def reload(context: ServletContext, settings: SystemSettings, conn: java.sql.Connection): Unit = synchronized {
|
||||
shutdown(context, settings)
|
||||
instance = new PluginRegistry()
|
||||
initialize(context, settings, conn)
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes all installed plugins.
|
||||
*/
|
||||
def initialize(context: ServletContext, settings: SystemSettings, conn: java.sql.Connection): Unit = {
|
||||
def initialize(context: ServletContext, settings: SystemSettings, conn: java.sql.Connection): Unit = synchronized {
|
||||
val pluginDir = new File(PluginHome)
|
||||
val manager = new JDBCVersionManager(conn)
|
||||
|
||||
@@ -207,7 +216,7 @@ object PluginRegistry {
|
||||
}
|
||||
}
|
||||
|
||||
def shutdown(context: ServletContext, settings: SystemSettings): Unit = {
|
||||
def shutdown(context: ServletContext, settings: SystemSettings): Unit = synchronized {
|
||||
instance.getPlugins().foreach { pluginInfo =>
|
||||
try {
|
||||
pluginInfo.pluginClass.shutdown(instance, context, settings)
|
||||
@@ -219,7 +228,6 @@ object PluginRegistry {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
case class Link(id: String, label: String, path: String, icon: Option[String] = None)
|
||||
|
||||
@@ -7,10 +7,10 @@ import gitbucket.core.plugin.PluginRegistry
|
||||
|
||||
class PluginControllerFilter extends Filter {
|
||||
|
||||
private var filterConfig: FilterConfig = null
|
||||
|
||||
override def init(filterConfig: FilterConfig): Unit = {
|
||||
PluginRegistry().getControllers().foreach { case (controller, _) =>
|
||||
controller.init(filterConfig)
|
||||
}
|
||||
this.filterConfig = filterConfig
|
||||
}
|
||||
|
||||
override def destroy(): Unit = {
|
||||
@@ -26,6 +26,9 @@ class PluginControllerFilter extends Filter {
|
||||
}
|
||||
|
||||
controller.map { case (controller, _) =>
|
||||
if(controller.config == null){
|
||||
controller.init(filterConfig)
|
||||
}
|
||||
controller.doFilter(request, response, chain)
|
||||
}.getOrElse{
|
||||
chain.doFilter(request, response)
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
@(plugins: List[gitbucket.core.plugin.PluginInfo])(implicit context: gitbucket.core.controller.Context)
|
||||
@(plugins: List[gitbucket.core.plugin.PluginInfo], info: Option[Any])(implicit context: gitbucket.core.controller.Context)
|
||||
@gitbucket.core.html.main("Plugins"){
|
||||
@gitbucket.core.admin.html.menu("plugins") {
|
||||
@gitbucket.core.helper.html.information(info)
|
||||
<h1>Installed plugins</h1>
|
||||
|
||||
<form action="@context.path/admin/plugins/_reload" method="POST" class="pull-right">
|
||||
<input type="submit" value="Reload plugins" class="btn btn-success">
|
||||
</form>
|
||||
@if(plugins.size > 0) {
|
||||
<ul>
|
||||
@plugins.map { plugin =>
|
||||
|
||||
Reference in New Issue
Block a user