]> source.dussan.org Git - gitea.git/commitdiff
add webhooks page ui
authorFuXiaoHei <fuxiaohei@hexiaz.com>
Fri, 2 May 2014 14:07:34 +0000 (22:07 +0800)
committerFuXiaoHei <fuxiaohei@hexiaz.com>
Fri, 2 May 2014 14:07:34 +0000 (22:07 +0800)
cmd/web.go
public/css/gogs.css
routers/repo/setting.go
templates/repo/hooks.tmpl [new file with mode: 0644]
templates/repo/hooks_add.tmpl [new file with mode: 0644]
templates/repo/setting_nav.tmpl

index af5d507edf1e57f428d4f8bbb732e8e7a3b4e45d..1e60501834e85edef3c3a1578a6e0d5199ea8179 100644 (file)
@@ -152,6 +152,8 @@ func runWeb(*cli.Context) {
                r.Post("/settings", repo.SettingPost)
                r.Get("/settings/collaboration", repo.Collaboration)
                r.Post("/settings/collaboration", repo.CollaborationPost)
+               r.Get("/settings/hooks", repo.WebHooks)
+               r.Get("/settings/hooks/add",repo.WebHooksAdd)
                r.Get("/action/:action", repo.Action)
                r.Get("/issues/new", repo.CreateIssue)
                r.Post("/issues/new", bindIgnErr(auth.CreateIssueForm{}), repo.CreateIssuePost)
index e84eb1ef14944af1e1e04ca445800dcacdf2131f..881860987d20bcdffe0acf191824c2819cdf600e 100755 (executable)
@@ -311,17 +311,17 @@ html, body {
     border-radius: 2px;
 }
 
-#user-name,#user-full-name {
+#user-name, #user-full-name {
     font-size: 1.6em;
     font-weight: bold;
 }
 
-#user-name{
+#user-name {
     margin-bottom: 20px;
     margin-top: 10px;
 }
 
-#user-full-name{
+#user-full-name {
     margin-top: 20px;
 }
 
@@ -446,7 +446,7 @@ html, body {
     border-left: 4px solid #DD4B39;
 }
 
-#repo-setting-container{
+#repo-setting-container {
     padding-right: 0;
 }
 
@@ -454,41 +454,41 @@ html, body {
     line-height: 30px;
 }
 
-#repo-collab-list li.collab{
+#repo-collab-list li.collab {
     margin-bottom: .6em;
 }
 
-#repo-collab-list .avatar{
+#repo-collab-list .avatar {
     margin-right: 1em;
     width: 40px;
 }
 
-#repo-collab-list a.member{
+#repo-collab-list a.member {
     color: #444;
 }
 
-#repo-collab-list .remove-collab{
+#repo-collab-list .remove-collab, #repo-hooks-list .remove-hook {
     color: #DD4B39;
 }
 
-#repo-collab-form .dropdown-menu{
+#repo-collab-form .dropdown-menu {
     margin-left: 15px;
     margin-top: 4px;
     padding: 0;
 }
 
-#repo-collab-form .dropdown-menu li{
+#repo-collab-form .dropdown-menu li {
     padding: 0 1em;
     line-height: 36px;
     cursor: pointer;
     font-weight: bold;
 }
 
-#repo-collab-form .dropdown-menu li:hover{
+#repo-collab-form .dropdown-menu li:hover {
     background-color: #e8f0ff;
 }
 
-#repo-collab-form .dropdown-menu img{
+#repo-collab-form .dropdown-menu img {
     width: 28px;
     height: 28px;
     margin-right: 1em;
@@ -496,10 +496,26 @@ html, body {
     margin-top: -3px;
 }
 
-#repo-collab-form .dropdown-menu ul{
+#repo-collab-form .dropdown-menu ul {
     margin-bottom: 0;
 }
 
+#repo-hooks-list li {
+    line-height: 40px;
+    border-top: 1px solid #DDD;
+    height: 40px;
+}
+
+#repo-hooks-list .link {
+    display: inline-block;
+    max-width: 360px;
+    overflow: hidden;
+    text-overflow: ellipsis;
+    height: 40px;
+    line-height: 40px;
+    white-space: nowrap;
+}
+
 /* gogits user ssh keys */
 
 #ssh-keys .list-group-item {
index 8f7b84b6944cfb692e33870a6dabc23c94de12c1..aee3fe3a1d4e295893d5018f19e37b3f9f959f81 100644 (file)
@@ -204,3 +204,25 @@ func CollaborationPost(ctx *middleware.Context) {
        ctx.Flash.Success("New collaborator has been added.")
        ctx.Redirect(ctx.Req.RequestURI)
 }
