fix(dashboard): F-U-003 surface known collection patterns on the Files page
The Files page could only list a collection if the operator already knew its name and typed it in. No "browse known collections" affordance, no backend endpoint listing collections. Closest approximation without new backend: pull registered files-trigger collection_globs from the existing triggers list and surface them as: - a <datalist> on the collection input for autocomplete - chip buttons under the form that one-click set the input Empty state copy points the operator at the Triggers tab. Backend endpoint to list known collections directly is still a v1.1.10+ task. Styling uses the F-U-004 :root tokens so it inherits the dark theme. AUDIT.md anchor: F-U-003 (frontend-only; backend endpoint deferred). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -14,6 +14,11 @@
|
|||||||
let error = $state<string | null>(null);
|
let error = $state<string | null>(null);
|
||||||
let fileToRemove = $state<FileMeta | null>(null);
|
let fileToRemove = $state<FileMeta | null>(null);
|
||||||
let removing = $state(false);
|
let removing = $state(false);
|
||||||
|
/// F-U-003: hints derived from registered `files` triggers. No
|
||||||
|
/// backend endpoint lists known collections; this is the next-best
|
||||||
|
/// approximation — operators see "we've heard about these patterns"
|
||||||
|
/// instead of having to guess.
|
||||||
|
let collectionHints = $state<string[]>([]);
|
||||||
|
|
||||||
async function loadApp() {
|
async function loadApp() {
|
||||||
try {
|
try {
|
||||||
@@ -23,9 +28,25 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function loadCollectionHints() {
|
||||||
|
try {
|
||||||
|
const r = await api.triggers.list(slug);
|
||||||
|
const seen = new Set<string>();
|
||||||
|
for (const t of r.triggers) {
|
||||||
|
if (t.details.kind === 'files' && t.details.collection_glob) {
|
||||||
|
seen.add(t.details.collection_glob);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
collectionHints = Array.from(seen).sort();
|
||||||
|
} catch {
|
||||||
|
collectionHints = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
void slug;
|
void slug;
|
||||||
void loadApp();
|
void loadApp();
|
||||||
|
void loadCollectionHints();
|
||||||
});
|
});
|
||||||
|
|
||||||
async function loadFiles(cursor?: string) {
|
async function loadFiles(cursor?: string) {
|
||||||
@@ -102,12 +123,36 @@
|
|||||||
>
|
>
|
||||||
<label>
|
<label>
|
||||||
<span>Collection</span>
|
<span>Collection</span>
|
||||||
<input bind:value={collection} placeholder="avatars" required />
|
<input
|
||||||
|
bind:value={collection}
|
||||||
|
placeholder="avatars"
|
||||||
|
list="files-collection-hints"
|
||||||
|
required
|
||||||
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
<datalist id="files-collection-hints">
|
||||||
|
{#each collectionHints as h}
|
||||||
|
<option value={h}></option>
|
||||||
|
{/each}
|
||||||
|
</datalist>
|
||||||
<button type="submit" disabled={loading || !collection.trim()}>
|
<button type="submit" disabled={loading || !collection.trim()}>
|
||||||
{loading ? 'Loading…' : 'List files'}
|
{loading ? 'Loading…' : 'List files'}
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
{#if collectionHints.length > 0}
|
||||||
|
<p class="hint">
|
||||||
|
Known collection patterns from registered files triggers:
|
||||||
|
{#each collectionHints as h, i}
|
||||||
|
{#if i > 0}, {/if}
|
||||||
|
<button class="hint-chip" type="button" onclick={() => (collection = h)}>{h}</button>
|
||||||
|
{/each}
|
||||||
|
</p>
|
||||||
|
{:else}
|
||||||
|
<p class="hint">
|
||||||
|
No files triggers registered yet. Once you register a files trigger from the Triggers tab,
|
||||||
|
its collection glob will appear here as a suggestion.
|
||||||
|
</p>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if error}
|
{#if error}
|
||||||
<div class="error">{error}</div>
|
<div class="error">{error}</div>
|
||||||
@@ -217,10 +262,28 @@
|
|||||||
font-size: 0.78rem;
|
font-size: 0.78rem;
|
||||||
}
|
}
|
||||||
.muted {
|
.muted {
|
||||||
color: var(--muted, #666);
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
.hint {
|
||||||
|
color: var(--text-muted);
|
||||||
|
font-size: 0.85rem;
|
||||||
|
margin: 0.5rem 0 1rem;
|
||||||
|
}
|
||||||
|
.hint-chip {
|
||||||
|
background: var(--bg-elevated);
|
||||||
|
color: var(--text-primary);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 0.25rem;
|
||||||
|
padding: 0.1rem 0.4rem;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
cursor: pointer;
|
||||||
|
font-family: monospace;
|
||||||
|
}
|
||||||
|
.hint-chip:hover {
|
||||||
|
border-color: var(--color-link);
|
||||||
}
|
}
|
||||||
.error {
|
.error {
|
||||||
color: #b00020;
|
color: var(--color-danger);
|
||||||
margin: 0.5rem 0;
|
margin: 0.5rem 0;
|
||||||
}
|
}
|
||||||
button.danger {
|
button.danger {
|
||||||
|
|||||||
Reference in New Issue
Block a user