+32
-10
appview/pages/templates/repo/index.html
+32
-10
appview/pages/templates/repo/index.html
···
32
32
{{ end }}
33
33
34
34
{{ define "branchSelector" }}
35
-
<div>
35
+
<div class="flex gap-4 items-center justify-center">
36
36
<select
37
37
onchange="window.location.href = '/{{ .RepoInfo.FullName }}/tree/' + encodeURIComponent(this.value)"
38
38
class="p-1 border max-w-32 border-gray-200 bg-white dark:bg-gray-800 dark:text-white dark:border-gray-700"
···
66
66
{{ end }}
67
67
</optgroup>
68
68
</select>
69
-
<button
70
-
id="syncBtn"
71
-
class="btn disabled:opacity-50 disabled:cursor-not-allowed"
72
-
hx-post="/{{ .RepoInfo.FullName }}/fork/sync?knot={{ .RepoInfo.Knot }}&branch={{ .RepoInfo.Ref }}"
73
-
hx-trigger="click"
74
-
hx-swap="none"
75
-
>
76
-
sync
77
-
</button>
69
+
{{ if .ForkInfo.IsFork }}
70
+
{{ $disabled := "" }}
71
+
{{ $title := "" }}
72
+
{{ if eq .ForkInfo.Status 0 }}
73
+
{{ $disabled = "disabled" }}
74
+
{{ $title = "This branch is not behind the upstream" }}
75
+
{{ else if eq .ForkInfo.Status 2 }}
76
+
{{ $disabled = "disabled" }}
77
+
{{ $title = "This branch has conflicts that must be resolved" }}
78
+
{{ else if eq .ForkInfo.Status 3 }}
79
+
{{ $disabled = "disabled" }}
80
+
{{ $title = "This branch does not exist on the upstream" }}
81
+
{{ end }}
82
+
83
+
<button
84
+
id="syncBtn"
85
+
{{ $disabled }}
86
+
{{ if $title }}title="{{ $title }}"{{ end }}
87
+
class="btn flex gap-2 items-center disabled:opacity-50 disabled:cursor-not-allowed"
88
+
hx-post="/{{ .RepoInfo.FullName }}/fork/sync"
89
+
hx-trigger="click"
90
+
hx-swap="none"
91
+
>
92
+
{{ if $disabled }}
93
+
{{ i "refresh-cw-off" "w-4 h-4" }}
94
+
{{ else }}
95
+
{{ i "refresh-cw" "w-4 h-4" }}
96
+
{{ end }}
97
+
<span>sync</span>
98
+
</button>
99
+
{{ end }}
78
100
</div>
79
101
{{ end }}
80
102