this repo has no description
1{{ define "title" }} 2 {{ if and .Head .Base }} 3 comparing {{ .Base }} and 4 {{ .Head }} 5 {{ else }} 6 new comparison 7 {{ end }} 8{{ end }} 9 10{{ define "repoContent" }} 11 <section> 12 <h2 class="font-bold text-sm mb-4 uppercase dark:text-white"> 13 Compare changes 14 </h2> 15 <p>Choose any two refs to compare.</p> 16 17 <form id="compare-form"> 18 <div class="flex items-center gap-2 py-4"> 19 <div> 20 base: 21 22 <select 23 name="base" 24 id="base-select" 25 class="p-1 border max-w-32 border-gray-200 bg-white dark:bg-gray-800 dark:text-white dark:border-gray-700" 26 onchange="triggerCompare()" 27 > 28 <optgroup 29 label="branches ({{ len .Branches }})" 30 class="bold text-sm" 31 > 32 {{ range .Branches }} 33 <option 34 value="{{ .Reference.Name }}" 35 class="py-1" 36 {{ if .IsDefault }} 37 selected 38 {{ end }} 39 > 40 {{ .Reference.Name }} 41 </option> 42 {{ end }} 43 </optgroup> 44 <optgroup 45 label="tags ({{ len .Tags }})" 46 class="bold text-sm" 47 > 48 {{ range .Tags }} 49 <option 50 value="{{ .Reference.Name }}" 51 class="py-1" 52 > 53 {{ .Reference.Name }} 54 </option> 55 {{ else }} 56 <option class="py-1" disabled> 57 no tags found 58 </option> 59 {{ end }} 60 </optgroup> 61 </select> 62 </div> 63 64 {{ i "arrow-left" "w-4 h-4" }} 65 66 67 <div> 68 compare: 69 70 <select 71 name="head" 72 id="head-select" 73 class="p-1 border max-w-32 border-gray-200 bg-white dark:bg-gray-800 dark:text-white dark:border-gray-700" 74 onchange="triggerCompare()" 75 > 76 <option value="" selected disabled hidden> 77 select a branch or tag 78 </option> 79 <optgroup 80 label="branches ({{ len .Branches }})" 81 class="bold text-sm" 82 > 83 {{ range .Branches }} 84 <option 85 value="{{ .Reference.Name }}" 86 class="py-1" 87 > 88 {{ .Reference.Name }} 89 </option> 90 {{ end }} 91 </optgroup> 92 <optgroup 93 label="tags ({{ len .Tags }})" 94 class="bold text-sm" 95 > 96 {{ range .Tags }} 97 <option 98 value="{{ .Reference.Name }}" 99 class="py-1" 100 > 101 {{ .Reference.Name }} 102 </option> 103 {{ else }} 104 <option class="py-1" disabled> 105 no tags found 106 </option> 107 {{ end }} 108 </optgroup> 109 </select> 110 </div> 111 </div> 112 </form> 113 </section> 114 115 <script> 116 var templatedBase = `{{ .Base }}`; 117 var templatedHead = `{{ .Head }}`; 118 var selectedBase = ""; 119 var selectedHead = ""; 120 121 document.addEventListener('DOMContentLoaded', function() { 122 if (templatedBase && templatedHead) { 123 const baseSelect = document.getElementById('base-select'); 124 const headSelect = document.getElementById('head-select'); 125 126 // select the option that matches templated values 127 for(let i = 0; i < baseSelect.options.length; i++) { 128 if(baseSelect.options[i].value === templatedBase) { 129 baseSelect.selectedIndex = i; 130 break; 131 } 132 } 133 134 for(let i = 0; i < headSelect.options.length; i++) { 135 if(headSelect.options[i].value === templatedHead) { 136 headSelect.selectedIndex = i; 137 break; 138 } 139 } 140 141 triggerCompare(); 142 } 143 }); 144 145 function triggerCompare() { 146 // if user has selected values, use those 147 selectedBase = document.getElementById('base-select').value; 148 selectedHead = document.getElementById('head-select').value; 149 150 const baseToUse = templatedBase && !selectedBase ? templatedBase : selectedBase; 151 const headToUse = templatedHead && !selectedHead ? templatedHead : selectedHead; 152 153 if (baseToUse && headToUse) { 154 const url = `/{{ .RepoInfo.FullName }}/compare/diff/${baseToUse}/${headToUse}`; 155 htmx.ajax('GET', url, { target: '#compare-diff' }); 156 document.title = `comparing ${baseToUse} and ${headToUse}`; 157 158 const allowPull = `{{ .AllowPull }}` 159 if (allowPull) { 160 htmx.ajax('GET', 161 `/{{ .RepoInfo.FullName }}/compare/allow-pull/${baseToUse}/${headToUse}`, 162 { target: '#allow-pull'}, 163 ) 164 } 165 } 166 } 167 </script> 168 <section id="allow-pull" class="pt-4"></section> 169{{ end }} 170 171{{ define "repoAfter" }} 172 <div id="compare-diff"></div> 173{{ end }}