Monorepo for Tangled tangled.org

appview/{pipelines,pages}: filter pipelines list by push/PR #1058

merged opened by anirudh.fi targeting master from icy/mnwnvv
Labels

None yet.

assignee

None yet.

Participants 2
AT URI
at://did:plc:hwevmowznbiukdf6uk5dwrrq/sh.tangled.repo.pull/3mee2ywxaeo22
+61 -12
Diff #0
+6 -4
appview/pages/pages.go
··· 1348 1348 } 1349 1349 1350 1350 type PipelinesParams struct { 1351 - LoggedInUser *oauth.MultiAccountUser 1352 - RepoInfo repoinfo.RepoInfo 1353 - Pipelines []models.Pipeline 1354 - Active string 1351 + LoggedInUser *oauth.MultiAccountUser 1352 + RepoInfo repoinfo.RepoInfo 1353 + Pipelines []models.Pipeline 1354 + Active string 1355 + FilteringByPush bool 1356 + FilteringByPR bool 1355 1357 } 1356 1358 1357 1359 func (p *Pages) Pipelines(w io.Writer, params PipelinesParams) error {
+34 -5
appview/pages/templates/repo/pipelines/pipelines.html
··· 7 7 {{ end }} 8 8 9 9 {{ define "repoContent" }} 10 - <div class="flex justify-between items-center gap-4 mb-4"> 11 - <div class="text-sm text-gray-600 dark:text-gray-400"> 12 - {{ len .Pipelines }} pipeline run{{ if ne (len .Pipelines) 1 }}s{{ end }} 10 + {{ $active := "all" }} 11 + {{ if .FilteringByPush }} 12 + {{ $active = "push" }} 13 + {{ else if .FilteringByPR }} 14 + {{ $active = "pr" }} 15 + {{ end }} 16 + 17 + {{ $all := 18 + (dict 19 + "Key" "all" 20 + "Value" "all" 21 + "Icon" "package" 22 + "Meta" "") }} 23 + {{ $push := 24 + (dict 25 + "Key" "push" 26 + "Value" "push" 27 + "Icon" "git-commit-horizontal" 28 + "Meta" "") }} 29 + {{ $pr := 30 + (dict 31 + "Key" "pr" 32 + "Value" "pull request" 33 + "Icon" "git-pull-request" 34 + "Meta" "") }} 35 + {{ $values := list $all $push $pr }} 36 + 37 + <div class="flex justify-between items-center gap-4"> 38 + <div> 39 + {{ template "fragments/tabSelector" (dict "Name" "trigger" "Values" $values "Active" $active) }} 40 + </div> 41 + <div class="text-sm text-gray-600 dark:text-gray-400"> 42 + {{ len .Pipelines }} pipeline run{{ if ne (len .Pipelines) 1 }}s{{ end }} 43 + </div> 13 44 </div> 14 - <!-- Future: Add filter tabs here similar to issues/pulls --> 15 - </div> 16 45 {{ end }} 17 46 18 47 {{ define "repoAfter" }}
+21 -3
appview/pipelines/pipelines.go
··· 98 98 return 99 99 } 100 100 101 + // Filter by trigger 102 + filterTrigger := r.URL.Query().Get("trigger") 103 + var filtered []models.Pipeline 104 + for _, pipeline := range ps { 105 + if filterTrigger == "push" && pipeline.Trigger != nil && pipeline.Trigger.IsPush() { 106 + filtered = append(filtered, pipeline) 107 + } else if filterTrigger == "pr" && pipeline.Trigger != nil && pipeline.Trigger.IsPullRequest() { 108 + filtered = append(filtered, pipeline) 109 + } else if filterTrigger == "" || filterTrigger == "all" { 110 + filtered = append(filtered, pipeline) 111 + } 112 + } 113 + 114 + filteringByPush := filterTrigger == "push" 115 + filteringByPR := filterTrigger == "pr" 116 + 101 117 p.pages.Pipelines(w, pages.PipelinesParams{ 102 - LoggedInUser: user, 103 - RepoInfo: p.repoResolver.GetRepoInfo(r, user), 104 - Pipelines: ps, 118 + LoggedInUser: user, 119 + RepoInfo: p.repoResolver.GetRepoInfo(r, user), 120 + Pipelines: filtered, 121 + FilteringByPush: filteringByPush, 122 + FilteringByPR: filteringByPR, 105 123 }) 106 124 } 107 125

History

1 round 1 comment
sign up or login to add to the discussion
anirudh.fi submitted #0
1 commit
expand
appview/{pipelines,pages}: filter pipelines list by push/PR
1/3 failed, 2/3 success
expand
expand 1 comment

looks pretty good!

pull request successfully merged