diff --git a/src/main/scala/gitbucket/core/controller/AccountController.scala b/src/main/scala/gitbucket/core/controller/AccountController.scala index 9d45edb..1ac1a0d 100644 --- a/src/main/scala/gitbucket/core/controller/AccountController.scala +++ b/src/main/scala/gitbucket/core/controller/AccountController.scala @@ -317,10 +317,7 @@ get("/:userName/_hooks")(oneselfOnly { val userName = params("userName") getAccountByUserName(userName).map { account => - gitbucket.core.account.html.webhook(account, - if(account.isGroupAccount) Nil else getGroupsByUserName(userName), - getAccountWebHooks(account.userName) - ) + gitbucket.core.account.html.hooks(account, getAccountWebHooks(account.userName), flash.get("info")) } getOrElse NotFound() }) @@ -331,7 +328,7 @@ val userName = params("userName") getAccountByUserName(userName).map { account => val webhook = AccountWebHook(userName, "", WebHookContentType.FORM, None) - html.edithooks(webhook, Set(WebHook.Push), account, if (account.isGroupAccount) Nil else getGroupsByUserName(userName), flash.get("info"), true) + html.edithook(webhook, Set(WebHook.Push), account, true) } getOrElse NotFound() }) @@ -360,11 +357,11 @@ */ get("/:userName/_hooks/edit")(oneselfOnly { val userName = params("userName") - getAccountByUserName(userName).map { account => + getAccountByUserName(userName).flatMap { account => getAccountWebHook(userName, params("url")).map { case (webhook, events) => - html.edithooks(webhook, events, account, if (account.isGroupAccount) Nil else getGroupsByUserName(userName), flash.get("info"), false) - } getOrElse NotFound() - } + html.edithook(webhook, events, account, false) + } + } getOrElse NotFound() }) /** @@ -381,7 +378,7 @@ * Send the test request to registered account web hook URLs. */ ajaxPost("/:userName/_hooks/test")(oneselfOnly { - // TODO copied & pasted?? + // TODO Is it possible to merge with [[RepositorySettingsController.ajaxPost]]? import scala.concurrent.duration._ import scala.concurrent._ import scala.util.control.NonFatal diff --git a/src/main/scala/gitbucket/core/controller/RepositorySettingsController.scala b/src/main/scala/gitbucket/core/controller/RepositorySettingsController.scala index 93fee33..7b154ce 100644 --- a/src/main/scala/gitbucket/core/controller/RepositorySettingsController.scala +++ b/src/main/scala/gitbucket/core/controller/RepositorySettingsController.scala @@ -222,7 +222,7 @@ */ get("/:owner/:repository/settings/hooks/new")(ownerOnly { repository => val webhook = RepositoryWebHook(repository.owner, repository.name, "", WebHookContentType.FORM, None) - html.edithooks(webhook, Set(WebHook.Push), repository, flash.get("info"), true) + html.edithook(webhook, Set(WebHook.Push), repository, true) }) /** @@ -311,7 +311,7 @@ */ get("/:owner/:repository/settings/hooks/edit")(ownerOnly { repository => getWebHook(repository.owner, repository.name, params("url")).map{ case (webhook, events) => - html.edithooks(webhook, events, repository, flash.get("info"), false) + html.edithook(webhook, events, repository, false) } getOrElse NotFound() }) diff --git a/src/main/twirl/gitbucket/core/account/edithook.scala.html b/src/main/twirl/gitbucket/core/account/edithook.scala.html new file mode 100644 index 0000000..2b44ef1 --- /dev/null +++ b/src/main/twirl/gitbucket/core/account/edithook.scala.html @@ -0,0 +1,16 @@ +@(webHook: gitbucket.core.model.AccountWebHook, + events: Set[gitbucket.core.model.WebHook.Event], + account: gitbucket.core.model.Account, + create: Boolean)(implicit context: gitbucket.core.controller.Context) +@import gitbucket.core.view.helpers +@gitbucket.core.html.main("Service Hooks"){ + @gitbucket.core.account.html.menu("hooks", context.settings.ssh){ + @gitbucket.core.settings.html.edithookform( + webHook, events, create, + helpers.url(account.userName) + "/_hooks/new", + helpers.url(account.userName) + "/_hooks/edit", + helpers.url(account.userName) + "/_hooks/delete", + helpers.url(account.userName) + "/_hooks/test" + ) + } +} diff --git a/src/main/twirl/gitbucket/core/account/edithooks.scala.html b/src/main/twirl/gitbucket/core/account/edithooks.scala.html deleted file mode 100644 index f2a49cb..0000000 --- a/src/main/twirl/gitbucket/core/account/edithooks.scala.html +++ /dev/null @@ -1,195 +0,0 @@ -@(webHook: gitbucket.core.model.AccountWebHook, - events: Set[gitbucket.core.model.WebHook.Event], - account: gitbucket.core.model.Account, - groupNames: List[String], - info: Option[Any], - create: Boolean)(implicit context: gitbucket.core.controller.Context) -@import gitbucket.core.view.helpers -@import gitbucket.core.model.WebHook._ -@import gitbucket.core.model.WebHookContentType -@check(name: String, event: Event) = { - name="@(name).@event.name" value="on" @if(events(event)){checked} -} -@gitbucket.core.html.main("Service Hooks"){ - @gitbucket.core.account.html.menu("hooks", context.settings.ssh){ -
+ Webhooks allow external services to be notified when certain events happen within your repository. + When the specified events happen, we’ll send a POST request to each of the URLs you provide. + Learn more in GitBucket Wiki Webhook Page. +
+ Add webhook + ++ + @webHook.url + + (@events.map(_.name).mkString(", ")) + | + + |
- Webhooks allow external services to be notified when certain events happen within your repository. - When the specified events happen, we’ll send a POST request to each of the URLs you provide. - Learn more in GitBucket Wiki Webhook Page. -
- Add webhook - -- - @webHook.url - - (@events.map(_.name).mkString(", ")) - | - - |