forked from
tangled.org/core
Monorepo for Tangled — https://tangled.org
1{{ define "title" }}new pull · {{ .RepoInfo.FullName }}{{ end }}
2
3{{ define "repoContent" }}
4 <h2 class="font-bold text-sm mb-4 uppercase dark:text-white">
5 Create new pull request
6 </h2>
7
8 <form
9 hx-post="/{{ .RepoInfo.FullName }}/pulls/new"
10 hx-indicator="#create-pull-spinner"
11 hx-swap="none"
12 >
13 <div class="flex flex-col gap-6">
14 <div class="flex gap-2 items-center">
15 <p>First, choose a target branch on {{ .RepoInfo.FullName }}:</p>
16 <div>
17 <select
18 required
19 name="targetBranch"
20 class="p-1 border border-gray-200 bg-white dark:bg-gray-700 dark:text-white dark:border-gray-600"
21 >
22 <option disabled selected>target branch</option>
23
24
25 {{ range .Branches }}
26
27 {{ $preset := false }}
28 {{ if $.TargetBranch }}
29 {{ $preset = eq .Reference.Name $.TargetBranch }}
30 {{ else }}
31 {{ $preset = .IsDefault }}
32 {{ end }}
33
34 <option value="{{ .Reference.Name }}" class="py-1" {{if $preset}}selected{{end}}>
35 {{ .Reference.Name }}
36 </option>
37 {{ end }}
38 </select>
39 </div>
40 </div>
41
42 <div class="flex flex-col gap-2">
43 <h2 class="font-bold text-sm mb-4 uppercase dark:text-white">
44 Choose pull strategy
45 </h2>
46 <nav class="flex space-x-4 items-center">
47 <button
48 type="button"
49 class="btn"
50 hx-get="/{{ .RepoInfo.FullName }}/pulls/new/patch-upload"
51 hx-target="#patch-strategy"
52 hx-swap="innerHTML"
53 >
54 paste patch
55 </button>
56
57 {{ if .RepoInfo.Roles.IsPushAllowed }}
58 <span class="text-sm text-gray-500 dark:text-gray-400">
59 or
60 </span>
61 <button
62 type="button"
63 class="btn"
64 hx-get="/{{ .RepoInfo.FullName }}/pulls/new/compare-branches"
65 hx-target="#patch-strategy"
66 hx-swap="innerHTML"
67 >
68 compare branches
69 </button>
70 {{ end }}
71
72
73 <span class="text-sm text-gray-500 dark:text-gray-400">
74 or
75 </span>
76 <script>
77 function getQueryParams() {
78 return Object.fromEntries(new URLSearchParams(window.location.search));
79 }
80 </script>
81 <!--
82 since compare-forks need the server to load forks, we
83 hx-get this button; unlike simply loading the pullCompareForks template
84 as we do for the rest of the gang below. the hx-vals thing just populates
85 the query params so the forks page gets it.
86 -->
87 <button
88 type="button"
89 class="btn"
90 hx-get="/{{ .RepoInfo.FullName }}/pulls/new/compare-forks"
91 hx-target="#patch-strategy"
92 hx-swap="innerHTML"
93 {{ if eq .Strategy "fork" }}
94 hx-trigger="click, load"
95 hx-vals='js:{...getQueryParams()}'
96 {{ end }}
97 >
98 compare forks
99 </button>
100
101
102 </nav>
103 <section id="patch-strategy" class="flex flex-col gap-2">
104 {{ if eq .Strategy "patch" }}
105 {{ template "repo/pulls/fragments/pullPatchUpload" . }}
106 {{ else if eq .Strategy "branch" }}
107 {{ template "repo/pulls/fragments/pullCompareBranches" . }}
108 {{ else }}
109 {{ template "repo/pulls/fragments/pullPatchUpload" . }}
110 {{ end }}
111 </section>
112
113 <div id="patch-error" class="error dark:text-red-300"></div>
114 </div>
115
116 <div>
117 <label for="title" class="dark:text-white">write a title</label>
118
119 <input
120 type="text"
121 name="title"
122 id="title"
123 value="{{ .Title }}"
124 class="w-full dark:bg-gray-700 dark:text-white dark:border-gray-600"
125 placeholder="One-line summary of your change."
126 />
127 </div>
128
129 <div>
130 <label for="body" class="dark:text-white"
131 >add a description</label
132 >
133
134 <textarea
135 name="body"
136 id="body"
137 rows="6"
138 class="w-full resize-y dark:bg-gray-700 dark:text-white dark:border-gray-600"
139 placeholder="Describe your change. Markdown is supported."
140 >{{ .Body }}</textarea>
141 </div>
142
143 <div class="flex justify-start items-center gap-2 mt-4">
144 <button type="submit" class="btn flex items-center gap-2">
145 {{ i "git-pull-request-create" "w-4 h-4" }}
146 create pull
147 <span id="create-pull-spinner" class="group">
148 {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }}
149 </span>
150 </button>
151 </div>
152 </div>
153 <div id="pull" class="error dark:text-red-300"></div>
154 </form>
155{{ end }}