{{define "namespace"}}
{{ $foundFirstWorkload := false }}

<article class="detailInfo --namespace verticalRhythm" data-filter="{{ $.Namespace }}">
  <h2>
    <span class="badge detailBadge --namespace">Namespace</span>
    {{ $.Namespace }}
  </h2>

  {{ if not .IsOnlyNamespace }}
  <a
    class="detailLink --namespace"
    href="{{ $.BasePath }}dashboard/{{ $.Namespace }}"
  >Limit results to the {{ $.Namespace }} namespace</a>
  {{ end }}

  <details open>
    <summary>Workloads</summary>

    {{ if lt (len $.Workloads) 1 }}
    <p class="detailInfo --empty">No workloads found in this namespace.</p>

    {{ else }}
      {{ range $workload := $.Workloads }}

    <div class="detailInfo --deployment verticalRhythm">
      <h3>
        <span class="badge detailBadge --deployment">{{ $workload.ControllerType }}</span>
        {{ $workload.ControllerName }}
      </h3>

      <details
          {{ if not $foundFirstWorkload }}
            {{ $foundFirstWorkload = true }} open
          {{ end }}>
        <summary>Containers</summary>

        {{ range $cName, $cSummary := $workload.Containers }}
        <div class="detailInfo --container verticalRhythm">
          <h4>
            <span class="badge detailBadge --container">Container</span>
            {{ $cName }}
          </h4>

          <details open>
            <summary>Details</summary>

            <div class="layoutLineup">
              {{ template "container" $cSummary }}
            </div>
          </details>
        </div>
        {{ end }}
      </details>
    </div>
      {{ end }}
    {{ end }}
  </details>
</article>
{{end}}
