feat(updater): extend update modals with auto-update option

Additive: adds optional autoUpdateEligible and onAutoUpdate props to
UpdateAvailableModal and UpdateCheckResultModal. When both are set,
the primary button becomes 'Download & Install' and 'Visit release
page' stays as a secondary option. Existing $t() translations are
preserved.

cc
This commit is contained in:
vicrodh committed 2026-04-13 14:58:30 -06:00
1 parent 10b5d95852
commit 1372040990
2 files changed
+42 -4

No files matched your search

@@ -6,15 +6,29 @@
isOpen: boolean;
currentVersion: string;
newVersion: string;
autoUpdateEligible?: boolean;
onClose: () => void;
onVisitReleasePage: () => void;
onAutoUpdate?: () => void;
}
let { isOpen, currentVersion, newVersion, onClose, onVisitReleasePage }: Props = $props();
let {
isOpen,
currentVersion,
newVersion,
autoUpdateEligible = false,
onClose,
onVisitReleasePage,
onAutoUpdate,
}: Props = $props();
function handleVisit(): void {
onVisitReleasePage();
}
function handleAutoUpdate(): void {
onAutoUpdate?.();
}
</script>
<Modal {isOpen} onClose={onClose} title={ $t('updates.newReleaseAvailable') } maxWidth="560px">
@@ -35,7 +49,12 @@
{#snippet footer()}
<div class="footer-actions">
<button class="btn btn-ghost" type="button" onclick={onClose}>{$t('actions.close')}</button>
<button class="btn btn-primary" type="button" onclick={handleVisit}>{$t('actions.visitReleasePage')}</button>
{#if autoUpdateEligible && onAutoUpdate}
<button class="btn btn-ghost" type="button" onclick={handleVisit}>{$t('actions.visitReleasePage')}</button>
<button class="btn btn-primary" type="button" onclick={handleAutoUpdate}>{$t('actions.downloadAndInstall')}</button>
{:else}
<button class="btn btn-primary" type="button" onclick={handleVisit}>{$t('actions.visitReleasePage')}</button>
{/if}
</div>
{/snippet}
</Modal>
@@ -7,11 +7,25 @@
isOpen: boolean;
status: UpdateCheckStatus;
newVersion: string;
autoUpdateEligible?: boolean;
onClose: () => void;
onVisitReleasePage: () => void;
onAutoUpdate?: () => void;
}
let { isOpen, status, newVersion, onClose, onVisitReleasePage }: Props = $props();
let {
isOpen,
status,
newVersion,
autoUpdateEligible = false,
onClose,
onVisitReleasePage,
onAutoUpdate,
}: Props = $props();
function handleAutoUpdate(): void {
onAutoUpdate?.();
}
</script>
<Modal {isOpen} onClose={onClose} title={ $t('updates.checkForUpdates') } maxWidth="460px">
@@ -27,7 +41,12 @@
<div class="footer-actions">
<button class="btn btn-ghost" type="button" onclick={onClose}>{$t('actions.close')}</button>
{#if status === 'update_available'}
<button class="btn btn-primary" type="button" onclick={onVisitReleasePage}>{$t('actions.visitReleasePage')}</button>
{#if autoUpdateEligible && onAutoUpdate}
<button class="btn btn-ghost" type="button" onclick={onVisitReleasePage}>{$t('actions.visitReleasePage')}</button>
<button class="btn btn-primary" type="button" onclick={handleAutoUpdate}>{$t('actions.downloadAndInstall')}</button>
{:else}
<button class="btn btn-primary" type="button" onclick={onVisitReleasePage}>{$t('actions.visitReleasePage')}</button>
{/if}
{/if}
</div>
{/snippet}