From 27d30f1a619ff716e39d79e7322c487e1299b75d Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sat, 28 Jan 2017 13:59:58 -0200 Subject: [PATCH 1/3] Notifying on open PR, and Close/Reopen/Merge issue or PR --- routers/repo/issue.go | 2 ++ routers/repo/pull.go | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 6ef34746e..7ae614038 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -875,6 +875,8 @@ func NewComment(ctx *context.Context, form auth.CreateCommentForm) { log.Error(4, "ChangeStatus: %v", err) } else { log.Trace("Issue [%d] status changed to closed: %v", issue.ID, issue.IsClosed) + + notification.Service.NotifyIssue(issue, ctx.User.ID) } } } diff --git a/routers/repo/pull.go b/routers/repo/pull.go index f0162cca0..f518c9edc 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -16,7 +16,9 @@ import ( "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/notification" "code.gitea.io/gitea/modules/setting" + "github.com/Unknwon/com" ) @@ -415,6 +417,8 @@ func MergePullRequest(ctx *context.Context) { return } + notification.Service.NotifyIssue(pr.Issue, ctx.User.ID) + log.Trace("Pull request merged: %d", pr.ID) ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index)) } @@ -707,6 +711,8 @@ func CompareAndPullRequestPost(ctx *context.Context, form auth.CreateIssueForm) return } + notification.Service.NotifyIssue(pullIssue, ctx.User.ID) + log.Trace("Pull request created: %d/%d", repo.ID, pullIssue.ID) ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pullIssue.Index)) } From 5348e8b71ab42ae04c59b70b5225035bfe05b0a0 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sat, 28 Jan 2017 14:01:07 -0200 Subject: [PATCH 2/3] Fix color: closed PR was showing as purple instead of red --- models/issue.go | 15 +++++++++--- public/css/index.css | 9 ++++--- public/less/_user.less | 24 ++++++++++--------- templates/user/notification/notification.tmpl | 12 ++++++---- 4 files changed, 37 insertions(+), 23 deletions(-) diff --git a/models/issue.go b/models/issue.go index cb5f8bb06..6d557ad4e 100644 --- a/models/issue.go +++ b/models/issue.go @@ -93,6 +93,16 @@ func (issue *Issue) loadRepo(e Engine) (err error) { return nil } +// GetPullRequest returns the issue pull request +func (issue *Issue) GetPullRequest() (pr *PullRequest, err error) { + if !issue.IsPull { + return nil, fmt.Errorf("Issue is not a pull request") + } + + pr, err = getPullRequestByIssueID(x, issue.ID) + return +} + func (issue *Issue) loadAttributes(e Engine) (err error) { if err := issue.loadRepo(e); err != nil { return err @@ -953,9 +963,9 @@ func Issues(opts *IssuesOptions) ([]*Issue, error) { switch opts.IsPull { case util.OptionalBoolTrue: - sess.And("issue.is_pull=?",true) + sess.And("issue.is_pull=?", true) case util.OptionalBoolFalse: - sess.And("issue.is_pull=?",false) + sess.And("issue.is_pull=?", false) } sortIssuesSession(sess, opts.SortType) @@ -1780,4 +1790,3 @@ func DeleteMilestoneByRepoID(repoID, id int64) error { } return sess.Commit() } - diff --git a/public/css/index.css b/public/css/index.css index c636d17d5..1bb9e9fd4 100644 --- a/public/css/index.css +++ b/public/css/index.css @@ -2726,17 +2726,16 @@ footer .ui.language .menu { .user.notification table tr { cursor: pointer; } -.user.notification .octicon-issue-opened, -.user.notification .octicon-git-pull-request { +.user.notification .octicon.green { color: #21ba45; } -.user.notification .octicon-issue-closed { +.user.notification .octicon.red { color: #d01919; } -.user.notification .octicon-git-merge { +.user.notification .octicon.purple { color: #a333c8; } -.user.notification .octicon-pin { +.user.notification .octicon.blue { color: #2185d0; } .dashboard { diff --git a/public/less/_user.less b/public/less/_user.less index d63b9b3de..5411c1d06 100644 --- a/public/less/_user.less +++ b/public/less/_user.less @@ -99,17 +99,19 @@ } } - .octicon-issue-opened, .octicon-git-pull-request { - color: #21ba45; - } - .octicon-issue-closed { - color: #d01919; - } - .octicon-git-merge { - color: #a333c8; - } - .octicon-pin { - color: #2185d0; + .octicon { + &.green { + color: #21ba45; + } + &.red { + color: #d01919; + } + &.purple { + color: #a333c8; + } + &.blue { + color: #2185d0; + } } } } diff --git a/templates/user/notification/notification.tmpl b/templates/user/notification/notification.tmpl index 04f3bf5a0..eb09c21ff 100644 --- a/templates/user/notification/notification.tmpl +++ b/templates/user/notification/notification.tmpl @@ -40,15 +40,19 @@ {{else if $issue.IsPull}} {{if $issue.IsClosed}} - + {{if $issue.GetPullRequest.HasMerged}} + + {{else}} + + {{end}} {{else}} - + {{end}} {{else}} {{if $issue.IsClosed}} - + {{else}} - + {{end}} {{end}} From aa591317e7085185f754b6a6b998c87ef6467f6e Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sat, 28 Jan 2017 14:11:49 -0200 Subject: [PATCH 3/3] Small UI fixes --- templates/user/notification/notification.tmpl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/templates/user/notification/notification.tmpl b/templates/user/notification/notification.tmpl index eb09c21ff..6d975a934 100644 --- a/templates/user/notification/notification.tmpl +++ b/templates/user/notification/notification.tmpl @@ -56,13 +56,15 @@ {{end}} {{end}} - + #{{$issue.Index}} - {{$issue.Title}} - {{$repoOwner.Name}}/{{$repo.Name}} + + {{$repoOwner.Name}}/{{$repo.Name}} + {{if ne $notification.Status 3}}