{{define "content" -}}
<h2>Dolt keys</h2>
{{if .Error}}<div class="alert alert-danger">{{.Error}}</div>{{end}}
{{if .Notice}}<div class="alert alert-success">{{.Notice}}</div>{{end}}
<p>
Associate a dolt Ed25519 credential to clone and push without a personal access
token, like a git SSH key. Run:
</p>
<pre>dolt creds new
dolt login --auth-endpoint {{doltHost .SelfOrigin}} --login-url {{.SelfOrigin}}/settings/keys</pre>
<p>
<code>dolt login</code> opens this page with your public key in the URL; the
field below is filled in automatically. Without JavaScript, paste the
<code>pub key</code> value the command printed.
</p>
<form method="POST" action="/settings/keys">
<div class="form-group">
<label for="pubkey">Public key</label>
<input type="text" class="form-control" name="pubkey" id="pubkey"
autocomplete="off" spellcheck="false">
</div>
<div class="form-group">
<label for="comment">Comment (optional)</label>
<input type="text" class="form-control" name="comment" id="comment" maxlength="256">
</div>
<button type="submit" class="btn btn-primary">Add key</button>
</form>
<div class="header-extension"></div>
<h4>Your keys</h4>
{{if .Keys}}
<table class="table">
<thead><tr><th>Key ID</th><th>Comment</th><th>Added</th><th>Last used</th><th></th></tr></thead>
<tbody>
{{range .Keys}}
<tr>
<td><code>{{.KID}}</code></td>
<td>{{.Comment}}</td>
<td class="text-muted" title="{{.Created | abstime}}">{{.Created | reltime}}</td>
<td class="text-muted">{{if .LastUsed}}{{.LastUsed | reltime}}{{else}}never{{end}}</td>
<td>
<form method="POST" action="/settings/keys" style="display:inline">
<input type="hidden" name="delete_id" value="{{.ID}}">
<button type="submit" class="btn btn-sm btn-danger">Delete</button>
</form>
</td>
</tr>
{{end}}
</tbody>
</table>
{{else}}
<p class="text-muted">No keys registered.</p>
{{end}}
<script>
// Prefill the public key from the URL fragment that `dolt login` appends
// (#<pubkey-base32>). Progressive enhancement only: the page works without JS.
(function () {
if (window.location.hash.length > 1) {
var field = document.getElementById("pubkey");
if (field && !field.value) {
field.value = decodeURIComponent(window.location.hash.substring(1));
}
}
})();
</script>
{{- end}}