From 9820b8e1342017edfe4f6ced9cc3a7d811449c7b Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sat, 9 Aug 2014 10:29:51 -0700 Subject: [PATCH] Finish new hooks list page --- cmd/web.go | 4 +- conf/locale/locale_en-US.ini | 3 ++ conf/locale/locale_zh-CN.ini | 3 ++ gogs.go | 2 +- public/ng/css/gogs.css | 34 ++++++++++++++-- public/ng/css/ui.css | 5 +++ public/ng/less/gogs/base.less | 9 ++++ public/ng/less/gogs/repository.less | 4 ++ public/ng/less/gogs/settings.less | 61 +++++++++++++++------------- public/ng/less/ui/form.less | 5 +++ public/ng/less/ui/reset.less | 10 ++--- routers/repo/setting.go | 60 ++++----------------------- templates/.VERSION | 2 +- templates/repo/hooks.tmpl | 33 --------------- templates/repo/settings/hooks.tmpl | 35 ++++++++++++++++ templates/user/settings/profile.tmpl | 34 ++++++++-------- templates/user/settings/sshkeys.tmpl | 8 ++-- 17 files changed, 167 insertions(+), 145 deletions(-) delete mode 100644 templates/repo/hooks.tmpl create mode 100644 templates/repo/settings/hooks.tmpl diff --git a/cmd/web.go b/cmd/web.go index 40ae760280..474e86b3e3 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -255,8 +255,8 @@ func runWeb(*cli.Context) { r.Post("/settings", bindIgnErr(auth.RepoSettingForm{}), repo.SettingsPost) m.Group("/settings", func(r *macaron.Router) { r.Route("/collaboration", "GET,POST", repo.SettingsCollaboration) - r.Get("/hooks", repo.WebHooks) - r.Get("/hooks/add", repo.WebHooksAdd) + r.Get("/hooks", repo.Webhooks) + r.Get("/hooks/new", repo.WebHooksAdd) r.Post("/hooks/add", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksAddPost) r.Get("/hooks/:id", repo.WebHooksEdit) r.Post("/hooks/:id", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksEditPost) diff --git a/conf/locale/locale_en-US.ini b/conf/locale/locale_en-US.ini index 5ecf913900..5e6974d2eb 100644 --- a/conf/locale/locale_en-US.ini +++ b/conf/locale/locale_en-US.ini @@ -178,6 +178,9 @@ settings.confirm_delete = Confirm Deletion settings.add_collaborator = Add New Collaborator settings.add_collaborator_success = New collaborator has been added. settings.remove_collaborator_success = Collaborator has been removed. +settings.add_webhook = Add Webhook +settings.hooks_desc = Webhooks allow external services to be notified when certain events happen on Gogs. When the specified events happen, we'll send a POST request to each of the URLs you provide. Learn more in our Webhooks Guide. +settings.remove_hook_success = Webhook has been removed. [org] org_name_holder = Organization Name diff --git a/conf/locale/locale_zh-CN.ini b/conf/locale/locale_zh-CN.ini index 4c65812523..2bacaa5a7e 100644 --- a/conf/locale/locale_zh-CN.ini +++ b/conf/locale/locale_zh-CN.ini @@ -178,6 +178,9 @@ settings.confirm_delete = 确认删除仓库 settings.add_collaborator = 增加新的协作者 settings.add_collaborator_success = 成功添加新的协作者! settings.remove_collaborator_success = 被操作的协作者已经被收回权限! +settings.add_webhook = 添加 Web 钩子 +settings.hooks_desc = Web 钩子允许您设定在 Gogs 上发生指定事件时对指定 URL 发送 POST 通知。查看 Webhooks 文档 获取更多信息。 +settings.remove_hook_success = Web 钩子删除成功! [org] org_name_holder = 组织名称 diff --git a/gogs.go b/gogs.go index d40f1a02d1..b8a4ec6cfd 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.4.7.0807 Alpha" +const APP_VER = "0.4.7.0809 Alpha" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/public/ng/css/gogs.css b/public/ng/css/gogs.css index 244d6531d6..e3eb4c8807 100644 --- a/public/ng/css/gogs.css +++ b/public/ng/css/gogs.css @@ -214,6 +214,15 @@ img.avatar-48 { cursor: pointer; font-weight: bold; } +.text-success { + color: #3c763d; +} +.text-blue { + color: #15c; +} +.text-red { + color: #DD4B39; +} .markdown { background-color: white; font-size: 16px; @@ -1297,6 +1306,10 @@ The register and sign-in page style position: relative; top: 5px; } +.setting-list { + width: 100%; + list-style: none; +} #setting-wrapper { padding-bottom: 100px; } @@ -1347,18 +1360,28 @@ The register and sign-in page style #user-profile-form .field { margin-bottom: 24px; } +#repo-hooks-panel, #user-ssh-panel { margin-bottom: 20px; } -#user-ssh-panel .switching-list { +#repo-hooks-panel .setting-list, +#user-ssh-panel .setting-list { background-color: #FFF; } -#user-ssh-panel .switching-list li { +#repo-hooks-panel .setting-list li, +#user-ssh-panel .setting-list li { padding: 8px 20px; + border-bottom: 1px solid #eaeaea; } -#user-ssh-panel .switching-list li.ssh:hover { +#repo-hooks-panel .setting-list li.ssh:hover, +#user-ssh-panel .setting-list li.ssh:hover { background-color: #ffffEE; } +#repo-hooks-panel .setting-list li i, +#user-ssh-panel .setting-list li i { + padding-right: 5px; +} +#repo-hooks-panel .active-icon, #user-ssh-panel .active-icon { width: 10px; height: 10px; @@ -1367,16 +1390,21 @@ The register and sign-in page style margin-right: 20px; margin-top: 10px; } +#repo-hooks-panel .ssh-content, #user-ssh-panel .ssh-content { margin-left: 24px; } +#repo-hooks-panel .ssh-content .octicon, #user-ssh-panel .ssh-content .octicon { margin-right: 4px; } +#repo-hooks-panel .ssh-content .print, #user-ssh-panel .ssh-content .print, +#repo-hooks-panel .ssh-content .activity, #user-ssh-panel .ssh-content .activity { color: #888; } +#repo-hooks-panel .ssh-delete-btn, #user-ssh-panel .ssh-delete-btn { margin-top: 6px; } diff --git a/public/ng/css/ui.css b/public/ng/css/ui.css index d30e137dbc..df03818b71 100644 --- a/public/ng/css/ui.css +++ b/public/ng/css/ui.css @@ -427,6 +427,11 @@ dt { .btn-active { box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1) inset, 0 0 4px rgba(0, 0, 0, 0.15) inset; } +.btn-header { + margin-top: -1px; + color: white; + padding: 0 10px; +} .btn-radius { border-radius: .25em; } diff --git a/public/ng/less/gogs/base.less b/public/ng/less/gogs/base.less index 0cadabe869..8d22557a66 100644 --- a/public/ng/less/gogs/base.less +++ b/public/ng/less/gogs/base.less @@ -230,4 +230,13 @@ clear: both; cursor: pointer; font-weight: bold; } +} +.text-success { + color: #3c763d; +} +.text-blue { + color: #15c; +} +.text-red { + color: #DD4B39; } \ No newline at end of file diff --git a/public/ng/less/gogs/repository.less b/public/ng/less/gogs/repository.less index 1847c44e53..abc2f93874 100644 --- a/public/ng/less/gogs/repository.less +++ b/public/ng/less/gogs/repository.less @@ -469,4 +469,8 @@ .repo-user-list-block { position: relative; top: 5px; +} +.setting-list { + width: 100%; + list-style: none; } \ No newline at end of file diff --git a/public/ng/less/gogs/settings.less b/public/ng/less/gogs/settings.less index 076c30bb6b..c908af3b63 100644 --- a/public/ng/less/gogs/settings.less +++ b/public/ng/less/gogs/settings.less @@ -51,38 +51,43 @@ } } +#repo-hooks-panel, #user-ssh-panel { - margin-bottom: 20px; - .switching-list { - background-color: #FFF; - li { - padding: 8px 20px; - &.ssh:hover { - background-color: #ffffEE; - } + margin-bottom: 20px; + .setting-list { + background-color: #FFF; + li { + padding: 8px 20px; + border-bottom: 1px solid #eaeaea; + &.ssh:hover { + background-color: #ffffEE; + } + i { + padding-right: 5px; + } + } } - } - .active-icon { - width: 10px; - height: 10px; - border-radius: 6px; - padding: 0; - margin-right: 20px; - margin-top: 10px; - } - .ssh-content { - margin-left: 24px; - .octicon { - margin-right: 4px; + .active-icon { + width: 10px; + height: 10px; + border-radius: 6px; + padding: 0; + margin-right: 20px; + margin-top: 10px; } - .print, - .activity { - color: #888; + .ssh-content { + margin-left: 24px; + .octicon { + margin-right: 4px; + } + .print, + .activity { + color: #888; + } + } + .ssh-delete-btn { + margin-top: 6px; } - } - .ssh-delete-btn { - margin-top: 6px; - } } #user-ssh-add-form { diff --git a/public/ng/less/ui/form.less b/public/ng/less/ui/form.less index 017432935f..268baea882 100644 --- a/public/ng/less/ui/form.less +++ b/public/ng/less/ui/form.less @@ -75,6 +75,11 @@ .btn-active { box-shadow: 0 0 0 1px rgba(0, 0, 0, .1) inset, 0 0 4px rgba(0, 0, 0, .15) inset } +.btn-header { + margin-top: -1px; + color: white; + padding: 0 10px; +} .btn-radius { border-radius: .25em; diff --git a/public/ng/less/ui/reset.less b/public/ng/less/ui/reset.less index 04d1198969..af497ca14d 100644 --- a/public/ng/less/ui/reset.less +++ b/public/ng/less/ui/reset.less @@ -360,11 +360,11 @@ p { // truncate element .text-truncate { - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - display: inline-block; - vertical-align: top; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + display: inline-block; + vertical-align: top; } // code elements diff --git a/routers/repo/setting.go b/routers/repo/setting.go index 484cefb621..5867d161e4 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -23,8 +23,8 @@ import ( const ( SETTINGS_OPTIONS base.TplName = "repo/settings/options" COLLABORATION base.TplName = "repo/settings/collaboration" + HOOKS base.TplName = "repo/settings/hooks" - HOOKS base.TplName = "repo/hooks" HOOK_ADD base.TplName = "repo/hook_add" HOOK_EDIT base.TplName = "repo/hook_edit" ) @@ -215,69 +215,25 @@ func SettingsCollaboration(ctx *middleware.Context) { ctx.HTML(200, COLLABORATION) } -func SettingsCollaborationPost(ctx *middleware.Context) { - repoLink := strings.TrimPrefix(ctx.Repo.RepoLink, "/") - name := strings.ToLower(ctx.Query("collaborator")) - if len(name) == 0 || ctx.Repo.Owner.LowerName == name { - ctx.Redirect(ctx.Req.RequestURI) - return - } - has, err := models.HasAccess(name, repoLink, models.WRITABLE) - if err != nil { - ctx.Handle(500, "setting.CollaborationPost(HasAccess)", err) - return - } else if has { - ctx.Redirect(ctx.Req.RequestURI) - return - } +func Webhooks(ctx *middleware.Context) { + ctx.Data["Title"] = ctx.Tr("repo.settings") + ctx.Data["PageIsSettingsHooks"] = true - u, err := models.GetUserByName(name) - if err != nil { - if err == models.ErrUserNotExist { - ctx.Flash.Error("Given user does not exist.") - ctx.Redirect(ctx.Req.RequestURI) - } else { - ctx.Handle(500, "setting.CollaborationPost(GetUserByName)", err) - } - return - } - - if err = models.AddAccess(&models.Access{UserName: name, RepoName: repoLink, - Mode: models.WRITABLE}); err != nil { - ctx.Handle(500, "setting.CollaborationPost(AddAccess)", err) - return - } - - if setting.Service.EnableNotifyMail { - if err = mailer.SendCollaboratorMail(ctx.Render, u, ctx.User, ctx.Repo.Repository); err != nil { - ctx.Handle(500, "setting.CollaborationPost(SendCollaboratorMail)", err) - return - } - } - - ctx.Flash.Success("New collaborator has been added.") - ctx.Redirect(ctx.Req.RequestURI) -} - -func WebHooks(ctx *middleware.Context) { - ctx.Data["IsRepoToolbarWebHooks"] = true - ctx.Data["Title"] = strings.TrimPrefix(ctx.Repo.RepoLink, "/") + " - Webhooks" - - // Delete webhook. + // Delete web hook. remove := com.StrTo(ctx.Query("remove")).MustInt64() if remove > 0 { if err := models.DeleteWebhook(remove); err != nil { - ctx.Handle(500, "setting.WebHooks(DeleteWebhook)", err) + ctx.Handle(500, "DeleteWebhook", err) return } - ctx.Flash.Success("Webhook has been removed.") + ctx.Flash.Success(ctx.Tr("repo.settings.remove_hook_success")) ctx.Redirect(ctx.Repo.RepoLink + "/settings/hooks") return } ws, err := models.GetWebhooksByRepoId(ctx.Repo.Repository.Id) if err != nil { - ctx.Handle(500, "setting.WebHooks(GetWebhooksByRepoId)", err) + ctx.Handle(500, "GetWebhooksByRepoId", err) return } diff --git a/templates/.VERSION b/templates/.VERSION index 0621825f4b..760339a997 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.4.7.0807 Alpha \ No newline at end of file +0.4.7.0809 Alpha \ No newline at end of file diff --git a/templates/repo/hooks.tmpl b/templates/repo/hooks.tmpl deleted file mode 100644 index 85132e4b81..0000000000 --- a/templates/repo/hooks.tmpl +++ /dev/null @@ -1,33 +0,0 @@ -{{template "base/head" .}} -{{template "base/navbar" .}} -{{template "repo/nav" .}} -{{template "repo/toolbar" .}} -
- {{template "repo/setting_nav" .}} -
- {{template "base/alert" .}} -
-
- Webhooks -
-
-

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.
 

-
    - {{range .Webhooks}} -
  • - {{if .IsActive}}{{else}}{{end}} - {{.Url}} - - -
  • - {{end}} -
-
- -
- -
-
-{{template "base/footer" .}} \ No newline at end of file diff --git a/templates/repo/settings/hooks.tmpl b/templates/repo/settings/hooks.tmpl new file mode 100644 index 0000000000..7081e78f91 --- /dev/null +++ b/templates/repo/settings/hooks.tmpl @@ -0,0 +1,35 @@ +{{template "ng/base/head" .}} +{{template "ng/base/header" .}} +
+ {{template "repo/header" .}} +
+
+ {{template "repo/settings/nav" .}} +
+
+ {{template "ng/base/alert" .}} +
+
+
+ {{.i18n.Tr "repo.settings.add_webhook"}} + {{.i18n.Tr "repo.settings.hooks"}} +
+
    +
  • {{.i18n.Tr "repo.settings.hooks_desc" | Str2html}}
  • + {{range .Webhooks}} +
  • + {{if .IsActive}}{{else}}{{end}} + {{.Url}} + + +
  • + {{end}} +
+
+
+
+
+
+
+
+{{template "ng/base/footer" .}} \ No newline at end of file diff --git a/templates/user/settings/profile.tmpl b/templates/user/settings/profile.tmpl index 2d09975f4d..33e6a944d7 100644 --- a/templates/user/settings/profile.tmpl +++ b/templates/user/settings/profile.tmpl @@ -8,38 +8,40 @@ {{template "ng/base/alert" .}}
-

{{.i18n.Tr "settings.public_profile"}}

+
+ {{.i18n.Tr "settings.public_profile"}} +
{{.CsrfTokenHtml}} -

{{.i18n.Tr "settings.profile_desc"}}

-

+

{{.i18n.Tr "settings.profile_desc"}}
+
-

-

+

+
-

-

+

+
-

-

+

+
-

-

+

+
-

-

+

+
-

-

+

+
-

+
diff --git a/templates/user/settings/sshkeys.tmpl b/templates/user/settings/sshkeys.tmpl index 43dfb66e26..ed54cbf5b6 100644 --- a/templates/user/settings/sshkeys.tmpl +++ b/templates/user/settings/sshkeys.tmpl @@ -8,11 +8,11 @@ {{template "ng/base/alert" .}}
-

- +

+ {{.i18n.Tr "settings.add_key"}} {{.i18n.Tr "settings.manage_ssh_keys"}} -

-
+
  • {{.i18n.Tr "settings.ssh_desc"}}
  • {{range .Keys}}