Monorepo for Tangled
at 74318eac9fdd72cf69e916276814351931ed0dcb 65 lines 2.5 kB view raw
1{{ define "repo/pipelines/fragments/pipelineSymbol" }} 2 <div class="cursor-pointer flex gap-2 items-center"> 3 {{ template "symbol" .Pipeline }} 4 {{ if .ShortSummary }} 5 {{ .Pipeline.ShortStatusSummary }} 6 {{ else }} 7 {{ .Pipeline.LongStatusSummary }} 8 {{ end }} 9 </div> 10{{ end }} 11 12{{ define "symbol" }} 13 {{ $c := .Counts }} 14 {{ $statuses := .Statuses }} 15 {{ $total := len $statuses }} 16 {{ $success := index $c "success" }} 17 {{ $fail := index $c "failed" }} 18 {{ $timeout := index $c "timeout" }} 19 {{ $empty := eq $total 0 }} 20 {{ $allPass := eq $success $total }} 21 {{ $allFail := eq $fail $total }} 22 {{ $allTimeout := eq $timeout $total }} 23 24 {{ if $empty }} 25 {{ i "hourglass" "size-4 text-gray-600 dark:text-gray-400 " }} 26 {{ else if $allPass }} 27 {{ i "check" "size-4 text-green-600 dark:text-green-500" }} 28 {{ else if $allFail }} 29 {{ i "x" "size-4 text-red-600 dark:text-red-500" }} 30 {{ else if $allTimeout }} 31 {{ i "clock-alert" "size-4 text-orange-500" }} 32 {{ else }} 33 {{ $radius := f64 8 }} 34 {{ $circumference := mulf64 2.0 (mulf64 3.1416 $radius) }} 35 {{ $offset := 0.0 }} 36 <svg class="w-4 h-4 transform -rotate-90" viewBox="0 0 20 20"> 37 <circle cx="10" cy="10" r="{{ $radius }}" fill="none" class="stroke-gray-200 dark:stroke-gray-700" stroke-width="2"/> 38 {{ range $kind, $count := $c }} 39 {{ $colorClass := "" }} 40 {{ if or (eq $kind "pending") (eq $kind "running") }} 41 {{ $colorClass = "stroke-yellow-600 dark:stroke-yellow-500" }} 42 {{ else if eq $kind "success" }} 43 {{ $colorClass = "stroke-green-600 dark:stroke-green-500" }} 44 {{ else if eq $kind "cancelled" }} 45 {{ $colorClass = "stroke-gray-600 dark:stroke-gray-500" }} 46 {{ else if eq $kind "timeout" }} 47 {{ $colorClass = "stroke-orange-600 dark:stroke-orange-500" }} 48 {{ else }} 49 {{ $colorClass = "stroke-red-600 dark:stroke-red-500" }} 50 {{ end }} 51 {{ $percent := divf64 (f64 $count) (f64 $total) }} 52 {{ $length := mulf64 $percent $circumference }} 53 <circle 54 cx="10" cy="10" r="{{ $radius }}" 55 fill="none" 56 class="{{ $colorClass }}" 57 stroke-width="2" 58 stroke-dasharray="{{ printf "%.2f %.2f" $length (subf64 $circumference $length) }}" 59 stroke-dashoffset="{{ printf "%.2f" (negf64 $offset) }}" 60 /> 61 {{ $offset = addf64 $offset $length }} 62 {{ end }} 63 </svg> 64 {{ end }} 65{{ end }}