From abbb9150ea499c0ce422d848156d0b1e6097f713 Mon Sep 17 00:00:00 2001 From: Anirudh Oppiliappan Date: Fri, 3 Jul 2026 15:43:55 +0530 Subject: [PATCH] appview/pages: add subscribe button to issue and pull pages --- appview/pages/pages.go | 32 +++++++++++++- .../issues/fragments/subscribeButton.html | 34 ++++++++++++++ .../pages/templates/repo/issues/issue.html | 12 +++-- .../repo/pulls/fragments/subscribeButton.html | 31 +++++++++++++ appview/pages/templates/repo/pulls/pull.html | 44 +++++++++++-------- 5 files changed, 129 insertions(+), 24 deletions(-) create mode 100644 appview/pages/templates/repo/issues/fragments/subscribeButton.html create mode 100644 appview/pages/templates/repo/pulls/fragments/subscribeButton.html diff --git a/appview/pages/pages.go b/appview/pages/pages.go index a81dcdcb..25391ec6 100644 --- a/appview/pages/pages.go +++ b/appview/pages/pages.go @@ -592,8 +592,9 @@ func (p *Pages) UserEmailsSettings(w io.Writer, params UserEmailsSettingsParams) type UserNotificationSettingsParams struct { BaseParams - Preferences *models.NotificationPreferences - Tab string + Preferences *models.NotificationPreferences + HasVerifiedEmail bool + Tab string } func (p *Pages) UserNotificationSettings(w io.Writer, params UserNotificationSettingsParams) error { @@ -1346,6 +1347,10 @@ type RepoSingleIssueParams struct { Reactions map[syntax.ATURI]map[models.ReactionKind]models.ReactionDisplayData UserReacted map[syntax.ATURI]map[models.ReactionKind]bool VouchRelationships map[syntax.DID]*models.VouchRelationship + + // IsSubscribed is nil when the user is not logged in, true when subscribed, + // false when explicitly unsubscribed, and nil when no explicit subscription. + IsSubscribed *bool } func (p *Pages) RepoSingleIssue(w io.Writer, params RepoSingleIssueParams) error { @@ -1353,6 +1358,26 @@ func (p *Pages) RepoSingleIssue(w io.Writer, params RepoSingleIssueParams) error return p.executeRepo("repo/issues/issue", w, params) } +type IssueSubscribeParams struct { + RepoInfo repoinfo.RepoInfo + IssueId int + IsSubscribed *bool +} + +func (p *Pages) IssueSubscribeFragment(w io.Writer, params IssueSubscribeParams) error { + return p.executePlain("repo/issues/fragments/subscribeButton", w, params) +} + +type PullSubscribeParams struct { + RepoInfo repoinfo.RepoInfo + PullId int + IsSubscribed *bool +} + +func (p *Pages) PullSubscribeFragment(w io.Writer, params PullSubscribeParams) error { + return p.executePlain("repo/pulls/fragments/subscribeButton", w, params) +} + type EditIssueParams struct { BaseParams RepoInfo repoinfo.RepoInfo @@ -1502,6 +1527,9 @@ type RepoSinglePullParams struct { LabelDefs map[string]*models.LabelDefinition VouchRelationships map[syntax.DID]*models.VouchRelationship VouchSkips map[syntax.DID]bool + + // IsSubscribed is nil when not logged in, true when subscribed, false when explicitly unsubscribed. + IsSubscribed *bool } func (p *Pages) RepoSinglePull(w io.Writer, params RepoSinglePullParams) error { diff --git a/appview/pages/templates/repo/issues/fragments/subscribeButton.html b/appview/pages/templates/repo/issues/fragments/subscribeButton.html new file mode 100644 index 00000000..333b0360 --- /dev/null +++ b/appview/pages/templates/repo/issues/fragments/subscribeButton.html @@ -0,0 +1,34 @@ +{{ define "repo/issues/fragments/subscribeButton" }} + {{ $subscribed := false }} + {{ if .IsSubscribed }}{{ $subscribed = .IsSubscribed }}{{ end }} +
+
+ Notifications +
+ {{ if $subscribed }} +
+ + +
+ {{ else }} +
+ + +
+ {{ end }} +
+{{ end }} diff --git a/appview/pages/templates/repo/issues/issue.html b/appview/pages/templates/repo/issues/issue.html index 9cbcf59f..0801cf2e 100644 --- a/appview/pages/templates/repo/issues/issue.html +++ b/appview/pages/templates/repo/issues/issue.html @@ -6,20 +6,26 @@ {{ end }} {{ define "repoContentLayout" }} -
-
+
+
{{ block "repoContent" . }}{{ end }}
{{ block "repoAfter" . }}{{ end }}
-
+
{{ template "repo/fragments/labelPanel" (dict "RepoInfo" $.RepoInfo "Defs" $.LabelDefs "Subject" $.Issue.AtUri "State" $.Issue.Labels) }} {{ template "repo/fragments/participants" $.Issue.Participants }} + {{ if $.LoggedInUser }} + {{ template "repo/issues/fragments/subscribeButton" + (dict "RepoInfo" $.RepoInfo + "IssueId" $.Issue.IssueId + "IsSubscribed" $.IsSubscribed) }} + {{ end }} {{ template "repo/fragments/backlinks" (dict "RepoInfo" $.RepoInfo "Backlinks" $.Backlinks) }} diff --git a/appview/pages/templates/repo/pulls/fragments/subscribeButton.html b/appview/pages/templates/repo/pulls/fragments/subscribeButton.html new file mode 100644 index 00000000..53c84cf1 --- /dev/null +++ b/appview/pages/templates/repo/pulls/fragments/subscribeButton.html @@ -0,0 +1,31 @@ +{{ define "repo/pulls/fragments/subscribeButton" }} + {{ $subscribed := false }} + {{ if .IsSubscribed }}{{ $subscribed = .IsSubscribed }}{{ end }} +
+ {{ if $subscribed }} +
+ + +
+ {{ else }} +
+ + +
+ {{ end }} +
+{{ end }} diff --git a/appview/pages/templates/repo/pulls/pull.html b/appview/pages/templates/repo/pulls/pull.html index b5eefefc..d789b20f 100644 --- a/appview/pages/templates/repo/pulls/pull.html +++ b/appview/pages/templates/repo/pulls/pull.html @@ -23,7 +23,7 @@ (function() { const details = document.getElementById('bottomSheet'); const backdrop = document.getElementById('bottomSheetBackdrop'); - const isDesktop = () => window.matchMedia('(min-width: 768px)').matches; + const isDesktop = () => window.matchMedia('(min-width: 1024px)').matches; // function to update backdrop const updateBackdrop = () => { @@ -54,7 +54,7 @@ updateBackdrop(); }); - const mediaQuery = window.matchMedia('(min-width: 768px)'); + const mediaQuery = window.matchMedia('(min-width: 1024px)'); mediaQuery.addEventListener('change', function(e) { if (e.matches) { // switched to desktop - keep open @@ -111,20 +111,26 @@ {{ end }} {{ define "repoContentLayout" }} -
-
+
+
{{ block "repoContent" . }}{{ end }}
{{ template "repo/pulls/fragments/pullVouchNudge" . }}
-
+
{{ template "repo/fragments/labelPanel" (dict "RepoInfo" $.RepoInfo "Defs" $.LabelDefs "Subject" $.Pull.AtUri "State" $.Pull.Labels) }} {{ template "repo/fragments/participants" $.Pull.Participants }} + {{ if $.LoggedInUser }} + {{ template "repo/pulls/fragments/subscribeButton" + (dict "RepoInfo" $.RepoInfo + "PullId" $.Pull.PullId + "IsSubscribed" $.IsSubscribed) }} + {{ end }} {{ template "repo/fragments/backlinks" (dict "RepoInfo" $.RepoInfo "Backlinks" $.Backlinks) }} @@ -158,7 +164,7 @@ data-resizer="vertical" data-target="{{ $target }}" data-direction="{{ $direction }}" - class="resizer-vertical hidden md:flex w-4 sticky top-12 max-h-screen flex-col items-center justify-center group"> + class="resizer-vertical hidden lg:flex w-4 sticky top-12 max-h-screen flex-col items-center justify-center group">
{{ end }} @@ -170,7 +176,7 @@
-