This repository has no description
7.3 kB
156 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
32 {{ if ne .Source "patch" }}
33 <div class="flex items-center gap-2">
34 <input type="checkbox" id="mode-stack" name="mode" value="stack" autocomplete="off" {{ if .IsStacked }}checked{{ end }}
35 hx-post="/{{ .RepoInfo.FullName }}/pulls/new/refresh"
36 hx-include="closest form"
37 hx-target="#pr-compose-host"
38 hx-swap="outerHTML"
39 hx-trigger="change"
40 hx-indicator="this"
41 class="peer">
42 <label for="mode-stack" class="my-0 py-0 normal-case font-normal dark:text-white">
43 Submit as stacked PRs
44 </label>
45 <a
46 href="https://blog.tangled.org/stacking"
47 target="_blank"
48 rel="noopener noreferrer"
49 aria-label="What are stacked PRs?"
50 class="text-gray-500 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white peer-[.htmx-request]:hidden"
51 >
52 {{ i "circle-question-mark" "size-4" }}
53 </a>
54 {{ i "loader-circle" "size-4 animate-spin hidden peer-[.htmx-request]:inline text-gray-500 dark:text-gray-400" }}
55 </div>
56 {{ end }}
57 </section>
58{{ end }}
59
60{{ define "pullTargetBranchSelect" }}
61 <div class="flex flex-wrap gap-2 items-center">
62 <select
63 id="targetBranch"
64 name="targetBranch"
65 required
66 hx-post="/{{ .RepoInfo.FullName }}/pulls/new/refresh"
67 hx-include="closest form"
68 hx-target="#pr-compose-host"
69 hx-swap="outerHTML"
70 hx-trigger="change"
71 hx-indicator="this"
72 class="peer p-1 border border-gray-200 bg-white dark:bg-gray-700 dark:text-white dark:border-gray-600"
73 >
74 <option disabled {{ if not .TargetBranch }}selected{{ end }}>Target branch</option>
75 {{ $disableSource := and (eq .Source "branch") $.SourceBranch }}
76 {{ range .Branches }}
77 {{ $preset := false }}
78 {{ if $.TargetBranch }}
79 {{ $preset = eq .Reference.Name $.TargetBranch }}
80 {{ else }}
81 {{ $preset = .IsDefault }}
82 {{ end }}
83 {{ $isSource := and $disableSource (eq .Reference.Name $.SourceBranch) }}
84 <option value="{{ .Reference.Name }}" class="py-1"
85 {{ if $preset }}selected{{ end }}
86 {{ if $isSource }}disabled{{ end }}>
87 {{ .Reference.Name }}
88 {{ if $isSource }}(source){{ end }}
89 </option>
90 {{ end }}
91 </select>
92 {{ i "loader-circle" "size-4 animate-spin hidden peer-[.htmx-request]:inline text-gray-500 dark:text-gray-400" }}
93 </div>
94{{ end }}
95
96{{ define "pullSourceTabs" }}
97 {{ $active := "bg-white dark:bg-gray-800 shadow-sm cursor-default" }}
98 {{ $inactive := "bg-transparent hover:bg-white/50 dark:hover:bg-gray-800/50" }}
99 {{ $shared := "group flex-1 p-3 text-left hover:no-underline flex flex-col gap-1 rounded border-0" }}
100 {{ $titleCls := "font-medium text-sm dark:text-white flex items-center gap-2" }}
101 {{ $descCls := "text-xs text-gray-500 dark:text-gray-400" }}
102 {{ $fullName := .RepoInfo.FullName }}
103 <div class="flex gap-1 p-1 rounded-md bg-slate-100 dark:bg-gray-900"
104 hx-on::before-request="const t=event.target.closest('button'); if(!t||t.classList.contains('shadow-sm'))return event.preventDefault();">
105 {{ if .RepoInfo.Roles.IsPushAllowed }}
106 <button
107 type="button"
108 class="{{ $shared }} {{ if eq .Source "branch" }}{{ $active }}{{ else }}{{ $inactive }}{{ end }}"
109 hx-post="/{{ $fullName }}/pulls/new/refresh"
110 hx-vals='{"source": "branch"}'
111 hx-include="closest form"
112 hx-target="#pr-compose-host"
113 hx-swap="outerHTML"
114 hx-indicator="this"
115 >
116 <span class="{{ $titleCls }}">
117 Compare branches
118 {{ i "loader-circle" "size-3 animate-spin hidden group-[.htmx-request]:inline" }}
119 </span>
120 <span class="{{ $descCls }}">Select a source branch</span>
121 </button>
122 {{ end }}
123 <button
124 type="button"
125 class="{{ $shared }} {{ if eq .Source "fork" }}{{ $active }}{{ else }}{{ $inactive }}{{ end }}"
126 hx-post="/{{ $fullName }}/pulls/new/refresh"
127 hx-vals='{"source": "fork"}'
128 hx-include="closest form"
129 hx-target="#pr-compose-host"
130 hx-swap="outerHTML"
131 hx-indicator="this"
132 >
133 <span class="{{ $titleCls }}">
134 Compare forks
135 {{ i "loader-circle" "size-3 animate-spin hidden group-[.htmx-request]:inline" }}
136 </span>
137 <span class="{{ $descCls }}">Select a fork and branch as the source</span>
138 </button>
139 <button
140 type="button"
141 class="{{ $shared }} {{ if eq .Source "patch" }}{{ $active }}{{ else }}{{ $inactive }}{{ end }}"
142 hx-post="/{{ $fullName }}/pulls/new/refresh"
143 hx-vals='{"source": "patch"}'
144 hx-include="closest form"
145 hx-target="#pr-compose-host"
146 hx-swap="outerHTML"
147 hx-indicator="this"
148 >
149 <span class="{{ $titleCls }}">
150 Paste patch
151 {{ i "loader-circle" "size-3 animate-spin hidden group-[.htmx-request]:inline" }}
152 </span>
153 <span class="{{ $descCls }}">Paste a <code class="font-mono">git diff</code> or <code class="font-mono">git format-patch</code></span>
154 </button>
155 </div>
156{{ end }}