11import gitbucket .core .controller .Context
22import gitbucket .core .model .Issue
3- import gitbucket .core .plugin . Link
3+ import gitbucket .core .service .{ AccountService , IssuesService , RepositoryService }
44import gitbucket .core .service .RepositoryService .RepositoryInfo
55import gitbucket .core .util .Implicits .request2Session
66import gitbucket .notifications ._
7+ import gitbucket .notifications .model .Watch
8+ import gitbucket .notifications .service .NotificationsService
79import io .github .gitbucket .solidbase .migration .LiquibaseMigration
810import io .github .gitbucket .solidbase .model .Version
911
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 {
1114
1215 override val pluginId = " notifications"
1316
@@ -30,14 +33,16 @@ class Plugin extends gitbucket.core.plugin.Plugin {
3033 override val issueHooks = Seq (new service.IssueHook )
3134 override val pullRequestHooks = Seq (new service.PullRequestHook )
3235
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+ }
4146 )
4247
4348 override val issueSidebars = Seq (
0 commit comments