aboutsummaryrefslogtreecommitdiff
blob: 317ce70eff215b461307122633da4224591c69d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
package maintainer

import "strconv"
import "strings"
import "soko/pkg/app/layout"
import "soko/pkg/models"

func showViewTabs(email string, packagesCount int, info *models.MaintainerPackagesInformation) []layout.SubTab {
	return []layout.SubTab{
		{
			Name:       "Packages",
			Link:       templ.URL("/maintainer/" + email),
			Icon:       "fa fa-info mr-1",
			BadgeValue: strconv.Itoa(packagesCount),
		},
		{
			Name:       "Stabilization",
			Link:       templ.URL("/maintainer/" + email + "/stabilization"),
			Icon:       "fa fa-check-circle-o mr-1",
			BadgeValue: strconv.Itoa(info.StableRequests),
		},
		{
			Name:       "Outdated",
			Link:       templ.URL("/maintainer/" + email + "/outdated"),
			Icon:       "fa fa-tag mr-1",
			BadgeValue: strconv.Itoa(info.Outdated),
		},
		{
			Name:       "Pull requests",
			Link:       templ.URL("/maintainer/" + email + "/pull-requests"),
			Icon:       "octicon octicon-git-pull-request opticon-resource-icon ml-1",
			BadgeValue: strconv.Itoa(info.PullRequests),
		},
		{
			Name:       "Bugs",
			Link:       templ.URL("/maintainer/" + email + "/bugs"),
			Icon:       "fa fa-bug",
			BadgeValue: strconv.Itoa(info.Bugs),
		},
		{
			Name:       "Security",
			Link:       templ.URL("/maintainer/" + email + "/security"),
			Icon:       "fa fa-shield",
			BadgeValue: strconv.Itoa(info.SecurityBugs),
		},
		{
			Name: "Changelog",
			Link: templ.URL("/maintainer/" + email + "/changelog"),
			Icon: "fa fa-fw fa-history",
		},
	}
}

templ tabbedHeader(maintainer *models.Maintainer, packagesCount int, currentSubTab string) {
	<div class="kk-header-container">
		<div class="container">
			<div class="row">
				<div class="col-12">
					<div class="row mt-3">
						<div class="col-md-5">
							<h1 class="stick-top kk-package-title" id="package-title">
								<small class="kk-package-cat">
									if maintainer.Email == "maintainer-needed@gentoo.org" {
									} else if maintainer.Type == "project" {
										Gentoo Project
									} else if strings.Contains(maintainer.Email, "@gentoo.org") {
										Gentoo Developer
									} else if maintainer.Email != "" {
										Proxied Maintainer
									}
								</small>
								<div>
									<svg height="32" class="octicon octicon-person right left kk-package-icon" aria-label="Package icon" viewBox="0 0 16 16" version="1.1" width="32" role="img"><path fill-rule="evenodd" d="M10.5 5a2.5 2.5 0 11-5 0 2.5 2.5 0 015 0zm.061 3.073a4 4 0 10-5.123 0 6.004 6.004 0 00-3.431 5.142.75.75 0 001.498.07 4.5 4.5 0 018.99 0 .75.75 0 101.498-.07 6.005 6.005 0 00-3.432-5.142z"></path></svg>
									<div class="kk-package-name">
										if len(maintainer.Name) > 0 {
											{  maintainer.Name }
										} else if len(maintainer.Email) > 0 {
											{  maintainer.Email }
										} else {
											Maintainer Needed
										}
									</div>
								</div>
							</h1>
						</div>
						<div class="col-md-7"></div>
						<div class="col-md-12 pt-4 mt-1">
							<nav class="nav kk-package-nav">
								for _, tab := range showViewTabs(maintainer.Email, packagesCount, &maintainer.PackagesInformation) {
									<a class={ "nav-link", templ.KV("active", tab.Name == currentSubTab) } href={ tab.Link }>
										<i class={ tab.Icon } aria-hidden="true"></i> { tab.Name }
										if tab.BadgeValue != "" {
											<span class="ml-1 badge badge-pill kk-misc-badge">{ tab.BadgeValue }</span>
										}
									</a>
								}
							</nav>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
}

templ show(packagesCount int, maintainer *models.Maintainer, currentSubTab string, component templ.Component) {
	@tabbedHeader(maintainer, packagesCount, currentSubTab)
	<div class="tab-content" id="myTabContent">
		<div class="container mb-5 tab-pane fade show active" id="overview" role="tabpanel" aria-labelledby="overview-tab">
			@component
		</div>
	</div>
}

script filter() {
	const value = document.querySelector("#filter").value.toLowerCase();
	const groups = document.querySelectorAll("#pkglist .list-group");
	for (let i = 0; i < groups.length; i++) {
		let visible = false;
		const rows = groups[i].querySelectorAll(".list-group-item");
		for (let j = 0; j < rows.length; j++) {
			const flag = rows[j].children[0].children[0].innerText.toLowerCase().includes(value);
			rows[j].style.display = flag ? "" : "none";
			visible ||= flag;
		}
		groups[i].style.display = visible ? "" : "none";
	}
}

