mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-07 14:05:52 +01:00
(refs #32)Add deleting installed plugins
This commit is contained in:
@@ -3,9 +3,11 @@ package app
|
|||||||
import service.{AccountService, SystemSettingsService}
|
import service.{AccountService, SystemSettingsService}
|
||||||
import SystemSettingsService._
|
import SystemSettingsService._
|
||||||
import util.AdminAuthenticator
|
import util.AdminAuthenticator
|
||||||
|
import util.Directory._
|
||||||
import jp.sf.amateras.scalatra.forms._
|
import jp.sf.amateras.scalatra.forms._
|
||||||
import ssh.SshServer
|
import ssh.SshServer
|
||||||
import org.scalatra.Ok
|
import org.scalatra.Ok
|
||||||
|
import org.apache.commons.io.FileUtils
|
||||||
|
|
||||||
class SystemSettingsController extends SystemSettingsControllerBase
|
class SystemSettingsController extends SystemSettingsControllerBase
|
||||||
with AccountService with AdminAuthenticator
|
with AccountService with AdminAuthenticator
|
||||||
@@ -48,6 +50,11 @@ trait SystemSettingsControllerBase extends ControllerBase {
|
|||||||
} else Nil
|
} else Nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val pluginForm = mapping(
|
||||||
|
"pluginId" -> list(trim(label("", text())))
|
||||||
|
)(PluginForm.apply)
|
||||||
|
|
||||||
|
case class PluginForm(pluginIds: List[String])
|
||||||
|
|
||||||
get("/admin/system")(adminOnly {
|
get("/admin/system")(adminOnly {
|
||||||
admin.html.system(flash.get("info"))
|
admin.html.system(flash.get("info"))
|
||||||
@@ -76,6 +83,22 @@ trait SystemSettingsControllerBase extends ControllerBase {
|
|||||||
admin.html.plugins(plugin.PluginSystem.plugins)
|
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 {
|
get("/admin/script")(adminOnly {
|
||||||
admin.html.script()
|
admin.html.script()
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,19 +3,32 @@
|
|||||||
@import view.helpers._
|
@import view.helpers._
|
||||||
@html.main("Plugins"){
|
@html.main("Plugins"){
|
||||||
@menu("plugins"){
|
@menu("plugins"){
|
||||||
<table class="table table-bordered">
|
<form action="@path/admin/plugins/_delete" method="POST" validate="true">
|
||||||
<tr>
|
<table class="table table-bordered">
|
||||||
<th>ID</th>
|
|
||||||
<th>Provider</th>
|
|
||||||
<th>Description</th>
|
|
||||||
</tr>
|
|
||||||
@plugins.map { plugin =>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>@plugin.id</td>
|
<th>ID</th>
|
||||||
<td><a href="@plugin.url">@plugin.author</a></td>
|
<th>Provider</th>
|
||||||
<td>@plugin.description</td>
|
<th>Description</th>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
@plugins.zipWithIndex.map { case (plugin, i) =>
|
||||||
</table>
|
<tr>
|
||||||
|
<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