|
1
|
{% extends "base.html" %} |
|
2
|
{% block title %}Generate API Token — {{ project.name }} — Fossilrepo{% endblock %} |
|
3
|
|
|
4
|
{% block content %} |
|
5
|
<h1 class="text-2xl font-bold text-gray-100 mb-2">{{ project.name }}</h1> |
|
6
|
{% include "fossil/_project_nav.html" %} |
|
7
|
|
|
8
|
<div class="mb-4"> |
|
9
|
<a href="{% url 'fossil:api_tokens' slug=project.slug %}" class="text-sm text-brand-light hover:text-brand">← Back to Tokens</a> |
|
10
|
</div> |
|
11
|
|
|
12
|
{% if raw_token %} |
|
13
|
<div class="mx-auto max-w-3xl"> |
|
14
|
<div class="rounded-lg bg-green-900/20 border border-green-800 p-6 mb-6"> |
|
15
|
<h2 class="text-lg font-bold text-green-300 mb-2">Token Generated</h2> |
|
16
|
<p class="text-sm text-gray-300 mb-4">Copy this token now. It will not be shown again.</p> |
|
17
|
<div class="flex items-center gap-2" x-data="{ copied: false }"> |
|
18
|
<input type="text" readonly value="{{ raw_token }}" |
|
19
|
class="flex-1 rounded-md border-gray-700 bg-gray-900 text-gray-100 text-sm px-3 py-2 font-mono" |
|
20
|
id="token-value"> |
|
21
|
<button @click="navigator.clipboard.writeText(document.getElementById('token-value').value); copied = true; setTimeout(() => copied = false, 2000)" |
|
22
|
:class="copied ? 'bg-green-700 text-green-100' : 'bg-gray-700 text-gray-200 hover:bg-gray-600'" |
|
23
|
class="rounded-md px-3 py-2 text-sm font-medium transition-colors"> |
|
24
|
<span x-show="!copied">Copy</span> |
|
25
|
<span x-show="copied">Copied</span> |
|
26
|
</button> |
|
27
|
</div> |
|
28
|
</div> |
|
29
|
<a href="{% url 'fossil:api_tokens' slug=project.slug %}" |
|
30
|
class="inline-flex items-center rounded-md bg-gray-700 px-4 py-2 text-sm font-semibold text-gray-100 shadow-sm ring-1 ring-inset ring-gray-600 hover:bg-gray-600"> |
|
31
|
Done |
|
32
|
</a> |
|
33
|
</div> |
|
34
|
{% else %} |
|
35
|
<div class="mx-auto max-w-3xl"> |
|
36
|
<h2 class="text-xl font-bold text-gray-100 mb-4">Generate API Token</h2> |
|
37
|
|
|
38
|
<form method="post" class="space-y-4 rounded-lg bg-gray-800 p-6 shadow border border-gray-700"> |
|
39
|
{% csrf_token %} |
|
40
|
|
|
41
|
<div> |
|
42
|
<label class="block text-sm font-medium text-gray-300 mb-1">Name <span class="text-red-400">*</span></label> |
|
43
|
<input type="text" name="name" required placeholder="e.g., GitHub Actions CI" |
|
44
|
class="w-full rounded-md border-gray-700 bg-gray-800 text-gray-100 shadow-sm focus:border-brand focus:ring-brand sm:text-sm"> |
|
45
|
<p class="mt-1 text-xs text-gray-500">A descriptive name to identify this token.</p> |
|
46
|
</div> |
|
47
|
|
|
48
|
<div> |
|
49
|
<label class="block text-sm font-medium text-gray-300 mb-1">Permissions</label> |
|
50
|
<input type="text" name="permissions" value="status:write" placeholder="status:write" |
|
51
|
class="w-full rounded-md border-gray-700 bg-gray-800 text-gray-100 shadow-sm focus:border-brand focus:ring-brand sm:text-sm font-mono"> |
|
52
|
<p class="mt-1 text-xs text-gray-500">Comma-separated permissions. Available: <code class="text-gray-400">read</code>, <code class="text-gray-400">write</code>, <code class="text-gray-400">status:write</code> (CI status reporting only), <code class="text-gray-400">admin</code></p> |
|
53
|
</div> |
|
54
|
|
|
55
|
<div> |
|
56
|
<label class="block text-sm font-medium text-gray-300 mb-1">Expiration</label> |
|
57
|
<input type="datetime-local" name="expires_at" |
|
58
|
class="w-full rounded-md border-gray-700 bg-gray-800 text-gray-100 shadow-sm focus:border-brand focus:ring-brand sm:text-sm"> |
|
59
|
<p class="mt-1 text-xs text-gray-500">Optional. Leave blank for no expiration.</p> |
|
60
|
</div> |
|
61
|
|
|
62
|
<div class="flex justify-end gap-3 pt-2"> |
|
63
|
<a href="{% url 'fossil:api_tokens' slug=project.slug %}" |
|
64
|
class="rounded-md bg-gray-700 px-4 py-2 text-sm font-semibold text-gray-100 shadow-sm ring-1 ring-inset ring-gray-600 hover:bg-gray-600"> |
|
65
|
Cancel |
|
66
|
</a> |
|
67
|
<button type="submit" class="rounded-md bg-brand px-4 py-2 text-sm font-semibold text-white shadow-sm hover:bg-brand-hover"> |
|
68
|
Generate Token |
|
69
|
</button> |
|
70
|
</div> |
|
71
|
</form> |
|
72
|
</div> |
|
73
|
{% endif %} |
|
74
|
{% endblock %} |
|
75
|
|