navid/veinsforge / 7ddba925b0ba65a01574baceaa108a0ca5d633bd247f06c62065a5c6acec6273 / internal/web/templates/repo_settings.html

repo_settings.html

← internal/web/templates · 7318 bytes · raw · download

{{define "content"}}
<section class="page-head">
  <div>
    <p class="kicker"><a href="{{repoURL .Data.Repo}}">{{.Data.Repo.OwnerName}}/{{.Data.Repo.Name}}</a> / SETTINGS</p>
    <h1>Repository settings</h1>
  </div>
  <div class="page-head-actions"><a class="btn" href="{{repoURL .Data.Repo}}">Back to repository</a></div>
</section>

<div class="settings-grid">
  <section class="settings-card wide">
    <h2>General</h2>
    <form method="post" action="{{repoURL .Data.Repo}}/settings" class="stack">
      <input type="hidden" name="csrf" value="{{.CSRF}}">
      <div class="two-col">
        <label>Display name <input name="display_name" value="{{.Data.Repo.DisplayName}}" maxlength="80"></label>
        <label>Default branch
          <input name="default_branch" value="{{.Data.Repo.DefaultBranch}}" list="branches" maxlength="200">
          <datalist id="branches">{{range .Data.Branches}}<option value="{{.Name}}">{{end}}</datalist>
        </label>
      </div>
      <label>Description <textarea name="description" rows="4" maxlength="2000">{{.Data.Repo.Description}}</textarea></label>
      <div class="two-col">
        <label>Visibility
          <select name="visibility">
            <option value="public" {{if eq .Data.Repo.Visibility "public"}}selected{{end}}>Public</option>
            <option value="private" {{if eq .Data.Repo.Visibility "private"}}selected{{end}}>Private</option>
          </select>
        </label>
        <label class="checkbox"><input type="checkbox" name="archived" {{if .Data.Repo.Archived}}checked{{end}}> Archived (read-only web actions)</label>
      </div>
      <button class="btn btn-primary" type="submit">Save settings</button>
    </form>
  </section>

  <section class="settings-card wide">
    <h2>Collaborators</h2>
    <div class="table-wrap">
      <table>
        <thead><tr><th>User</th><th>Role</th><th></th></tr></thead>
        <tbody>
        {{range .Data.Collaborators}}
          <tr>
            <td><img class="avatar avatar-sm" src="{{avatarURL .Username}}" alt="" width="20" height="20"> <a href="/u/{{.Username}}">{{.Username}}</a></td>
            <td><span class="pill">{{roleLabel .Role}}</span></td>
            <td class="right">
              <form method="post" action="{{repoURL $.Data.Repo}}/settings/collaborators/{{.UserID}}/delete" class="inline">
                <input type="hidden" name="csrf" value="{{$.CSRF}}">
                <button class="btn btn-small btn-danger" type="submit">Remove</button>
              </form>
            </td>
          </tr>
        {{else}}
          <tr><td colspan="3" class="muted">No direct collaborators.</td></tr>
        {{end}}
        </tbody>
      </table>
    </div>
    <form method="post" action="{{repoURL .Data.Repo}}/settings/collaborators" class="inline-form">
      <input type="hidden" name="csrf" value="{{.CSRF}}">
      <input name="username" placeholder="username" required maxlength="32">
      <select name="role"><option value="read">Read</option><option value="write">Write</option><option value="admin">Admin</option></select>
      <button class="btn btn-small" type="submit">Add collaborator</button>
    </form>
  </section>

  {{if eq .Data.Repo.OwnerType "org"}}
  <section class="settings-card wide">
    <h2>Team access</h2>
    <div class="table-wrap">
      <table>
        <thead><tr><th>Team</th><th>Permission</th><th></th></tr></thead>
        <tbody>
        {{range .Data.Teams}}
          <tr>
            <td><strong>{{.OrgName}}/{{.TeamName}}</strong></td>
            <td><span class="pill">{{roleLabel .Permission}}</span></td>
            <td class="right">
              <form method="post" action="{{repoURL $.Data.Repo}}/settings/teams/{{.TeamID}}/delete" class="inline">
                <input type="hidden" name="csrf" value="{{$.CSRF}}">
                <button class="btn btn-small btn-danger" type="submit">Remove</button>
              </form>
            </td>
          </tr>
        {{else}}
          <tr><td colspan="3" class="muted">No teams have access.</td></tr>
        {{end}}
        </tbody>
      </table>
    </div>
    <form method="post" action="{{repoURL .Data.Repo}}/settings/teams" class="inline-form">
      <input type="hidden" name="csrf" value="{{.CSRF}}">
      <select name="team_id" required>
        {{range .Data.OrgTeams}}<option value="{{.ID}}">{{.Name}}</option>{{end}}
      </select>
      <select name="permission"><option value="read">Read</option><option value="write">Write</option><option value="admin">Admin</option></select>
      <button class="btn btn-small" type="submit">Grant access</button>
    </form>
  </section>
  {{end}}

  <section class="settings-card wide">
    <h2>Webhooks</h2>
    <p class="muted small">Signed with HMAC-SHA256 in <code>X-Veinsforge-Signature</code>. Private and loopback destinations are blocked.</p>
    <div class="table-wrap">
      <table>
        <thead><tr><th>URL</th><th>Events</th><th>Last status</th><th></th></tr></thead>
        <tbody>
        {{range .Data.Webhooks}}
          <tr>
            <td><code class="break">{{.URL}}</code></td>
            <td>{{.Events}}</td>
            <td>{{if .LastStatus}}{{.LastStatus}}{{else}}—{{end}}</td>
            <td class="right">
              <form method="post" action="{{repoURL $.Data.Repo}}/settings/webhooks/{{.ID}}/delete" class="inline">
                <input type="hidden" name="csrf" value="{{$.CSRF}}">
                <button class="btn btn-small btn-danger" type="submit">Delete</button>
              </form>
            </td>
          </tr>
        {{else}}
          <tr><td colspan="4" class="muted">No webhooks.</td></tr>
        {{end}}
        </tbody>
      </table>
    </div>
    <form method="post" action="{{repoURL .Data.Repo}}/settings/webhooks" class="stack">
      <input type="hidden" name="csrf" value="{{.CSRF}}">
      <label>Endpoint URL <input type="url" name="url" required maxlength="2000" placeholder="https://example.com/hook"></label>
      <label>Secret <span class="muted">(blank to generate)</span><input name="secret" maxlength="256"></label>
      <div class="checkbox-row">
        <label class="checkbox"><input type="checkbox" name="event_issue" checked> Issues</label>
        <label class="checkbox"><input type="checkbox" name="event_pull_request" checked> Pull requests</label>
        <label class="checkbox"><input type="checkbox" name="event_comment" checked> Comments</label>
        <label class="checkbox"><input type="checkbox" name="event_star" checked> Stars</label>
        <label class="checkbox"><input type="checkbox" name="event_repository" checked> Repository</label>
      </div>
      <button class="btn btn-primary" type="submit">Add webhook</button>
    </form>
  </section>

  <section class="settings-card wide danger">
    <h2>Danger zone</h2>
    <p>Deleting the repository removes its SQLite metadata and its veins object storage. This cannot be undone.</p>
    <form method="post" action="{{repoURL .Data.Repo}}/settings/delete" class="inline-form">
      <input type="hidden" name="csrf" value="{{.CSRF}}">
      <input name="confirm" placeholder="type {{.Data.Repo.Name}} to confirm" required>
      <button class="btn btn-danger" type="submit">Delete repository</button>
    </form>
  </section>
</div>
{{end}}