diff --git a/ui/src/ChangeVersionModal.svelte b/ui/src/ChangeVersionModal.svelte index 0ceecb1..ee21f96 100644 --- a/ui/src/ChangeVersionModal.svelte +++ b/ui/src/ChangeVersionModal.svelte @@ -19,6 +19,10 @@ let trains: Record = {}; let loading = true; + // Why the list could not be had, kept apart from a registry that simply + // has no tags: the two read the same otherwise, and a failed request + // looked like an image with nothing published. + let loadError = ''; let train = ''; let versionTag = ''; let customTag = ''; @@ -49,11 +53,27 @@ } catch {} } - onMount(async () => { + async function load() { + loading = true; + loadError = ''; try { const res = await fetch(`/api/registry/versions?image=${encodeURIComponent(repo)}`); - if (res.ok) trains = await res.json(); - } catch {} + if (res.ok) trains = (await res.json()) ?? {}; + else { + let msg = (await res.text()).trim(); + try { + msg = JSON.parse(msg).error || msg; // the sign-in gate answers in JSON + } catch {} + loadError = msg || `${res.status} ${res.statusText}`; + } + } catch (e) { + loadError = e instanceof Error ? e.message : String(e); + } + pickDefault(); + loading = false; + } + + function pickDefault() { // Default the picker to the suggested tag (an upgrade target) if given, // else the currently-deployed tag. const target = suggestTag || currentTag; @@ -68,8 +88,9 @@ } } if (!train) train = trainList[0] || currentTag; - loading = false; - }); + } + + onMount(load); function apply() { if (!tag) return; @@ -94,6 +115,11 @@ {#if loading}

Loading published versions…

+ {:else if loadError} +

+ Could not load the published versions: {loadError} + +

{:else if trainList.length === 0}

No published tags found for this image.

{:else} @@ -121,6 +147,9 @@ + {/if} + + {#if !loading}
{noBuild}

{/if} - {/if} - - {#if !loading}
diff --git a/ui/src/locales/en.po b/ui/src/locales/en.po index ab6fe22..1aa47f7 100644 --- a/ui/src/locales/en.po +++ b/ui/src/locales/en.po @@ -4869,3 +4869,8 @@ msgstr "New stack" #: src/App.svelte msgid "Write the compose file yourself" msgstr "Write the compose file yourself" + +#. 0: loadError +#: src/ChangeVersionModal.svelte +msgid "Could not load the published versions: {0} <0>Try again" +msgstr "Could not load the published versions: {0} <0>Try again" diff --git a/ui/src/locales/fr.po b/ui/src/locales/fr.po index 55ece69..a96c17f 100644 --- a/ui/src/locales/fr.po +++ b/ui/src/locales/fr.po @@ -4858,3 +4858,8 @@ msgstr "Nouvelle pile" #: src/App.svelte msgid "Write the compose file yourself" msgstr "Écrivez vous-même le fichier compose" + +#. 0: loadError +#: src/ChangeVersionModal.svelte +msgid "Could not load the published versions: {0} <0>Try again" +msgstr "Impossible de charger les versions publiées : {0} <0>Réessayer"