arche / internal/archesrv/templates/srv_repo_settings.html

commit 154431fd
  1{{ define "title" }}{{.Repo}} — settings{{ end }}
  2{{ define "navextra" }}<a href="/{{.Repo}}">{{.Repo}}</a> <a href="/{{.Repo}}/log">log</a> <a href="/{{.Repo}}/tree">tree</a> <a href="/{{.Repo}}/issues">issues</a> <a href="/{{.Repo}}/stacks">stacks</a> <a href="/{{.Repo}}/wiki">wiki</a> <a href="/{{.Repo}}/settings">settings</a>{{ end }}
  3{{ define "srv_repo_settings.html" }}{{ template "head" . }}
  4<div class="container">
  5    <h2 style="margin-bottom: 16px">{{.Repo}} / settings</h2>
  6    {{ if .Error }}
  7    <p class="error">{{.Error}}</p>
  8    {{ end }}
  9    <section style="margin-bottom: 32px">
 10        <h3 style="margin-bottom: 12px; font-size: 15px">General</h3>
 11        <form method="post" action="/{{.Repo}}/settings">
 12            <div class="field">
 13                <label>Description</label>
 14                <input type="text"
 15                       name="description"
 16                       value="{{.Description}}"
 17                       style="width: 400px" />
 18            </div>
 19            <div class="field">
 20                <label>Visibility</label>
 21                <select name="visibility"
 22                        style="padding: 6px 8px;
 23                               border: 1px solid #ccc;
 24                               border-radius: 3px;
 25                               font-size: 13px">
 26                    <option value="public" {{ if eq .Visibility "public" }}selected{{ end }}>Public
 27                    </option>
 28                    <option value="private" {{ if eq .Visibility "private" }}selected{{ end }}>Private
 29                    </option>
 30                </select>
 31            </div>
 32            <button type="submit">Save</button>
 33        </form>
 34    </section>
 35    <section style="margin-bottom: 32px">
 36        <h3 style="margin-bottom: 12px; font-size: 15px">Collaborators</h3>
 37        {{ if .Collaborators }}
 38        <table style="margin-bottom: 16px">
 39            <thead>
 40                <tr>
 41                    <th>Username</th>
 42                    <th>Role</th>
 43                    <th></th>
 44                </tr>
 45            </thead>
 46            <tbody>
 47                {{ range .Collaborators }}
 48                <tr>
 49                    <td>{{.Username}}</td>
 50                    <td style="font-size: 12px; color: #666">{{.Role}}</td>
 51                    <td>
 52                        <button onclick="removeCollab({{.UserID}})"
 53                                style="background: #c0392b;
 54                                       font-size: 12px;
 55                                       padding: 2px 8px">Remove</button>
 56                    </td>
 57                </tr>
 58                {{ end }}
 59            </tbody>
 60        </table>
 61    {{ else }}
 62        <p style="color: #888; margin-bottom: 16px">No collaborators yet.</p>
 63        {{ end }}
 64        <details>
 65            <summary style="cursor: pointer; font-size: 13px; color: #555">Add collaborator</summary>
 66            <form method="post"
 67                  action="/{{.Repo}}/settings/collaborators"
 68                  style="margin-top: 12px">
 69                <div class="field">
 70                    <label>Username</label>
 71                    <input type="text"
 72                           name="username"
 73                           required
 74                           style="width: 280px"
 75                           placeholder="username" />
 76                </div>
 77                <div class="field">
 78                    <label>Role</label>
 79                    <select name="role"
 80                            style="padding: 6px 8px;
 81                                   border: 1px solid #ccc;
 82                                   border-radius: 3px;
 83                                   font-size: 13px">
 84                        <option value="read">read</option>
 85                        <option value="write">write</option>
 86                        <option value="admin">admin</option>
 87                    </select>
 88                </div>
 89                <button type="submit">Add</button>
 90            </form>
 91        </details>
 92    </section>
 93    <section style="border: 1px solid #f5c6cb;
 94                    border-radius: 4px;
 95                    padding: 16px;
 96                    background: #fff8f8">
 97        <h3 style="margin-bottom: 12px; font-size: 15px; color: #721c24">Danger zone</h3>
 98        <p style="font-size: 13px; color: #555; margin-bottom: 12px">
 99            Deleting this repository is permanent. All data will be lost.
100        </p>
101        <button onclick="deleteRepo()" style="background: #c0392b; font-size: 13px">Delete repository</button>
102    </section>
103</div>
104<script>
105  function removeCollab(userID) {
106    if (!confirm("Remove this collaborator?")) return;
107    fetch(
108      "/{{.Repo}}/settings/collaborators/" + userID,
109      { method: "DELETE" },
110    ).then(function (r) {
111      if (r.ok) {
112        location.reload();
113      } else {
114        r.text().then(alert);
115      }
116    });
117  }
118
119  function deleteRepo() {
120    if (
121      !confirm(
122        "Permanently delete {{.Repo}}? This cannot be undone.",
123      )
124    )
125      return;
126    fetch("/{{.Repo}}/settings/delete", { method: "POST" }).then(
127      function (r) {
128        if (r.ok) {
129          window.location.href = "/";
130        } else {
131          r.text().then(alert);
132        }
133      },
134    );
135  }
136</script>
137{{ template "foot" . }}
138{{ end }}