mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-11-26 10:06:31 +00:00
feat(webui): make the dashboard responsive and add loading and empty states
Every tab row scrolls sideways instead of being clipped by its card. On phones this hid tabs, such as the Config change helper's last forms at 360-390px. The login button has a larger touch target, and long names are truncated with a tooltip. Loading and empty states: - Skeletons show only while a selection has no data yet, never over data already on screen during a refresh. - Empty states name the next step to take. - Error states offer a Retry button that shows progress, and each card keeps its own error. - Toasts confirm copies and key generation, and report background failures once per streak through polite and assertive live regions. Other changes: - The access matrix switches between Models, MCP servers and Agents, and says "none configured" only once its data has loaded. - Home ranks the top 5 users by cost, requests or tokens. It requests only the needed metrics and warns before a range exceeds the server's key cap. - MCP and agent deep links accept a bare target name. admin_assets_gen.go is regenerated. Claude-Session: https://claude.ai/code/session_01V5jYJNxpDFdJkyyExpADrv
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { loadState } from './load-state'
|
||||
|
||||
describe('loadState', () => {
|
||||
it('is "ready" when there is data, no error, not loading', () => {
|
||||
expect(loadState({ loading: false, hasData: true, error: '' })).toBe('ready')
|
||||
})
|
||||
|
||||
it('is "ready" when there is data even if loading is true (a background refresh in flight)', () => {
|
||||
expect(loadState({ loading: true, hasData: true, error: '' })).toBe('ready')
|
||||
})
|
||||
|
||||
// states-plan.md item 1: a background refresh failure must never blank
|
||||
// already-rendered data into an error state — that surfaces via a
|
||||
// toast instead (stores/toasts.ts), not by switching away from 'ready'.
|
||||
it('is "ready" when there is data even if a background refresh just failed (error set)', () => {
|
||||
expect(loadState({ loading: false, hasData: true, error: 'usage: fetch failed' })).toBe('ready')
|
||||
})
|
||||
|
||||
it('is "error" when there is no data and an error is set', () => {
|
||||
expect(loadState({ loading: false, hasData: false, error: 'overview: fetch failed' })).toBe('error')
|
||||
})
|
||||
|
||||
it('is "error" even while loading, when there is no data and an error is set (a retry already in flight)', () => {
|
||||
expect(loadState({ loading: true, hasData: false, error: 'overview: fetch failed' })).toBe('error')
|
||||
})
|
||||
|
||||
it('is "skeleton" when there is no data, no error, and loading is true', () => {
|
||||
expect(loadState({ loading: true, hasData: false, error: '' })).toBe('skeleton')
|
||||
})
|
||||
|
||||
it('is "empty" when there is no data, no error, and not loading', () => {
|
||||
expect(loadState({ loading: false, hasData: false, error: '' })).toBe('empty')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user