tangled
alpha
login
or
join now
bad-example.com
/
core
forked from
tangled.org/core
this repo has no description
0
fork
atom
overview
issues
pulls
pipelines
allow filtering issues by status
oppi.li
11 months ago
5bf2f448
2228dc61
+38
-18
5 changed files
expand all
collapse all
unified
split
appview
db
issues.go
pages
pages.go
templates
repo
issues
issues.html
state
repo.go
input.css
+7
-3
appview/db/issues.go
···
96
96
return ownerDid, err
97
97
}
98
98
99
99
-
func GetIssues(e Execer, repoAt syntax.ATURI) ([]Issue, error) {
99
99
+
func GetIssues(e Execer, repoAt syntax.ATURI, isOpen bool) ([]Issue, error) {
100
100
var issues []Issue
101
101
+
openValue := 0
102
102
+
if isOpen {
103
103
+
openValue = 1
104
104
+
}
101
105
102
106
rows, err := e.Query(
103
107
`select
···
113
117
left join
114
118
comments c on i.repo_at = c.repo_at and i.issue_id = c.issue_id
115
119
where
116
116
-
i.repo_at = ?
120
120
+
i.repo_at = ? and i.open = ?
117
121
group by
118
122
i.id, i.owner_did, i.issue_id, i.created, i.title, i.body, i.open
119
123
order by
120
124
i.created desc`,
121
121
-
repoAt)
125
125
+
repoAt, openValue)
122
126
if err != nil {
123
127
return nil, err
124
128
}
+2
appview/pages/pages.go
···
459
459
Active string
460
460
Issues []db.Issue
461
461
DidHandleMap map[string]string
462
462
+
463
463
+
FilteringByOpen bool
462
464
}
463
465
464
466
func (p *Pages) RepoIssues(w io.Writer, params RepoIssuesParams) error {
+11
-4
appview/pages/templates/repo/issues/issues.html
···
2
2
3
3
{{ define "repoContent" }}
4
4
<div class="flex justify-between items-center">
5
5
-
<div class="error" id="issues"></div>
5
5
+
<p>
6
6
+
filtering
7
7
+
<select class="font-bold border border-gray-200 rounded" onchange="window.location.href = '/{{ .RepoInfo.FullName }}/issues?state=' + this.value">
8
8
+
<option value="open" {{ if .FilteringByOpen }}selected{{ end }}>open</option>
9
9
+
<option value="closed" {{ if not .FilteringByOpen }}selected{{ end }}>closed</option>
10
10
+
</select>
11
11
+
issues
12
12
+
</p>
6
13
<a
7
14
href="/{{ .RepoInfo.FullName }}/issues/new"
8
8
-
class="btn flex items-center gap-2 no-underline"
9
9
-
>
10
10
-
<i data-lucide="square-plus" class="w-5 h-5"></i>
15
15
+
class="btn text-sm flex items-center gap-2 no-underline hover:no-underline">
16
16
+
<i data-lucide="plus" class="w-5 h-5"></i>
11
17
<span>new issue</span>
12
18
</a>
13
19
</div>
20
20
+
<div class="error" id="issues"></div>
14
21
{{ end }}
15
22
16
23
{{ define "repoAfter" }}
+18
-5
appview/state/repo.go
···
887
887
}
888
888
889
889
func (s *State) RepoIssues(w http.ResponseWriter, r *http.Request) {
890
890
+
params := r.URL.Query()
891
891
+
state := params.Get("state")
892
892
+
isOpen := true
893
893
+
switch state {
894
894
+
case "open":
895
895
+
isOpen = true
896
896
+
case "closed":
897
897
+
isOpen = false
898
898
+
default:
899
899
+
isOpen = true
900
900
+
}
901
901
+
890
902
user := s.auth.GetUser(r)
891
903
f, err := fullyResolvedRepo(r)
892
904
if err != nil {
···
894
906
return
895
907
}
896
908
897
897
-
issues, err := db.GetIssues(s.db, f.RepoAt)
909
909
+
issues, err := db.GetIssues(s.db, f.RepoAt, isOpen)
898
910
if err != nil {
899
911
log.Println("failed to get issues", err)
900
912
s.pages.Notice(w, "issues", "Failed to load issues. Try again later.")
···
916
928
}
917
929
918
930
s.pages.RepoIssues(w, pages.RepoIssuesParams{
919
919
-
LoggedInUser: s.auth.GetUser(r),
920
920
-
RepoInfo: f.RepoInfo(s, user),
921
921
-
Issues: issues,
922
922
-
DidHandleMap: didHandleMap,
931
931
+
LoggedInUser: s.auth.GetUser(r),
932
932
+
RepoInfo: f.RepoInfo(s, user),
933
933
+
Issues: issues,
934
934
+
DidHandleMap: didHandleMap,
935
935
+
FilteringByOpen: isOpen,
923
936
})
924
937
return
925
938
}
-6
input.css
···
96
96
"calt" 1,
97
97
"kern" 1;
98
98
}
99
99
-
h1 {
100
100
-
@apply text-2xl;
101
101
-
@apply font-sans;
102
102
-
@apply text-black;
103
103
-
@apply py-4;
104
104
-
}
105
99
106
100
::selection {
107
101
@apply bg-yellow-400;