Monorepo for Tangled tangled.org
856
fork

Configure Feed

Select the types of activity you want to include in your feed.

appview/timeline: show opened pull requests as timeline events #334

open opened by tolik518.tngl.sh targeting master from tolik518.tngl.sh/core: master
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:wzoaxleof2leut3d5uk73qry/sh.tangled.repo.pull/3ml6rxitec422
+94
Diff #2
+35
appview/db/timeline.go
··· 47 47 return nil, err 48 48 } 49 49 50 + pullOpenedEvents, err := getTimelinePullOpenedEvents(e, fetchLimit, loggedInUserDid, userIsFollowing) 51 + if err != nil { 52 + return nil, err 53 + } 54 + 50 55 events = append(events, repos...) 51 56 events = append(events, stars...) 52 57 events = append(events, follows...) 58 + events = append(events, pullOpenedEvents...) 53 59 54 60 sort.Slice(events, func(i, j int) bool { 55 61 return events[i].EventAt.After(events[j].EventAt) ··· 278 284 279 285 return events, nil 280 286 } 287 + 288 + func getTimelinePullOpenedEvents(e Execer, limit int, loggedInUserDid string, userIsFollowing []string) ([]models.TimelineEvent, error) { 289 + // When userIsFollowing is non-nil we're in "following" mode — only show PRs 290 + // from followed users (mirroring how getTimelineRepos/getTimelineStars work). 291 + // When nil we're in global mode — show all PRs (no owner filter). 292 + filters := make([]orm.Filter, 0) 293 + if userIsFollowing != nil { 294 + filters = append(filters, orm.FilterIn("owner_did", userIsFollowing)) 295 + } 296 + 297 + pulls, err := GetPullsPaginated(e, pagination.Page{Limit: limit}, filters...) 298 + if err != nil { 299 + return nil, err 300 + } 301 + 302 + var events []models.TimelineEvent 303 + for _, pull := range pulls { 304 + if pull.Repo == nil { 305 + continue 306 + } 307 + 308 + events = append(events, models.TimelineEvent{ 309 + PullOpened: pull, 310 + EventAt: pull.Created, 311 + }) 312 + } 313 + 314 + return events, nil 315 + }
+1
appview/models/timeline.go
··· 6 6 *Repo 7 7 *Follow 8 8 *RepoStar 9 + PullOpened *Pull 9 10 10 11 EventAt time.Time 11 12
+58
appview/pages/templates/timeline/fragments/timeline.html
··· 19 19 {{ template "timeline/fragments/starEvent" (list $ $g) }} 20 20 {{ else if $primary.Follow }} 21 21 {{ template "timeline/fragments/followEvent" (list $ $g) }} 22 + {{ else if $primary.PullOpened }} 23 + {{ template "timeline/fragments/pullOpenedEvent" (list $ $g) }} 22 24 {{ end }} 23 25 </div> 24 26 </div> ··· 117 119 "FollowersCount" $followStats.Followers 118 120 "FollowingCount" $followStats.Following) }} 119 121 {{ end }} 122 + 123 + {{ define "timeline/fragments/pullOpenedEvent" }} 124 + {{ $root := index . 0 }} 125 + {{ $group := index . 1 }} 126 + {{ $event := $group.Primary }} 127 + {{ $pull := $event.PullOpened }} 128 + {{ $repo := $pull.Repo }} 129 + {{ $repoOwnerHandle := resolve $repo.Did }} 130 + {{ $repoPath := printf "%s/%s" $repoOwnerHandle $repo.Name }} 131 + {{ $pullPath := printf "/%s/pulls/%d" $repoPath $pull.PullId }} 132 + 133 + <div class="pl-6 py-2 bg-white dark:bg-gray-800 text-gray-600 dark:text-gray-300 flex flex-wrap items-center gap-2 text-sm"> 134 + {{ template "user/fragments/picHandleLink" $pull.OwnerDid }} 135 + opened a pull request in 136 + <a href="/{{ $repoPath }}" class="no-underline hover:underline">{{ $repoPath }}</a> 137 + <span class="text-gray-700 dark:text-gray-400 text-xs">{{ template "repo/fragments/time" $pull.Created }}</span> 138 + </div> 139 + 140 + <div class="bg-white dark:bg-gray-800 p-4"> 141 + <div class="flex flex-col gap-3"> 142 + 143 + <div class="flex items-start justify-between gap-3"> 144 + <a href="{{ $pullPath }}" class="min-w-0 flex-1 font-medium text-gray-900 dark:text-white no-underline hover:underline"> 145 + {{ $pull.Title | description }} 146 + <span class="text-gray-500 dark:text-gray-400">#{{ $pull.PullId }}</span> 147 + </a> 148 + <div class="flex-shrink-0"> 149 + {{ template "repo/pulls/fragments/pullState" $pull.State }} 150 + </div> 151 + </div> 152 + 153 + {{ if $pull.Body }} 154 + <details class="group"> 155 + <style> 156 + details:not([open]) .pull-body-open { display: none; } 157 + details[open] .pull-body-closed { display: none; } 158 + </style> 159 + <summary class="list-none cursor-pointer"> 160 + <div class="pull-body-closed text-sm text-gray-600 dark:text-gray-300 line-clamp-2"> 161 + {{ $pull.Body | description }} 162 + </div> 163 + <span class="pull-body-closed mt-1 inline-block text-sm text-blue-600 dark:text-blue-400"> 164 + Read more 165 + </span> 166 + <div class="pull-body-open text-sm text-gray-600 dark:text-gray-300"> 167 + {{ $pull.Body | description }} 168 + </div> 169 + <span class="pull-body-open mt-1 text-sm text-blue-600 dark:text-blue-400"> 170 + Read less 171 + </span> 172 + </summary> 173 + </details> 174 + {{ end }} 175 + </div> 176 + </div> 177 + {{ end }}

History

3 rounds 0 comments
sign up or login to add to the discussion
4 commits
expand
appview/timeline: show opened pull requests as timeline events
appview/timeline: remove redundant empty-follow guard in pull events
appview/timeline: added "Read more" and "Read less" option to opened PR
appview/timeline: adjusted color of the repoPath on opened PRs
no conflicts, ready to merge
expand 0 comments
3 commits
expand
appview/timeline: show opened pull requests as timeline events
appview/timeline: remove redundant empty-follow guard in pull events
appview/timeline: added "Read more" and "Read less" option to opened PR
expand 0 comments
2 commits
expand
appview/timeline: show opened pull requests as timeline events
appview/timeline: remove redundant empty-follow guard in pull events
expand 0 comments