Add friendly aliases for client proofing links

This commit is contained in:
2026-10-04 15:49:06 +03:00
parent c172d170ae
commit 15dcbf904e
6 changed files with 350 additions and 110 deletions

View File

@@ -52,6 +52,7 @@ function CreateForm({ onCreated }: { onCreated: () => void }) {
const [albums, setAlbums] = useState<AlbumOption[] | null>(null);
const [clientName, setClientName] = useState('');
const [albumId, setAlbumId] = useState('');
const [alias, setAlias] = useState('');
const [expiresOn, setExpiresOn] = useState('');
const [download, setDownload] = useState<Download>('none');
const [limit, setLimit] = useState('');
@@ -76,6 +77,7 @@ function CreateForm({ onCreated }: { onCreated: () => void }) {
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
clientName,
alias: alias.trim() || null,
albumId,
expiresOn: expiresOn || null,
download,
@@ -83,6 +85,7 @@ function CreateForm({ onCreated }: { onCreated: () => void }) {
}),
});
setClientName('');
setAlias('');
setAlbumId('');
setExpiresOn('');
setDownload('none');
@@ -113,6 +116,22 @@ function CreateForm({ onCreated }: { onCreated: () => void }) {
maxLength={120}
required
/>
<div className="admin-field">
<label htmlFor="proof-alias">Client URL alias (optional)</label>
<input
id="proof-alias"
value={alias}
onChange={(e) =>
setAlias(
e.target.value
.replace(/\s+/g, '-')
.replace(/[^A-Za-z0-9-]/g, ''),
)
}
placeholder="Client"
maxLength={64}
/>
</div>
</div>
<div className="admin-field">
<label htmlFor="proof-album">Album</label>
@@ -294,6 +313,30 @@ function SessionCard({
{copied === 'link' ? <Icons.IconCheck size={14} /> : <Icons.IconCopy size={14} />}{' '}
{copied === 'link' ? 'Copied' : 'Copy link'}
</button>
<button
type="button"
className="admin-btn admin-btn-ghost admin-btn-sm"
onClick={() => {
const next = window.prompt(
'Client URL alias (leave blank to remove):',
session.alias ?? '',
);
if (next === null) return;
const cleaned = next
.trim()
.replace(/\s+/g, '-')
.replace(/[^A-Za-z0-9-]/g, '');
void patch({
alias: cleaned || null,
});
}}
>
<Icons.IconLink size={14} />
{session.alias ? ' Change alias' : ' Set alias'}
</button>
<a
className="admin-btn admin-btn-ghost admin-btn-sm"
href={session.link}