1
1
import gitbucket .core .controller .Context
2
2
import gitbucket .core .model .Issue
3
- import gitbucket .core .plugin . Link
3
+ import gitbucket .core .service .{ AccountService , IssuesService , RepositoryService }
4
4
import gitbucket .core .service .RepositoryService .RepositoryInfo
5
5
import gitbucket .core .util .Implicits .request2Session
6
6
import gitbucket .notifications ._
7
+ import gitbucket .notifications .model .Watch
8
+ import gitbucket .notifications .service .NotificationsService
7
9
import io .github .gitbucket .solidbase .migration .LiquibaseMigration
8
10
import io .github .gitbucket .solidbase .model .Version
9
11
10
- class Plugin extends gitbucket.core.plugin.Plugin {
12
+ class Plugin extends gitbucket.core.plugin.Plugin
13
+ with NotificationsService with RepositoryService with AccountService with IssuesService {
11
14
12
15
override val pluginId = " notifications"
13
16
@@ -30,14 +33,16 @@ class Plugin extends gitbucket.core.plugin.Plugin {
30
33
override val issueHooks = Seq (new service.IssueHook )
31
34
override val pullRequestHooks = Seq (new service.PullRequestHook )
32
35
33
- override val repositoryMenus = Seq (
34
- (repository : RepositoryInfo , context : Context ) =>
35
- Some (Link (
36
- id = " watch" ,
37
- label = " Watch" ,
38
- path = " /watch" ,
39
- icon = Some (" menu-icon octicon octicon-eye" )
40
- ))
36
+ override val repositoryHeaders = Seq (
37
+ (repository : RepositoryInfo , context : Context ) => {
38
+ context.loginAccount.map { loginAccount =>
39
+ implicit val session = request2Session(context.request)
40
+
41
+ html.watch(getWatch(repository.owner, repository.name, loginAccount.userName).map(_.notification) getOrElse {
42
+ if (autoSubscribeUsersForRepository(repository.owner, repository.name) contains loginAccount.userName) Watch .Watching else Watch .NotWatching
43
+ }, repository)(context)
44
+ }
45
+ }
41
46
)
42
47
43
48
override val issueSidebars = Seq (
0 commit comments