mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-07 05:55:51 +01:00
(refs #32)Add deleting installed plugins
This commit is contained in:
@@ -3,9 +3,11 @@ package app
|
||||
import service.{AccountService, SystemSettingsService}
|
||||
import SystemSettingsService._
|
||||
import util.AdminAuthenticator
|
||||
import util.Directory._
|
||||
import jp.sf.amateras.scalatra.forms._
|
||||
import ssh.SshServer
|
||||
import org.scalatra.Ok
|
||||
import org.apache.commons.io.FileUtils
|
||||
|
||||
class SystemSettingsController extends SystemSettingsControllerBase
|
||||
with AccountService with AdminAuthenticator
|
||||
@@ -48,6 +50,11 @@ trait SystemSettingsControllerBase extends ControllerBase {
|
||||
} else Nil
|
||||
}
|
||||
|
||||
private val pluginForm = mapping(
|
||||
"pluginId" -> list(trim(label("", text())))
|
||||
)(PluginForm.apply)
|
||||
|
||||
case class PluginForm(pluginIds: List[String])
|
||||
|
||||
get("/admin/system")(adminOnly {
|
||||
admin.html.system(flash.get("info"))
|
||||
@@ -76,6 +83,22 @@ trait SystemSettingsControllerBase extends ControllerBase {
|
||||
admin.html.plugins(plugin.PluginSystem.plugins)
|
||||
})
|
||||
|
||||
post("/admin/plugins/_delete", pluginForm)(adminOnly { form =>
|
||||
// TODO uninstall and delete plugins
|
||||
println("****")
|
||||
println(form.pluginIds)
|
||||
println("****")
|
||||
|
||||
form.pluginIds.foreach { pluginId =>
|
||||
plugin.PluginSystem.uninstall(pluginId)
|
||||
val dir = new java.io.File(PluginHome, pluginId)
|
||||
if(dir.exists && dir.isDirectory){
|
||||
FileUtils.deleteQuietly(dir)
|
||||
}
|
||||
}
|
||||
redirect("/admin/plugins")
|
||||
})
|
||||
|
||||
get("/admin/script")(adminOnly {
|
||||
admin.html.script()
|
||||
})
|
||||
|
||||
@@ -3,19 +3,32 @@
|
||||
@import view.helpers._
|
||||
@html.main("Plugins"){
|
||||
@menu("plugins"){
|
||||
<form action="@path/admin/plugins/_delete" method="POST" validate="true">
|
||||
<table class="table table-bordered">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Provider</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
@plugins.map { plugin =>
|
||||
@plugins.zipWithIndex.map { case (plugin, i) =>
|
||||
<tr>
|
||||
<td>@plugin.id</td>
|
||||
<td>
|
||||
<input type="checkbox" name="pluginId[@i]" value="@plugin.id"/>
|
||||
@plugin.id
|
||||
</td>
|
||||
<td><a href="@plugin.url">@plugin.author</a></td>
|
||||
<td>@plugin.description</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
<input type="submit" id="delete-plugins" class="btn btn-danger" value="Uninstall selected plugins"/>
|
||||
</form>
|
||||
}
|
||||
}
|
||||
<script>
|
||||
$(function(){
|
||||
$('#delete-plugins').click(function(){
|
||||
return confirm('Selected plugin will be removed permanently. Are you sure?');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user