Skip to content

PostgreSQL backup tool with Point-In-Time-Recovery and restore verification

FEATURE (releases): Add release indicator

Rostislav Dugin9843a5b217b4
diff --git a/frontend/src/features/users/ui/AuthNavbarComponent.tsx b/frontend/src/features/users/ui/AuthNavbarComponent.tsx
index 86deb311..f0669d31 100644
--- a/frontend/src/features/users/ui/AuthNavbarComponent.tsx
+++ b/frontend/src/features/users/ui/AuthNavbarComponent.tsx
@@ -1,10 +1,13 @@
import { Tooltip } from 'antd';
import { IS_CLOUD, IS_DISABLE_CLOUD_NOTICE } from '../../../constants';
+import { useTemporaryVisibility } from '../../../shared/hooks';
import { StarButtonComponent } from '../../../shared/ui/StarButtonComponent';
import { ThemeToggleComponent } from '../../../shared/ui/ThemeToggleComponent';
export function AuthNavbarComponent() {
+ const isCloudPulseVisible = useTemporaryVisibility(15_000);
+
return (
<div className="flex h-[65px] items-center justify-center px-5 pt-5 sm:justify-start">
<div className="flex items-center gap-3 hover:opacity-80">
@@ -33,11 +36,13 @@ export function AuthNavbarComponent() {
target="_blank"
rel="noreferrer"
>
+ {isCloudPulseVisible && (
+ <span className="relative flex h-2 w-2" aria-label="99.9% uptime, 2x backup copies">
+ <span className="absolute inline-flex h-full w-full animate-ping rounded-full bg-green-500 opacity-75" />
+ <span className="relative inline-flex h-2 w-2 rounded-full bg-green-500" />
+ </span>
+ )}
Cloud
- <span className="relative flex h-2 w-2" aria-label="99.9% uptime, 2x backup copies">
- <span className="absolute inline-flex h-full w-full animate-ping rounded-full bg-green-500 opacity-75" />
- <span className="relative inline-flex h-2 w-2 rounded-full bg-green-500" />
- </span>
</a>
</Tooltip>
)}
diff --git a/frontend/src/shared/hooks/index.ts b/frontend/src/shared/hooks/index.ts
index 83b28117..fd69ceaf 100644
--- a/frontend/src/shared/hooks/index.ts
+++ b/frontend/src/shared/hooks/index.ts
@@ -1,2 +1,4 @@
export { useScreenHeight } from './useScreenHeight';
export { useIsMobile } from './useIsMobile';
+export { useIsNewGitHubVersionAvailable } from './useIsNewGitHubVersionAvailable';
+export { useTemporaryVisibility } from './useTemporaryVisibility';
diff --git a/frontend/src/shared/hooks/useIsNewGitHubVersionAvailable.ts b/frontend/src/shared/hooks/useIsNewGitHubVersionAvailable.ts
new file mode 100644
index 00000000..58c7c37c
--- /dev/null
+++ b/frontend/src/shared/hooks/useIsNewGitHubVersionAvailable.ts
@@ -0,0 +1,90 @@
+import { useEffect, useState } from 'react';
+
+import { APP_VERSION } from '../../constants';
+import { compareVersions, parseGitHubTag } from '../lib';
+
+const GITHUB_RELEASES_API = 'https://api.github.com/repos/databasus/databasus/releases/latest';
+const CACHE_KEY = 'githubLatestVersion';
+const CACHE_TTL_MS = 15 * 60 * 1000;
+
+interface CachedVersion {
+ version: string;
+ fetchedAt: number;
+}
+
+function readCachedVersion(): string | null {
+ try {
+ const raw = localStorage.getItem(CACHE_KEY);
+ if (!raw) {
+ return null;
+ }
+
+ const cached = JSON.parse(raw) as CachedVersion;
+
+ if (Date.now() - cached.fetchedAt < CACHE_TTL_MS) {
+ return cached.version;
+ }
+
+ return null;
+ } catch {
+ return null;
+ }
+}
+
+async function fetchLatestVersion(): Promise<string | null> {
+ try {
+ const response = await fetch(GITHUB_RELEASES_API, {
+ headers: { Accept: 'application/vnd.github+json' },
+ });
+
+ if (!response.ok) {
+ return null;
+ }
+
+ const release = (await response.json()) as { tag_name?: string };
+ if (!release.tag_name) {
+ return null;
+ }
+
+ const version = parseGitHubTag(release.tag_name);
+
+ localStorage.setItem(
+ CACHE_KEY,
+ JSON.stringify({ version, fetchedAt: Date.now() } satisfies CachedVersion),
+ );
+
+ return version;
+ } catch {
+ return null;
+ }
+}
+
+export function useIsNewGitHubVersionAvailable(): boolean {
+ const [latestVersion, setLatestVersion] = useState<string | null>(null);
+
+ useEffect(() => {
+ if (APP_VERSION === 'dev') {
+ return;
+ }
+
+ const cachedVersion = readCachedVersion();
+ if (cachedVersion) {
+ setLatestVersion(cachedVersion);
+ return;
+ }
+
+ let isActive = true;
+
+ fetchLatestVersion().then((version) => {
+ if (isActive && version) {
+ setLatestVersion(version);
+ }
+ });
+
+ return () => {
+ isActive = false;
+ };
+ }, []);
+
+ return latestVersion !== null && compareVersions(latestVersion, APP_VERSION) > 0;
+}
diff --git a/frontend/src/shared/hooks/useTemporaryVisibility.ts b/frontend/src/shared/hooks/useTemporaryVisibility.ts
new file mode 100644
index 00000000..af6756d4
--- /dev/null
+++ b/frontend/src/shared/hooks/useTemporaryVisibility.ts
@@ -0,0 +1,12 @@
+import { useEffect, useState } from 'react';
+
+export function useTemporaryVisibility(durationMs: number): boolean {
+ const [isVisible, setIsVisible] = useState(true);
+
+ useEffect(() => {
+ const hideTimer = setTimeout(() => setIsVisible(false), durationMs);
+ return () => clearTimeout(hideTimer);
+ }, [durationMs]);
+
+ return isVisible;
+}
diff --git a/frontend/src/shared/lib/index.ts b/frontend/src/shared/lib/index.ts
index 709651dd..43ce8938 100644
--- a/frontend/src/shared/lib/index.ts
+++ b/frontend/src/shared/lib/index.ts
@@ -1,2 +1,3 @@
export { FormValidator } from './FormValidator';
export { StringUtils } from './StringUtils';
+export { compareVersions, parseGitHubTag } from './version';
diff --git a/frontend/src/shared/lib/version.test.ts b/frontend/src/shared/lib/version.test.ts
new file mode 100644
index 00000000..4d8e1369
--- /dev/null
+++ b/frontend/src/shared/lib/version.test.ts
@@ -0,0 +1,82 @@
+import { describe, expect, it } from 'vitest';
+
+import { compareVersions, parseGitHubTag } from './version';
+
+describe('parseGitHubTag', () => {
+ it('strips a leading v from a release tag', () => {
+ expect(parseGitHubTag('v3.40.0')).toBe('3.40.0');
+ });
+
+ it('leaves a tag without a v prefix unchanged', () => {
+ expect(parseGitHubTag('3.40.0')).toBe('3.40.0');
+ });
+
+ it('trims surrounding whitespace', () => {
+ expect(parseGitHubTag(' v3.40.0 ')).toBe('3.40.0');
+ });
+});
+
+describe('compareVersions', () => {
+ it('returns 0 for equal versions', () => {
+ expect(compareVersions('3.26.0', '3.26.0')).toBe(0);
+ });
+
+ it('returns a positive number when the first version is newer', () => {
+ expect(compareVersions('3.40.0', '3.26.0')).toBeGreaterThan(0);
+ });
+
+ it('returns a negative number when the first version is older', () => {
+ expect(compareVersions('3.26.0', '3.40.0')).toBeLessThan(0);
+ });
+
+ it('compares the minor segment when majors match', () => {
+ expect(compareVersions('3.39.0', '3.40.0')).toBeLessThan(0);
+ });
+
+ it('compares the patch segment when major and minor match', () => {
+ expect(compareVersions('3.35.1', '3.35.0')).toBeGreaterThan(0);
+ });
+
+ it('treats missing segments as zero', () => {
+ expect(compareVersions('3.40', '3.40.0')).toBe(0);
+ });
+
+ it('treats non-numeric segments as zero', () => {
+ expect(compareVersions('3.40.x', '3.40.0')).toBe(0);
+ });
+
+ describe('against real databasus release tags', () => {
+ const releaseTags = [
+ 'v3.40.0',
+ 'v3.39.2',
+ 'v3.39.1',
+ 'v3.39.0',
+ 'v3.38.0',
+ 'v3.35.1',
+ 'v3.35.0',
+ 'v3.32.2',
+ 'v3.28.1',
+ 'v3.28.0',
+ 'v3.27.0',
+ 'v3.26.0',
+ ].map(parseGitHubTag);
+
+ it('orders the published tags newest-first', () => {
+ for (let i = 0; i < releaseTags.length - 1; i++) {
+ expect(compareVersions(releaseTags[i], releaseTags[i + 1])).toBeGreaterThan(0);
+ }
+ });
+
+ it('reports an update when the bundled version is behind the latest release', () => {
+ const latestRelease = releaseTags[0];
+
+ expect(compareVersions(latestRelease, '3.26.0')).toBeGreaterThan(0);
+ });
+
+ it('reports no update when the bundled version matches the latest release', () => {
+ const latestRelease = releaseTags[0];
+
+ expect(compareVersions(latestRelease, parseGitHubTag('v3.40.0'))).toBe(0);
+ });
+ });
+});
diff --git a/frontend/src/shared/lib/version.ts b/frontend/src/shared/lib/version.ts
new file mode 100644
index 00000000..a6063879
--- /dev/null
+++ b/frontend/src/shared/lib/version.ts
@@ -0,0 +1,18 @@
+export function parseGitHubTag(tagName: string): string {
+ return tagName.trim().replace(/^v/, '');
+}
+
+export function compareVersions(a: string, b: string): number {
+ const aParts = a.split('.').map((part) => parseInt(part, 10) || 0);
+ const bParts = b.split('.').map((part) => parseInt(part, 10) || 0);
+
+ for (let i = 0; i < 3; i++) {
+ const diff = (aParts[i] || 0) - (bParts[i] || 0);
+
+ if (diff !== 0) {
+ return diff;
+ }
+ }
+
+ return 0;
+}
diff --git a/frontend/src/widgets/main/MainScreenComponent.tsx b/frontend/src/widgets/main/MainScreenComponent.tsx
index 5cc80418..0354a7e3 100644
--- a/frontend/src/widgets/main/MainScreenComponent.tsx
+++ b/frontend/src/widgets/main/MainScreenComponent.tsx
@@ -22,7 +22,12 @@ import {
CreateWorkspaceDialogComponent,
WorkspaceSettingsComponent,
} from '../../features/workspaces';
-import { useIsMobile, useScreenHeight } from '../../shared/hooks';
+import {
+ useIsMobile,
+ useIsNewGitHubVersionAvailable,
+ useScreenHeight,
+ useTemporaryVisibility,
+} from '../../shared/hooks';
import { StarButtonComponent } from '../../shared/ui/StarButtonComponent';
import { ThemeToggleComponent } from '../../shared/ui/ThemeToggleComponent';
import { SidebarComponent } from './SidebarComponent';
@@ -32,6 +37,8 @@ export const MainScreenComponent = () => {
const { message } = App.useApp();
const screenHeight = useScreenHeight();
const isMobile = useIsMobile();
+ const isNewGitHubVersionAvailable = useIsNewGitHubVersionAvailable();
+ const isCloudPulseVisible = useTemporaryVisibility(15_000);
const contentHeight = screenHeight - (isMobile ? 70 : 95);
const [selectedTab, setSelectedTab] = useState<
@@ -220,11 +227,16 @@ export const MainScreenComponent = () => {
target="_blank"
rel="noreferrer"
>
+ {isCloudPulseVisible && (
+ <span
+ className="relative flex h-2 w-2"
+ aria-label="99.9% uptime, 2 backup copies"
+ >
+ <span className="absolute inline-flex h-full w-full animate-ping rounded-full bg-green-500 opacity-75" />
+ <span className="relative inline-flex h-2 w-2 rounded-full bg-green-500" />
+ </span>
+ )}
Cloud
- <span className="relative flex h-2 w-2" aria-label="99.9% uptime, 2 backup copies">
- <span className="absolute inline-flex h-full w-full animate-ping rounded-full bg-green-500 opacity-75" />
- <span className="relative inline-flex h-2 w-2 rounded-full bg-green-500" />
- </span>
</a>
</Tooltip>
)}
@@ -394,7 +406,21 @@ export const MainScreenComponent = () => {
<div className="absolute bottom-1 left-2 mb-[0px] hidden text-sm text-gray-400 md:block">
v{APP_VERSION}
<br />
- {CONTAINER_ARCH}
+ <span className="inline-flex items-center gap-1.5">
+ {CONTAINER_ARCH}
+ {isNewGitHubVersionAvailable && (
+ <Tooltip title="New version available">
+ <a
+ href="https://github.com/databasus/databasus/releases/latest"
+ target="_blank"
+ rel="noopener noreferrer"
+ className="inline-flex"
+ >
+ <span className="inline-flex h-2 w-2 rounded-full bg-green-500" />
+ </a>
+ </Tooltip>
+ )}
+ </span>
</div>
)}
</div>