| 1 |
{% extends "base.html" %} |
| 2 |
{% import "settings_tabs.html" as t %} |
| 3 |
{% block title %}Tokens{% endblock %} |
| 4 |
{% block tabs %}{% call t::tabs("tokens") %}{% endblock %} |
| 5 |
{% block content %} |
| 6 |
<script type="application/json" id="backdrop-data">{"scene":"mark"}</script> |
| 7 |
{% include "backdrop.html" %} |
| 8 |
<div data-backdrop-avoid> |
| 9 |
<div class="head"><h1>Personal access tokens <small>{{ me.username }} · for oxy and the API</small></h1></div> |
| 10 |
{% if let Some(n) = notice %}<p class="note">{{ n }}</p>{% endif %} |
| 11 |
{% if let Some(e) = error %}<p class="error">{{ e }}</p>{% endif %} |
| 12 |
{% if let Some(f) = fresh %} |
| 13 |
<section class="card-box token-fresh"> |
| 14 |
<div class="card-head"><h2>Your new token</h2><span class="small mute more">shown once: copy it now</span></div> |
| 15 |
<div class="pad"><p class="secret">{{ f }}</p> |
| 16 |
<p class="small mute">In a checkout: <code>oxy config remote.<name>.token {{ f }}</code>, or set <code>OXY_TOKEN</code>.</p></div> |
| 17 |
</section> |
| 18 |
{% endif %} |
| 19 |
<section class="card-box"> |
| 20 |
<div class="card-head"><h2>Tokens</h2><span class="count-chip">{{ tokens.len() }}</span></div> |
| 21 |
{% if tokens.is_empty() %}<p class="empty small pad">No tokens yet.</p>{% else %} |
| 22 |
<ul class="rows token-rows"> |
| 23 |
{% for t in tokens %} |
| 24 |
<li> |
| 25 |
<div class="token-main"> |
| 26 |
<div class="token-name"><strong>{{ t.name }}</strong>{% if t.agent %} <span class="pill agent-pill" title="What is done with this token is told to you">agent</span>{% endif %}</div> |
| 27 |
<div class="token-scopes">{% for sc in t.scopes.split(',') %}<code class="chip">{{ sc }}</code>{% endfor %}{% if !t.repos.is_empty() %} <span class="small mute">only {{ t.repos }}</span>{% endif %}</div> |
| 28 |
<div class="small mute">created <time title="{{ t.created_ms|when_i }}">{{ t.created_ms|ago_i }}</time> · last used {% if let Some(u) = t.last_used_ms %}<time title="{{ u|when_i }}">{{ u|ago_i }}</time>{% else %}never{% endif %} · {% if let Some(x) = t.expires_ms %}expires {{ x|when_i }}{% if t.renew_ms.is_some() %} (renewed on use){% endif %}{% else %}never expires{% endif %}</div> |
| 29 |
</div> |
| 30 |
<div class="token-actions"> |
| 31 |
<form class="inline" method="post" action="/settings/tokens/{{ t.id }}/agent"><input type="hidden" name="_csrf" value="{{ shell.csrf }}"><button class="small" title="{% if t.agent %}Stop telling me what is done with it{% else %}An agent uses this token: tell me what it does{% endif %}">{% if t.agent %}Not an agent{% else %}Mark as agent{% endif %}</button></form> |
| 32 |
<form class="inline" method="post" action="/settings/tokens/{{ t.id }}/delete"><input type="hidden" name="_csrf" value="{{ shell.csrf }}"><button class="small danger">Delete</button></form> |
| 33 |
</div> |
| 34 |
</li> |
| 35 |
{% endfor %} |
| 36 |
</ul> |
| 37 |
{% endif %} |
| 38 |
</section> |
| 39 |
<section class="card-box"> |
| 40 |
<div class="card-head"><h2>New token</h2></div> |
| 41 |
<form class="pad token-form" method="post" action="/settings/tokens"> |
| 42 |
<input type="hidden" name="_csrf" value="{{ shell.csrf }}"> |
| 43 |
<label for="name">Name</label><input type="text" id="name" name="name" required placeholder="laptop, CI, …"> |
| 44 |
<label>Scopes</label> |
| 45 |
<div class="scopes"> |
| 46 |
{% for (name, what) in scopes %}<label><input type="checkbox" name="scopes" value="{{ name }}"{% if *name == "repo:read" || *name == "repo:write" %} checked{% endif %}> <code>{{ name }}</code> <span class="small mute">{{ what }}</span></label>{% endfor %} |
| 47 |
</div> |
| 48 |
<label for="repos">Only these repositories (comma-separated owner/name; empty for all)</label><input type="text" id="repos" name="repos"> |
| 49 |
<label for="expires_days">Expires after (days; empty for never)</label><input type="number" id="expires_days" name="expires_days" min="1"> |
| 50 |
<label class="choice token-agent"><input type="checkbox" name="agent" value="1"> An agent uses this token: tell me what it does</label> |
| 51 |
<p class="small mute token-hint">Proposals it opens, comments it makes and the rest reach your inbox and email like anyone else's would.</p> |
| 52 |
<button type="submit">CREATE TOKEN</button> |
| 53 |
</form> |
| 54 |
</section> |
| 55 |
</div> |
| 56 |
{% endblock %} |