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