Skip to content

Commit 28b6f71

Browse files
committed
fix(layout): make version badge popover always clickable
Previously the badge ignored clicks until GitHub responded with a release tag. When the latest version is unknown (offline, rate-limited, still loading) the popover now opens with a "checking…" hint and the release link is hidden until it becomes available.
1 parent 40e68a9 commit 28b6f71

3 files changed

Lines changed: 27 additions & 20 deletions

File tree

frontend/src/components/Layout.tsx

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -232,40 +232,45 @@ export default function Layout({ children }: PropsWithChildren) {
232232
<div ref={versionPopoverRef} className="relative w-fit">
233233
<button
234234
type="button"
235-
className={`relative inline-flex items-center rounded-md bg-primary/10 px-1.5 py-0.5 text-[10px] font-bold text-primary ring-1 ring-primary/10 transition-colors ${releaseURL ? 'cursor-pointer hover:bg-primary/15' : 'cursor-default'}`}
235+
className="relative inline-flex cursor-pointer items-center rounded-md bg-primary/10 px-1.5 py-0.5 text-[10px] font-bold text-primary ring-1 ring-primary/10 transition-colors hover:bg-primary/15"
236236
title={hasUpdate && latestVersion ? t('common.newVersionAvailable', { version: latestVersion }) : undefined}
237237
tabIndex={sidebarCollapsed ? -1 : 0}
238-
onClick={() => {
239-
if (!releaseURL) return
240-
setShowVersionPopover((current) => !current)
241-
}}
238+
onClick={() => setShowVersionPopover((current) => !current)}
242239
>
243240
{__APP_VERSION__}
244241
{hasUpdate && (
245242
<span className="absolute -top-1.5 left-1/2 size-2.5 -translate-x-1/2 rounded-full bg-red-500 shadow-sm ring-2 ring-[hsl(var(--sidebar-background))] animate-pulse" />
246243
)}
247244
</button>
248-
{showVersionPopover && releaseURL && latestVersion && (
245+
{showVersionPopover && (
249246
<div className="absolute left-0 top-[calc(100%+8px)] z-50 w-[240px] rounded-lg border border-border bg-popover p-3 text-left shadow-xl">
250247
<div className="text-[13px] font-semibold text-foreground">
251-
{hasUpdate ? t('common.newVersionAvailable', { version: latestVersion }) : t('common.versionLatest')}
248+
{latestVersion
249+
? hasUpdate
250+
? t('common.newVersionAvailable', { version: latestVersion })
251+
: t('common.versionLatest')
252+
: t('common.versionChecking')}
252253
</div>
253254
<div className="mt-1 text-[11px] text-muted-foreground">
254255
{t('common.currentVersion', { version: __APP_VERSION__ })}
255256
</div>
256-
<div className="mt-1 text-[11px] text-muted-foreground">
257-
{t('common.latestVersion', { version: latestVersion })}
258-
</div>
259-
<a
260-
href={releaseURL}
261-
target="_blank"
262-
rel="noopener noreferrer"
263-
className="mt-3 inline-flex w-full items-center justify-center gap-1.5 rounded-md border border-primary/20 bg-primary/10 px-2.5 py-1.5 text-[12px] font-semibold text-primary transition-colors hover:bg-primary/15"
264-
onClick={() => setShowVersionPopover(false)}
265-
>
266-
{t('common.viewReleaseNotes')}
267-
<ExternalLink className="size-3.5" />
268-
</a>
257+
{latestVersion && (
258+
<div className="mt-1 text-[11px] text-muted-foreground">
259+
{t('common.latestVersion', { version: latestVersion })}
260+
</div>
261+
)}
262+
{releaseURL && (
263+
<a
264+
href={releaseURL}
265+
target="_blank"
266+
rel="noopener noreferrer"
267+
className="mt-3 inline-flex w-full items-center justify-center gap-1.5 rounded-md border border-primary/20 bg-primary/10 px-2.5 py-1.5 text-[12px] font-semibold text-primary transition-colors hover:bg-primary/15"
268+
onClick={() => setShowVersionPopover(false)}
269+
>
270+
{t('common.viewReleaseNotes')}
271+
<ExternalLink className="size-3.5" />
272+
</a>
273+
)}
269274
</div>
270275
)}
271276
</div>

frontend/src/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"currentVersion": "Current version: {{version}}",
2020
"latestVersion": "Latest version: {{version}}",
2121
"versionLatest": "You are on the latest version",
22+
"versionChecking": "Checking for the latest version…",
2223
"viewReleaseNotes": "View release notes",
2324
"logout": "Log out",
2425
"refresh": "Refresh",

frontend/src/locales/zh.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"currentVersion": "当前版本:{{version}}",
2020
"latestVersion": "最新版本:{{version}}",
2121
"versionLatest": "已是最新版本",
22+
"versionChecking": "正在检查最新版本…",
2223
"viewReleaseNotes": "查看更新内容",
2324
"logout": "退出登录",
2425
"refresh": "刷新",

0 commit comments

Comments
 (0)