fix(web): stop the settings page breaking on an unexpected payload
Every list the page walks was read straight off the response, so a single missing field took the whole view down with `undefined.map` — which reads as a broken feature rather than as what it is, a page and an API disagreeing on the shape of the data. The page now normalises what it receives: absent lists render empty, an enum without options falls back to a text field, and settings that arrive without sections are shown under one heading instead of not at all. Errors of that family also say so, and point at the reload that fixes them. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
3 files changed
+58
-21
No files matched your search
@@ -146,11 +146,28 @@ export function table(columns, rows, { empty = 'Rien à afficher pour le moment.
|
||||
export const spinner = (label = 'Chargement…') =>
|
||||
h('div', { class: 'loading' }, h('span', { class: 'spinner' }), h('span', { text: label }));
|
||||
|
||||
/**
|
||||
* A `undefined is not a function` reaching the screen almost always means the
|
||||
* page and the API disagree on the shape of the data — which reads as a broken
|
||||
* feature unless the box says otherwise.
|
||||
*/
|
||||
const looksLikeVersionMismatch = (message) =>
|
||||
/Cannot read propert|undefined is not|is not a function|of undefined/i.test(String(message));
|
||||
|
||||
export const errorBox = (message, { retry } = {}) =>
|
||||
h(
|
||||
'div',
|
||||
{ class: 'notice notice-error' },
|
||||
h('p', { text: message }),
|
||||
h(
|
||||
'div',
|
||||
{},
|
||||
h('p', { text: message }),
|
||||
looksLikeVersionMismatch(message) &&
|
||||
h('p', {
|
||||
class: 'muted',
|
||||
text: 'Cette erreur vient en général d’une interface plus ancienne que l’API : recharge avec Ctrl+Shift+R, et si elle persiste, re-téléverse le dossier src/web/public.',
|
||||
}),
|
||||
),
|
||||
retry && button('Réessayer', retry, { tone: 'ghost' }),
|
||||
);
|
||||
|
||||
|
||||
Reference in new issue
Block a user