forked from tangled.org/core
this repo has no description

appview: templates/repo: add `sync` fork button to ui

Changed files
+32 -10
appview
pages
templates
repo
+32 -10
appview/pages/templates/repo/index.html
···
{{ end }}
{{ define "branchSelector" }}
-
<div>
+
<div class="flex gap-4 items-center justify-center">
<select
onchange="window.location.href = '/{{ .RepoInfo.FullName }}/tree/' + encodeURIComponent(this.value)"
class="p-1 border max-w-32 border-gray-200 bg-white dark:bg-gray-800 dark:text-white dark:border-gray-700"
···
{{ end }}
</optgroup>
</select>
-
<button
-
id="syncBtn"
-
class="btn disabled:opacity-50 disabled:cursor-not-allowed"
-
hx-post="/{{ .RepoInfo.FullName }}/fork/sync?knot={{ .RepoInfo.Knot }}&branch={{ .RepoInfo.Ref }}"
-
hx-trigger="click"
-
hx-swap="none"
-
>
-
sync
-
</button>
+
{{ if .ForkInfo.IsFork }}
+
{{ $disabled := "" }}
+
{{ $title := "" }}
+
{{ if eq .ForkInfo.Status 0 }}
+
{{ $disabled = "disabled" }}
+
{{ $title = "This branch is not behind the upstream" }}
+
{{ else if eq .ForkInfo.Status 2 }}
+
{{ $disabled = "disabled" }}
+
{{ $title = "This branch has conflicts that must be resolved" }}
+
{{ else if eq .ForkInfo.Status 3 }}
+
{{ $disabled = "disabled" }}
+
{{ $title = "This branch does not exist on the upstream" }}
+
{{ end }}
+
+
<button
+
id="syncBtn"
+
{{ $disabled }}
+
{{ if $title }}title="{{ $title }}"{{ end }}
+
class="btn flex gap-2 items-center disabled:opacity-50 disabled:cursor-not-allowed"
+
hx-post="/{{ .RepoInfo.FullName }}/fork/sync"
+
hx-trigger="click"
+
hx-swap="none"
+
>
+
{{ if $disabled }}
+
{{ i "refresh-cw-off" "w-4 h-4" }}
+
{{ else }}
+
{{ i "refresh-cw" "w-4 h-4" }}
+
{{ end }}
+
<span>sync</span>
+
</button>
+
{{ end }}
</div>
{{ end }}