{{define "visibilityBadge" -}}
{{if eq (printf "%s" .) "PUBLIC" -}}
<span class="badge badge-success">public</span>
{{- else if eq (printf "%s" .) "UNLISTED" -}}
<span class="badge badge-warning">unlisted</span>
{{- else -}}
<span class="badge badge-secondary">private</span>
{{- end}}
{{- end}}
{{/*
viewtabs renders the repo's tab bar: a fixed "Overview" tab, a "Tables" tab for
the always-available generic browser, then one tab per applicable View.
Invoke it with a dict context:
{{template "viewtabs" (dict "Repo" .Repo "Views" .Views "Current" "overview" "Ref" .DefaultBranch)}}
.Current selects the active tab: "overview", "tables", or a view's slug. .Ref is
the branch/ref the Tables tab links to (falls back to the overview when empty).
*/}}
{{define "viewtabs" -}}
{{$repo := .Repo}}{{$current := .Current}}{{$ref := .Ref}}
<ul class="nav nav-tabs mb-3">
<li class="nav-item">
<a class="nav-link{{if eq $current "overview"}} active{{end}}"
href="/~{{$repo.OwnerName}}/{{$repo.Name}}">Overview</a>
</li>
<li class="nav-item">
<a class="nav-link{{if eq $current "tables"}} active{{end}}"
href="{{if $ref}}/~{{$repo.OwnerName}}/{{$repo.Name}}/tree/{{$ref}}{{else}}/~{{$repo.OwnerName}}/{{$repo.Name}}{{end}}">Tables</a>
</li>
{{range .Views}}
<li class="nav-item">
<a class="nav-link{{if eq .Name $current}} active{{end}}"
href="/~{{$repo.OwnerName}}/{{$repo.Name}}/view/{{.Name}}">{{.Label}}</a>
</li>
{{end}}
</ul>
{{- end}}
{{define "repoList" -}}
{{if .}}
<div class="event-list">
{{range .}}
<div class="event">
<h4>
<a href="/~{{.OwnerName}}/{{.Name}}">~{{.OwnerName}}/{{.Name}}</a>
{{if ne (printf "%s" .Visibility) "PUBLIC"}}
<small class="pull-right">{{lower (printf "%s" .Visibility)}}</small>
{{end}}
</h4>
{{if .Description}}
<p>{{.Description}}</p>
{{end}}
</div>
{{end}}
</div>
{{else}}
<p class="text-muted">No databases yet.</p>
{{end}}
{{- end}}