templ showPackages(packages []*models.Package, maintainer *models.Maintainer) {
	<div class="row">
		<div class="col-md-9" id="pkglist">
			if len(packages) > 0 {
				<p>
					<input onKeyup={ filter() } id="filter" type="text" class="form-control form-control-xl" placeholder={ "Search packages maintained by " + maintainer.Email }/>
				</p>
				<ul class="list-group">
					<h3 id={ packages[0].Category }>{ packages[0].Category }</h3>
					for i, pkg := range packages {
						if i != 0 && pkg.Category != packages[i-1].Category {
							@templ.Raw("</ul>")
							<h3 class="mt-4" id={ pkg.Category }>{ pkg.Category }</h3>
							@templ.Raw(`<ul class="list-group">`)
						}
						<li class="list-group-item">
							<div class="row">
								<div class="col-md-4">
									<a href={ templ.URL("/packages/" + pkg.Atom) } class="text-dark"><b>{ pkg.Atom }</b></a>
								</div>
								<div class="col-md-8 text-muted">
									{ pkg.Description() }
								</div>
							</div>
						</li>
					}
				</ul>
				@filter()
			} else {
				<div class="row">
					<div class="col-md-8"></div>
					<div class="col-md-4">
						<img
							style="width: 100%;"
							src="https://upload.wikimedia.org/wikipedia/commons/thumb/4/4f/Larry-the-cow-full.svg/1200px-Larry-the-cow-full.svg.png"
						/>
					</div>
				</div>
			}
		</div>
		<div class="col-md-3 pt-4">
			if maintainer.Project.Description != "" {
				<h4 class="">
					<a class="collapseLink" style="color:#000000;" data-toggle="collapse" href="#collapseDescription" role="button" aria-expanded="false" aria-controls="collapseDescription">
						Description
					</a>
				</h4>
				<div class="collapse show" id="collapseDescription">
					<dl>
						<dd class="ml-3 mb-0 text-muted">
							{ maintainer.Project.Description }
						</dd>
					</dl>
				</div>
			}
			<h4 class={ templ.KV("mt-4", maintainer.Project.Description != "") }>
				<a class="collapseLink" style="color:#000000;" data-toggle="collapse" href="#collapseExternalResources" role="button" aria-expanded="false" aria-controls="collapseDescription">
					External Resources
				</a>
			</h4>
			<div class="collapse show" id="collapseExternalResources">
				<dl class="ml-3">
					<dd>
						<span class="fa fa-fw fa-chain-broken"></span>
						<a href={ templ.URL("https://qa-reports.gentoo.org/output/gentoo-ci/output.html;maintainer=" + maintainer.Email) } title="CI report" target="_blank">CI Report</a>
						(<a href={ templ.URL("https://qa-reports.gentoo.org/output/gentoo-ci/output.verbose.html;maintainer=" + maintainer.Email) } title="Verbose CI report" target="_blank">verbose</a>)
					</dd>
					<dd>
						<span class="fa fa-fw fa-book"></span>
						<a href={ templ.URL(maintainer.Project.Url) } target="_blank">Documentation</a>
					</dd>
				</dl>
			</div>
			if maintainer.Project.Description != "" {
				<h4 class="mt-4">
					<a class="collapseLink" style="color:#000000;" data-toggle="collapse" href="#collapseMembers" role="button" aria-expanded="false" aria-controls="collapseMembers">
						Members
					</a>
				</h4>
				<div class="collapse show" id="collapseMembers">
					<dl>
						for _, member := range maintainer.Project.Members {
							<dd class="ml-3 mb-0">
								<a href={ templ.URL("/maintainer/" + member.Email) }>{ member.Name }</a>
								if member.IsLead {
									(Lead)
								}
							</dd>
						}
					</dl>
				</div>
			}
			if len(maintainer.Projects) > 0 {
				<h4>
					<a class="collapseLink" style="color:#000000;" data-toggle="collapse" href="#collapseProjects" role="button" aria-expanded="false" aria-controls="collapseProjects">
						Projects
					</a>
				</h4>
				<div class="collapse show" id="collapseProjects">
					<dl>
						for _, project := range maintainer.Projects {
							<dd class="ml-3 mb-0"><a href={ templ.URL("/maintainer/" + project.Email) }>{ project.Name }</a></dd>
						}
					</dl>
				</div>
			}
			if len(packages) > 0 {
				<h4 class="mt-4">
					<a class="collapseLink" style="color:#000000;" data-toggle="collapse" href="#collapseShortcuts" role="button" aria-expanded="false" aria-controls="collapseShortcuts">
						Shortcuts
					</a>
				</h4>
				<div class="collapse show" id="collapseShortcuts">
					<dl>
						for i, pkg := range packages {
							if i == 0 || pkg.Category != packages[i-1].Category {
								<dd class="ml-3 mb-0">
									<a href={ templ.URL("#" + pkg.Category) }>{ pkg.Category }</a>
								</dd>
							}
						}
					</dl>
				</div>
			}
		</div>
	</div>
}