+
+func WebHooks(ctx *middleware.Context) {
+       if !ctx.Repo.IsOwner {
+               ctx.Handle(404, "repo.WebHooks", nil)
+               return
+       }
+
+       ctx.Data["IsRepoToolbarWebHooks"] = true
+       ctx.Data["Title"] = strings.TrimPrefix(ctx.Repo.RepoLink, "/") + " - Web Hooks"
+       ctx.HTML(200, "repo/hooks")
+}
+
+func WebHooksAdd(ctx *middleware.Context) {
+       if !ctx.Repo.IsOwner {
+               ctx.Handle(404, "repo.WebHooksAdd", nil)
+               return
+       }
+
+       ctx.Data["IsRepoToolbarWebHooks"] = true
+       ctx.Data["Title"] = strings.TrimPrefix(ctx.Repo.RepoLink, "/") + " - Add Web Hook"
+       ctx.HTML(200, "repo/hooks_add")
+}
diff --git a/templates/repo/hooks.tmpl b/templates/repo/hooks.tmpl
new file mode 100644 (file)
index 0000000..643686a
--- /dev/null
@@ -0,0 +1,37 @@
+{{template "base/head" .}}
+{{template "base/navbar" .}}
+{{template "repo/nav" .}}
+{{template "repo/toolbar" .}}
+<div id="body" class="container">
+    {{template "repo/setting_nav" .}}
+    <div id="repo-setting-container" class="col-md-10">
+        {{template "base/alert" .}}
+        <div class="panel panel-default">
+            <div class="panel-heading">
+                Webhooks
+            </div>
+            <div class="panel-body">
+                <p>Webhooks allow external services to be notified when certain events happen on GitHub. When the specified events happen, we'll send a POST request to each of the URLs you provide. Learn more in our Webhooks Guide.<br/>&nbsp;</p>
+                <ul id="repo-hooks-list" class="list-unstyled">
+                    <li>
+                        <span class="pull-left status text-success"><i class="fa fa-check"></i></span>
+                        <a class="link" href="#">https://inbox-app.wercker.com/commits/11aea6e535af5eefc2a29bc25a23e89a</a>
+                        <a href="{{$.RepoLink}}/settings/hooks?remove=" class="remove-hook pull-right"><i class="fa fa-times"></i></a>
+                        <a href="{{$.RepoLink}}/settings/hooks/id" class="edit-hook pull-right"><i class="fa fa-pencil"></i></a>
+                    </li>
+                    <li>
+                        <span class="pull-left status text-success"><i class="fa fa-check"></i></span>
+                        <a class="link" href="#">https://inbox-app.wercker.com/commits/11aea6e535af5eefc2a29bc25a23e89a</a>
+                        <a href="{{$.RepoLink}}/settings/hooks?remove=" class="remove-hook pull-right"><i class="fa fa-times"></i></a>
+                        <a href="{{$.RepoLink}}/settings/hooks/id" class="edit-hook pull-right"><i class="fa fa-pencil"></i></a>
+                    </li>
+                </ul>
+            </div>
+            <div class="panel-footer">
+                <a href="/{{.Owner.Name}}/{{.Repository.Name}}/settings/hooks/add"><button class="btn btn-primary">Add Webhook</button></a>
+            </div>
+        </div>
+
+    </div>
+</div>
+{{template "base/footer" .}}
\ No newline at end of file
diff --git a/templates/repo/hooks_add.tmpl b/templates/repo/hooks_add.tmpl
new file mode 100644 (file)
index 0000000..174036d
--- /dev/null
@@ -0,0 +1,57 @@
+{{template "base/head" .}}
+{{template "base/navbar" .}}
+{{template "repo/nav" .}}
+{{template "repo/toolbar" .}}
+<div id="body" class="container">
+    {{template "repo/setting_nav" .}}
+    <div id="repo-setting-container" class="col-md-10">
+        {{template "base/alert" .}}
+        <div class="panel panel-default">
+            <div class="panel-heading">
+                Add Webhook
+            </div>
+            <div class="panel-body">
+                <p>We’ll send a POST request to the URL below with details of any subscribed events.</p>
+                <hr/>
+                <form id="repo-hooks-add-form" action="/{{.Owner.Name}}/{{.Repository.Name}}/settings/hooks/add" method="post" class="col-md-7">
+                    <div class="form-group">
+                        <label for="payload-url">Payload URL</label>
+                        <input id="payload-url" class="form-control" type="url" required="required" name="url"/>
+                    </div>
+                    <div class="form-group">
+                        <label for="payload-version">Payload Version</label>
+                        <select name="version" id="payload-version" class="form-control">
+                            <option value="json">application/json</option>
+                        </select>
+                    </div>
+                    <div class="form-group">
+                        <label for="payload-secret">Secret</label>
+                        <input id="payload-secret" class="form-control" type="text" required="required" name="secret"/>
+                    </div>
+                    <hr/>
+                    <div class="form-group">
+                        <label>Which events would you like to trigger this webhook?</label>
+                        <div class="radio">
+                            <label>
+                                <input class="form-control" type="radio" value="push" name="trigger"/> Just the <i>push</i> event.
+                            </label>
+                        </div>
+                    </div>
+                    <hr/>
+                    <div class="form-group">
+                        <label>
+                            <input type="checkbox" name="active" value="Active" checked/>&nbsp;&nbsp;
+                            Active
+                        </label>
+                        <p class="help-block">We will deliver event details when this hook is triggered.</p>
+                    </div>
+                </form>
+            </div>
+            <div class="panel-footer">
+                <a href="/{{.Owner.Name}}/{{.Repository.Name}}/settings/hooks"><button class="btn btn-primary">Webhooks List</button></a>
+            </div>
+        </div>
+
+    </div>
+</div>
+{{template "base/footer" .}}
\ No newline at end of file
index 4e558a76efc6e3a922e96f8a6c59fcc374210f8a..489602b4cc82ab7a62fd287ee2b41229dbe6f951 100644 (file)
@@ -2,6 +2,6 @@
     <ul class="list-group">
         <li class="list-group-item{{if .IsRepoToolbarSetting}} active{{end}}"><a href="/{{.Owner.Name}}/{{.Repository.Name}}/settings">Options</a></li>
         <li class="list-group-item{{if .IsRepoToolbarCollaboration}} active{{end}}"><a href="/{{.Owner.Name}}/{{.Repository.Name}}/settings/collaboration">Collaborators</a></li>
-        <!--<li class="list-group-item"><a href="#">Notifications</a></li>-->
+        <li class="list-group-item{{if .IsRepoToolbarWebHooks}} active{{end}}"><a href="/{{.Owner.Name}}/{{.Repository.Name}}/settings/hooks">Webhooks</a></li>
     </ul>
 </div>
\ No newline at end of file