This repository has no description
6.1 kB
130 lines
1{{ define "repo/pulls/fragments/pullStepSource" }}
2 <section class="flex flex-col gap-3">
3 <input type="hidden" name="source" value="{{ .Source }}">
4
5 {{ template "pullSourceTabs" . }}
6
7 {{ if eq .Source "patch" }}
8 <div class="flex flex-col gap-1">
9 {{ template "repo/fragments/labelSectionHeaderText" "Merge into" }}
10 {{ template "pullTargetBranchSelect" . }}
11 </div>
12 {{ template "repo/pulls/fragments/pullPatchUpload" . }}
13 {{ else }}
14 <div class="flex flex-col md:flex-row md:flex-wrap gap-3">
15 <div class="flex flex-col gap-1">
16 {{ template "repo/fragments/labelSectionHeaderText" "Merge into" }}
17 {{ template "pullTargetBranchSelect" . }}
18 </div>
19 <div id="patch-strategy" class="flex flex-col gap-1">
20 {{ template "repo/fragments/labelSectionHeaderText" "Pull from" }}
21 {{ if eq .Source "fork" }}
22 {{ template "repo/pulls/fragments/pullCompareForks" . }}
23 {{ else }}
24 {{ template "repo/pulls/fragments/pullCompareBranches" . }}
25 {{ end }}
26 </div>
27 </div>
28 {{ end }}
29
30 <div id="patch-error" class="error dark:text-red-300 empty:hidden"></div>
31 </section>
32{{ end }}
33
34{{ define "pullTargetBranchSelect" }}
35 <div class="flex flex-wrap gap-2 items-center">
36 <select
37 id="targetBranch"
38 name="targetBranch"
39 required
40 hx-post="/{{ .RepoInfo.RepoDid }}/pulls/new/refresh"
41 hx-include="closest form"
42 hx-target="#pr-compose-host"
43 hx-swap="outerHTML"
44 hx-trigger="change"
45 hx-indicator="this"
46 class="peer p-1 border border-gray-200 bg-white dark:bg-gray-700 dark:text-white dark:border-gray-600"
47 >
48 <option disabled {{ if not .TargetBranch }}selected{{ end }}>Target branch</option>
49 {{ $disableSource := and (eq .Source "branch") $.SourceBranch }}
50 {{ range .Branches }}
51 {{ $preset := false }}
52 {{ if $.TargetBranch }}
53 {{ $preset = eq .Reference.Name $.TargetBranch }}
54 {{ else }}
55 {{ $preset = .IsDefault }}
56 {{ end }}
57 {{ $isSource := and $disableSource (eq .Reference.Name $.SourceBranch) }}
58 <option value="{{ .Reference.Name }}" class="py-1"
59 {{ if $preset }}selected{{ end }}
60 {{ if $isSource }}disabled{{ end }}>
61 {{ .Reference.Name }}
62 {{ if $isSource }}(Source){{ end }}
63 </option>
64 {{ end }}
65 </select>
66 {{ i "loader-circle" "size-4 animate-spin hidden peer-[.htmx-request]:inline text-gray-500 dark:text-gray-400" }}
67 </div>
68{{ end }}
69
70{{ define "pullSourceTabs" }}
71 {{ $active := "bg-white dark:bg-gray-800 shadow-sm cursor-default border border-gray-200 dark:border-gray-700" }}
72 {{ $inactive := "bg-transparent hover:bg-white/50 dark:hover:bg-gray-800/50" }}
73 {{ $shared := "group flex-1 p-3 text-left hover:no-underline flex flex-col gap-1 rounded" }}
74 {{ $titleCls := "font-medium text-sm dark:text-white flex items-center gap-2" }}
75 {{ $descCls := "text-xs text-gray-500 dark:text-gray-400" }}
76 <div class="flex gap-1 p-1.5 rounded-md bg-slate-100 dark:bg-gray-900 border dark:border-gray-700 items-center justify-stretch"
77 hx-on::before-request="const t=event.target.closest('button'); if(!t||t.classList.contains('shadow-sm'))return event.preventDefault();">
78 {{ if .RepoInfo.Roles.IsPushAllowed }}
79 <button
80 type="button"
81 class='{{ $shared }} {{ if eq .Source "branch" }}{{ $active }}{{ else }}{{ $inactive }}{{ end }}'
82 hx-post="/{{ .RepoInfo.RepoDid }}/pulls/new/refresh"
83 hx-vals='{"source": "branch"}'
84 hx-include="closest form"
85 hx-target="#pr-compose-host"
86 hx-swap="outerHTML"
87 hx-indicator="this"
88 >
89 <span class="{{ $titleCls }}">
90 Compare branches
91 {{ i "loader-circle" "size-3 animate-spin hidden group-[.htmx-request]:inline" }}
92 </span>
93 <span class="{{ $descCls }}">Select a source branch</span>
94 </button>
95 {{ end }}
96 <button
97 type="button"
98 class='{{ $shared }} {{ if eq .Source "fork" }}{{ $active }}{{ else }}{{ $inactive }}{{ end }}'
99 hx-post="/{{ .RepoInfo.RepoDid }}/pulls/new/refresh"
100 hx-vals='{"source": "fork"}'
101 hx-include="closest form"
102 hx-target="#pr-compose-host"
103 hx-swap="outerHTML"
104 hx-indicator="this"
105 >
106 <span class="{{ $titleCls }}">
107 Compare forks
108 {{ i "loader-circle" "size-3 animate-spin hidden group-[.htmx-request]:inline" }}
109 </span>
110 <span class="{{ $descCls }}">Select a fork and branch as the source</span>
111 </button>
112 <button
113 type="button"
114 disabled
115 class='{{ $shared }} cursor-not-allowed {{ if eq .Source "patch" }}{{ $active }}{{ else }}{{ $inactive }}{{ end }}'
116 hx-post="/{{ .RepoInfo.RepoDid }}/pulls/new/refresh"
117 hx-vals='{"source": "patch"}'
118 hx-include="closest form"
119 hx-target="#pr-compose-host"
120 hx-swap="outerHTML"
121 hx-indicator="this"
122 >
123 <span class="{{ $titleCls }}">
124 Paste patch
125 {{ i "loader-circle" "size-3 animate-spin hidden group-[.htmx-request]:inline" }}
126 </span>
127 <span class="{{ $descCls }}">Paste a <code class="font-mono">git diff</code> or <code class="font-mono">git format-patch</code></span>
128 </button>
129 </div>
130{{ end }}