Skip to content

Commit ab24a72

Browse files
committed
Display the reason label of issue notifications.
1 parent 0de03b9 commit ab24a72

File tree

4 files changed

+21
-13
lines changed

4 files changed

+21
-13
lines changed

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ scalaVersion := "2.12.2"
77
lazy val root = (project in file(".")).enablePlugins(SbtTwirl)
88

99
libraryDependencies ++= Seq(
10-
"io.github.gitbucket" %% "gitbucket" % "4.14.0-SNAPSHOT" % "provided",
10+
"io.github.gitbucket" %% "gitbucket" % "4.15.0-SNAPSHOT" % "provided",
1111
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided"
1212
)
1313

src/main/scala/Plugin.scala

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import gitbucket.core.model.Issue
33
import gitbucket.core.plugin.Link
44
import gitbucket.core.service.RepositoryService.RepositoryInfo
55
import gitbucket.core.util.Implicits.request2Session
6-
import gitbucket.notifications.controller._
7-
import gitbucket.notifications.service._
6+
import gitbucket.notifications._
87
import io.github.gitbucket.solidbase.migration.LiquibaseMigration
98
import io.github.gitbucket.solidbase.model.Version
109

@@ -23,13 +22,13 @@ class Plugin extends gitbucket.core.plugin.Plugin {
2322
)
2423

2524
override val controllers = Seq(
26-
"/*" -> new NotificationsController()
25+
"/*" -> new controller.NotificationsController()
2726
)
2827

29-
override val accountHooks = Seq(new AccountHook)
30-
override val repositoryHooks = Seq(new RepositoryHook)
31-
override val issueHooks = Seq(new IssueHook)
32-
override val pullRequestHooks = Seq(new PullRequestHook)
28+
override val accountHooks = Seq(new service.AccountHook)
29+
override val repositoryHooks = Seq(new service.RepositoryHook)
30+
override val issueHooks = Seq(new service.IssueHook)
31+
override val pullRequestHooks = Seq(new service.PullRequestHook)
3332

3433
override val repositoryMenus = Seq(
3534
(repository: RepositoryInfo, context: Context) =>
@@ -46,8 +45,8 @@ class Plugin extends gitbucket.core.plugin.Plugin {
4645
context.loginAccount map { account =>
4746
implicit val session = request2Session(context.request)
4847

49-
gitbucket.notifications.html.issue(
50-
gitbucket.notifications.view.helpers.getNotificationUsers(issue).contains(account.userName),
48+
html.issue(
49+
view.helpers.getNotificationUsers(issue).contains(account.userName),
5150
issue,
5251
repository)(context)
5352
}

src/main/scala/gitbucket/notifications/service/NotificationsService.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ trait NotificationsService {
7979
notifications.withFilter(!_.subscribed).map(_.notificationUserName)
8080
)
8181
).foldLeft[List[String]](Nil){ case (res, (add, remove)) =>
82-
(add ++ res) diff remove
83-
}.distinct
82+
(add ++ res).distinct diff remove
83+
}
8484

8585
}
8686

src/main/twirl/gitbucket/notifications/issue.scala.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,27 @@
1414
}
1515
</div>
1616
</div>
17+
<span id="label-issue-notification">
18+
@if(subscribed){
19+
<span class="muted small">You’re receiving notifications.</span>
20+
} else {
21+
<span class="muted small">You’re not receiving notifications.</span>
22+
}
23+
</span>
1724
<script>
1825
$(function(){
1926
$('.issue-notification').click(function(){
2027
var $this = $(this);
2128
var subscribed = $this.data('subscribed');
2229
$.post('@helpers.url(repository)/issues/@issue.issueId/notification',
23-
{ subscribed : subscribed },
30+
{ 'subscribed' : subscribed },
2431
function(){
2532
if(subscribed == 'false'){
2633
$this.val('Subscribe').data('subscribed', 'true');
34+
$('#label-issue-notification').html($('<span class="muted small">').text('You’re not receiving notifications.'));
2735
} else {
2836
$this.val('Unsubscribe').data('subscribed', 'false');
37+
$('#label-issue-notification').html($('<span class="muted small">').text('You’re receiving notifications.'));
2938
}
3039
}
3140
);

0 commit comments

Comments
 (0)