Skip to content

Notifications step 5 #781

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions models/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -1780,4 +1790,3 @@ func DeleteMilestoneByRepoID(repoID, id int64) error {
}
return sess.Commit()
}

9 changes: 4 additions & 5 deletions public/css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
24 changes: 13 additions & 11 deletions public/less/_user.less
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}
2 changes: 2 additions & 0 deletions routers/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions routers/repo/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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))
}
Expand Down Expand Up @@ -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))
}
Expand Down
18 changes: 12 additions & 6 deletions templates/user/notification/notification.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,31 @@
<i class="blue octicon octicon-pin"></i>
{{else if $issue.IsPull}}
{{if $issue.IsClosed}}
<i class="octicon octicon-git-merge"></i>
{{if $issue.GetPullRequest.HasMerged}}
<i class="purple octicon octicon-git-merge"></i>
{{else}}
<i class="red octicon octicon-git-pull-request"></i>
{{end}}
{{else}}
<i class="octicon octicon-git-pull-request"></i>
<i class="green octicon octicon-git-pull-request"></i>
{{end}}
{{else}}
{{if $issue.IsClosed}}
<i class="octicon octicon-issue-closed"></i>
<i class="red octicon octicon-issue-closed"></i>
{{else}}
<i class="octicon octicon-issue-opened"></i>
<i class="green octicon octicon-issue-opened"></i>
{{end}}
{{end}}
</td>
<td class="twelve wide">
<td class="eleven wide">
<a class="item" href="{{AppSubUrl}}/{{$repoOwner.Name}}/{{$repo.Name}}/issues/{{$issue.Index}}">
#{{$issue.Index}} - {{$issue.Title}}
</a>
</td>
<td>
{{$repoOwner.Name}}/{{$repo.Name}}
<a class="item" href="{{AppSubUrl}}/{{$repoOwner.Name}}/{{$repo.Name}}">
{{$repoOwner.Name}}/{{$repo.Name}}
</a>
</td>
<td class="collapsing">
{{if ne $notification.Status 3}}
Expand Down