Add delete token UI for info page

This commit is contained in:
2026-09-13 00:32:51 +02:00
parent ca34f1506d
commit 74bfdbfd8a
9 changed files with 293 additions and 25 deletions
+41 -1
View File
@@ -6,6 +6,46 @@
<dt>Expires</dt><dd>{{.Expires}}</dd>
<dt>SHA-256</dt><dd class="mono wrap">{{.Meta.SHA256}}</dd>
</dl>
<p><a class="button" href="{{.Base}}d/{{.Meta.ID}}">Download</a></p>
<p class="actions"><a class="button" href="{{.Base}}d/{{.Meta.ID}}">Download</a></p>
<div class="field">
<span>Direct link</span>
<div class="copyrow">
<input type="text" id="link-file" value="{{.URL}}" readonly>
<button type="button" class="copy" data-copy="link-file" hidden>Copy</button>
</div>
</div>
</section>
<section class="card">
<details{{if .Error}} open{{end}}>
<summary>Remove this file</summary>
{{if .Error}}<p class="error">{{.Error}}</p>{{end}}
{{if .CanDelete}}
<p class="hint">Your token can remove this file.</p>
<form method="post" action="{{.Base}}api/d/{{.Meta.ID}}/delete">
<input type="hidden" name="from" value="info">
<button type="submit" class="danger"
data-confirm="Delete {{.Meta.Filename}}? This cannot be undone.">Delete this file</button>
</form>
{{else}}
<p class="hint">
Paste the delete token you were given when this file was uploaded.
It is the only way to remove a file early without an owning token.
</p>
<form method="post" action="{{.Base}}api/d/{{.Meta.ID}}/delete">
<input type="hidden" name="from" value="info">
<label class="field">
<span>Delete token</span>
<input type="password" name="token" autocomplete="off" required>
</label>
<button type="submit" class="danger"
data-confirm="Delete {{.Meta.Filename}}? This cannot be undone.">Delete this file</button>
</form>
{{end}}
</details>
</section>
{{end}}
+7 -2
View File
@@ -29,11 +29,16 @@
<div class="warn">
<h2>Delete token</h2>
<p>Shown once. Keep it if you want to remove the file before it expires.</p>
<p>
Shown once. Keep it alongside the share link: pasting it under
<strong>Remove this file</strong> on that page deletes the file before it
expires.
</p>
<p class="mono wrap">{{.DeleteToken}}</p>
<form method="post" action="{{.Base}}api/d/{{.Meta.ID}}/delete">
<input type="hidden" name="token" value="{{.DeleteToken}}">
<button type="submit" class="danger">Delete it now</button>
<button type="submit" class="danger"
data-confirm="Delete {{.Meta.Filename}}? This cannot be undone.">Delete it now</button>
</form>
</div>