{{ define "title" }}
    Tags &middot; {{ .RepoInfo.FullName }} &middot; Tangled
{{ end }}

{{ define "extrameta" }}
    {{ $title := printf "tags &middot; %s" .RepoInfo.FullName }}
    {{ $url := printf "https://tangled.org/%s/tags" .RepoInfo.FullName }}

    {{ template "repo/fragments/og" (dict "RepoInfo" .RepoInfo "Title" $title "Url" $url) }}
{{ end }}

{{ define "repoContent" }}
<section>
  <h2 class="mb-4 text-sm text-left text-gray-700 dark:text-gray-300 font-bold">Tags</h2>
  <div class="flex flex-col py-2 gap-12 md:gap-0">
    {{ range .Tags }}
      {{ template "repo/fragments/singleTag" (list $ . ) }}
    {{ else }}
      <p class="text-center text-gray-400 dark:text-gray-500 p-4">
        This repository does not contain any tags.
      </p>
    {{ end }}
  </div>
</section>
{{ end }}

{{ define "repoAfter" }}
{{ if gt (len .DanglingArtifacts) 0 }}
  <section class="bg-white dark:bg-gray-800 p-6 mt-4">
    {{ block "dangling" . }} {{ end }}
  </section>
{{ end }}
{{ end }}

{{ define "dangling" }}
  {{ $root := . }}
  {{ $isPushAllowed := $root.RepoInfo.Roles.IsPushAllowed }}
  {{ $artifacts := $root.DanglingArtifacts }}

  {{ if and (gt (len $artifacts) 0) $isPushAllowed }}
  <h2 class="mb-2 text-sm text-left text-red-700 dark:text-red-400 font-bold">Dangling artifacts</h2>
  <p class="mb-4">The tags that these artifacts were attached to have been deleted. These artifacts are only visible to collaborators.</p>
  <div class="flex flex-col rounded border border-gray-200 dark:border-gray-700">
    {{ range $artifact := $artifacts }}
      {{ $args := dict "LoggedInUser" $root.LoggedInUser "RepoInfo" $root.RepoInfo "Artifact" $artifact }}
      {{ template "repo/fragments/artifact" $args }}
    {{ end }}
  </div>
  {{ end }}
{{ end }}
