repo_settings.html
·
210 lines
·
10.2 KB
| 1 | {{define "content"}} |
| 2 | <div class="container"> |
| 3 | {{template "repo_header" .}} |
| 4 | |
| 5 | <!-- General Settings --> |
| 6 | <section class="card mb-4"> |
| 7 | <div class="card-header"> |
| 8 | <span class="font-semibold flex items-center gap-2">{{icon "settings" "size-4"}} {{t .Lang "repo.tab.settings"}}</span> |
| 9 | </div> |
| 10 | <form method="post" action="/{{.Repo.OwnerUsername}}/{{.Repo.Name}}/settings" class="card-body flex flex-col gap-3"> |
| 11 | <input type="hidden" name="_csrf" value="{{.CSRFToken}}"> |
| 12 | |
| 13 | <div> |
| 14 | <label class="label" for="description">{{t .Lang "repo.description"}}</label> |
| 15 | <input id="description" name="description" type="text" class="input" value="{{.Repo.Description}}" maxlength="500" placeholder="{{t .Lang "repo.description_ph"}}"> |
| 16 | </div> |
| 17 | |
| 18 | <div class="grid-2"> |
| 19 | <div> |
| 20 | <label class="label" for="default_branch">{{t .Lang "repo.default_branch"}}</label> |
| 21 | <select id="default_branch" name="default_branch" class="select font-mono"> |
| 22 | {{if .Branches}} |
| 23 | {{range .Branches}} |
| 24 | <option value="{{.}}" {{if eq . $.Repo.DefaultBranch}}selected{{end}}>{{.}}</option> |
| 25 | {{end}} |
| 26 | {{else}} |
| 27 | <option value="{{.Repo.DefaultBranch}}" selected>{{.Repo.DefaultBranch}}</option> |
| 28 | {{end}} |
| 29 | </select> |
| 30 | </div> |
| 31 | |
| 32 | <div> |
| 33 | <label class="label" for="visibility">{{t .Lang "repo.visibility"}}</label> |
| 34 | <select id="visibility" name="visibility" class="select"> |
| 35 | <option value="public" {{if not .Repo.IsPrivate}}selected{{end}}>{{t .Lang "repo.public"}}</option> |
| 36 | <option value="private" {{if .Repo.IsPrivate}}selected{{end}}>{{t .Lang "repo.private"}}</option> |
| 37 | </select> |
| 38 | </div> |
| 39 | </div> |
| 40 | |
| 41 | <!-- Feature Toggles for Repository --> |
| 42 | <div class="card p-3 mt-1" style="background:hsl(var(--muted) / 0.25);"> |
| 43 | <div class="font-semibold text-xs text-muted mb-2 uppercase" style="letter-spacing:0.04em;">{{t .Lang "repo.features"}}</div> |
| 44 | <div class="flex flex-col gap-2.5"> |
| 45 | <label class="flex items-center justify-between cursor-pointer"> |
| 46 | <span class="flex items-center gap-2 text-sm font-medium"> |
| 47 | {{icon "issue" "size-4"}} |
| 48 | <span>{{t .Lang "repo.tab.issues"}}</span> |
| 49 | </span> |
| 50 | <input type="checkbox" name="enable_issues" value="true" class="switch" {{if .Repo.EnableIssues}}checked{{end}}> |
| 51 | </label> |
| 52 | <label class="flex items-center justify-between cursor-pointer"> |
| 53 | <span class="flex items-center gap-2 text-sm font-medium"> |
| 54 | {{icon "git-pull-request" "size-4"}} |
| 55 | <span>{{t .Lang "repo.tab.pulls"}}</span> |
| 56 | </span> |
| 57 | <input type="checkbox" name="enable_pulls" value="true" class="switch" {{if .Repo.EnablePulls}}checked{{end}}> |
| 58 | </label> |
| 59 | <label class="flex items-center justify-between cursor-pointer"> |
| 60 | <span class="flex items-center gap-2 text-sm font-medium"> |
| 61 | {{icon "tag" "size-4"}} |
| 62 | <span>{{t .Lang "repo.tab.releases"}}</span> |
| 63 | </span> |
| 64 | <input type="checkbox" name="enable_releases" value="true" class="switch" {{if .Repo.EnableReleases}}checked{{end}}> |
| 65 | </label> |
| 66 | <label class="flex items-center justify-between cursor-pointer"> |
| 67 | <span class="flex items-center gap-2 text-sm font-medium"> |
| 68 | {{icon "activity" "size-4"}} |
| 69 | <span>{{t .Lang "repo.tab.activity"}}</span> |
| 70 | </span> |
| 71 | <input type="checkbox" name="enable_activity" value="true" class="switch" {{if .Repo.EnableActivity}}checked{{end}}> |
| 72 | </label> |
| 73 | </div> |
| 74 | </div> |
| 75 | |
| 76 | <div class="flex items-center justify-end"> |
| 77 | <button type="submit" class="btn btn-primary btn-sm">{{t .Lang "repo.save"}}</button> |
| 78 | </div> |
| 79 | </form> |
| 80 | </section> |
| 81 | |
| 82 | <!-- Collaborators --> |
| 83 | <section class="card mb-4" id="collaborators"> |
| 84 | <div class="card-header"> |
| 85 | <span class="font-semibold flex items-center gap-2">{{icon "users" "size-4"}} {{t .Lang "collab.title"}}</span> |
| 86 | <span class="text-xs text-muted">{{t .Lang "collab.desc"}}</span> |
| 87 | </div> |
| 88 | |
| 89 | <div class="dense-list" style="border-bottom:1px solid hsl(var(--border));"> |
| 90 | <div class="dense-row" style="min-height:2.6rem;padding:0.45rem 0.85rem;"> |
| 91 | <div class="flex items-center gap-2.5 min-w-0"> |
| 92 | {{avatar .Repo.OwnerUsername .Repo.OwnerAvatarURL}} |
| 93 | <div class="min-w-0"> |
| 94 | <a href="/{{.Repo.OwnerUsername}}" class="font-semibold text-sm">{{.Repo.OwnerUsername}}</a> |
| 95 | </div> |
| 96 | </div> |
| 97 | <span class="badge badge-outline">{{t .Lang "collab.owner"}}</span> |
| 98 | </div> |
| 99 | {{range .Collaborators}} |
| 100 | <div class="dense-row" style="min-height:2.6rem;padding:0.45rem 0.85rem;"> |
| 101 | <div class="flex items-center gap-2.5 min-w-0"> |
| 102 | {{avatar .Username .AvatarURL}} |
| 103 | <div class="min-w-0"> |
| 104 | <a href="/{{.Username}}" class="font-semibold text-sm">{{.Username}}</a> |
| 105 | {{if .FullName}}<div class="text-xs text-muted truncate">{{.FullName}}</div>{{end}} |
| 106 | </div> |
| 107 | </div> |
| 108 | <div class="flex items-center gap-2"> |
| 109 | <span class="badge badge-outline font-mono">{{if eq .Role "read"}}{{t $.Lang "collab.role_read"}}{{else}}{{t $.Lang "collab.role_write"}}{{end}}</span> |
| 110 | {{if $.CanManageCollab}} |
| 111 | <form method="post" action="/{{$.Repo.OwnerUsername}}/{{$.Repo.Name}}/settings/collaborators/remove" style="margin:0;"> |
| 112 | <input type="hidden" name="_csrf" value="{{$.CSRFToken}}"> |
| 113 | <input type="hidden" name="user_id" value="{{.UserID}}"> |
| 114 | <button type="submit" class="btn btn-ghost btn-icon" style="width:1.75rem;height:1.75rem;" title="{{t $.Lang "collab.remove"}}"> |
| 115 | {{icon "close" "size-3.5"}} |
| 116 | </button> |
| 117 | </form> |
| 118 | {{end}} |
| 119 | </div> |
| 120 | </div> |
| 121 | {{else}} |
| 122 | <div class="card-body text-xs text-muted">{{t .Lang "collab.empty"}}</div> |
| 123 | {{end}} |
| 124 | </div> |
| 125 | |
| 126 | {{if .CanManageCollab}} |
| 127 | <form method="post" action="/{{.Repo.OwnerUsername}}/{{.Repo.Name}}/settings/collaborators/add" class="card-body flex items-end gap-2 flex-wrap"> |
| 128 | <input type="hidden" name="_csrf" value="{{.CSRFToken}}"> |
| 129 | <div style="flex:1 1 12rem;"> |
| 130 | <label class="label" for="collab_username">{{t .Lang "collab.username"}}</label> |
| 131 | <input id="collab_username" name="username" type="text" class="input font-mono" placeholder="{{t .Lang "collab.username_ph"}}" required> |
| 132 | </div> |
| 133 | <div> |
| 134 | <label class="label" for="collab_role">{{t .Lang "collab.role"}}</label> |
| 135 | <select id="collab_role" name="role" class="select"> |
| 136 | <option value="write">{{t .Lang "collab.role_write"}}</option> |
| 137 | <option value="read">{{t .Lang "collab.role_read"}}</option> |
| 138 | </select> |
| 139 | </div> |
| 140 | <button type="submit" class="btn btn-primary btn-sm"> |
| 141 | {{icon "plus" "size-3.5"}} |
| 142 | <span>{{t .Lang "collab.add"}}</span> |
| 143 | </button> |
| 144 | </form> |
| 145 | {{end}} |
| 146 | </section> |
| 147 | |
| 148 | <!-- Rename Repository --> <section class="card mb-4"> |
| 149 | <div class="card-header"> |
| 150 | <span class="font-semibold flex items-center gap-2">{{icon "edit" "size-4"}} {{t .Lang "repo.rename"}}</span> |
| 151 | </div> |
| 152 | <form method="post" action="/{{.Repo.OwnerUsername}}/{{.Repo.Name}}/settings/rename" class="card-body flex items-center gap-2"> |
| 153 | <input type="hidden" name="_csrf" value="{{.CSRFToken}}"> |
| 154 | <input name="new_name" type="text" class="input font-mono" value="{{.Repo.Name}}" required pattern="^[a-zA-Z0-9][a-zA-Z0-9._-]{0,63}$"> |
| 155 | <button type="submit" class="btn btn-outline">{{t .Lang "repo.rename"}}</button> |
| 156 | </form> |
| 157 | </section> |
| 158 | |
| 159 | <!-- Danger Zone --> |
| 160 | <section class="card" style="border-color:hsl(var(--destructive) / 0.45);"> |
| 161 | <div class="card-header" style="border-bottom-color:hsl(var(--destructive) / 0.2);"> |
| 162 | <span class="font-semibold text-destructive flex items-center gap-2">{{icon "alert-circle" "size-4"}} {{t .Lang "repo.danger_zone"}}</span> |
| 163 | </div> |
| 164 | <div class="card-body flex items-center justify-between flex-wrap gap-3"> |
| 165 | <div> |
| 166 | <div class="font-medium text-sm">{{t .Lang "repo.delete"}}</div> |
| 167 | <div class="text-xs text-muted">{{t .Lang "repo.delete_desc"}}</div> |
| 168 | </div> |
| 169 | <button type="button" class="btn btn-destructive btn-sm" data-dialog-open="delete-repo-dialog"> |
| 170 | {{icon "trash" "size-3.5"}} |
| 171 | <span>{{t .Lang "repo.delete"}}</span> |
| 172 | </button> |
| 173 | </div> |
| 174 | </section> |
| 175 | </div> |
| 176 | |
| 177 | <!-- Delete Confirmation Modal --> |
| 178 | <div id="delete-repo-dialog" class="backdrop" role="dialog" aria-modal="true" aria-label="{{t .Lang "repo.delete"}}" aria-hidden="true"> |
| 179 | <div class="dialog-box"> |
| 180 | <div class="card-header"> |
| 181 | <span class="font-semibold text-destructive flex items-center gap-2">{{icon "trash" "size-4"}} {{t .Lang "repo.delete"}}</span> |
| 182 | <button type="button" class="btn btn-ghost btn-icon" data-dialog-close aria-label="{{t .Lang "common.close"}}">{{icon "close" "size-4"}}</button> |
| 183 | </div> |
| 184 | <form method="post" action="/{{.Repo.OwnerUsername}}/{{.Repo.Name}}/settings/delete"> |
| 185 | <input type="hidden" name="_csrf" value="{{.CSRFToken}}"> |
| 186 | <div class="card-body flex flex-col gap-3"> |
| 187 | <p class="text-sm text-muted" style="margin:0;"> |
| 188 | {{t .Lang "repo.delete_confirm"}}: <strong class="font-mono" style="color:hsl(var(--foreground));">{{.Repo.Name}}</strong> |
| 189 | </p> |
| 190 | <input |
| 191 | type="text" |
| 192 | name="confirm_name" |
| 193 | class="input font-mono" |
| 194 | placeholder="{{.Repo.Name}}" |
| 195 | autocomplete="off" |
| 196 | required |
| 197 | data-confirm-input="{{.Repo.Name}}" |
| 198 | data-confirm-button="confirm-delete-btn"> |
| 199 | </div> |
| 200 | <div class="card-footer flex items-center justify-end gap-2"> |
| 201 | <button type="button" class="btn btn-outline btn-sm" data-dialog-close>{{t .Lang "common.cancel"}}</button> |
| 202 | <button id="confirm-delete-btn" type="submit" class="btn btn-destructive btn-sm" disabled> |
| 203 | {{icon "trash" "size-3.5"}} |
| 204 | <span>{{t .Lang "repo.delete"}}</span> |
| 205 | </button> |
| 206 | </div> |
| 207 | </form> |
| 208 | </div> |
| 209 | </div> |
| 210 | {{end}} |