diff --git a/frontend/src/components/MobileTopBar.jsx b/frontend/src/components/MobileTopBar.jsx index a27f344c..ce8c96c8 100644 --- a/frontend/src/components/MobileTopBar.jsx +++ b/frontend/src/components/MobileTopBar.jsx @@ -1,16 +1,18 @@ -import { Menu, X } from 'lucide-react'; +import { Menu, Plus, X } from 'lucide-react'; import { t } from '../i18n/t'; import { useTheme } from '../contexts/useTheme.js'; import ServerKitLogo from './ServerKitLogo'; import NotificationBell from './NotificationBell'; import QuickCreate from './QuickCreate'; import { Button as SharedButton } from '@/components/ui/button'; +import { useRegisteredPrimaryAction } from '../contexts/pagePrimaryAction.js'; // Fixed header shown only on narrow viewports (< 768px). Houses the // hamburger toggle that opens the sidebar as an off-canvas drawer, since // the persistent sidebar is hidden at this width. Hidden on desktop via CSS. const MobileTopBar = ({ navOpen, onToggle }) => { const { whiteLabel } = useTheme(); + const primary = useRegisteredPrimaryAction(); const branded = whiteLabel?.enabled; const brandName = branded ? (whiteLabel.brandName || 'Brand') : 'ServerKit'; const showCustomLogo = branded && whiteLabel.logoData && whiteLabel.mode !== 'text_only'; @@ -43,7 +45,18 @@ const MobileTopBar = ({ navOpen, onToggle }) => { {brandName}
- + {primary ? ( + + + + ) : }
diff --git a/frontend/src/components/PagePrimaryButton.jsx b/frontend/src/components/PagePrimaryButton.jsx new file mode 100644 index 00000000..6bf6448b --- /dev/null +++ b/frontend/src/components/PagePrimaryButton.jsx @@ -0,0 +1,32 @@ +import { useNavigate } from 'react-router-dom'; +import { Plus } from 'lucide-react'; +import { Button } from '@/components/ui/button'; +import { usePagePrimaryAction } from '../contexts/pagePrimaryAction.js'; + +// A page's primary create button: compact icon + short label on desktop (the +// full text rides in title/aria-label), and it registers the same action with +// the mobile header "+", which takes over at the width where this button hides +// (.sk-topbar__primary). Pass `to` instead of onClick to navigate. +// `iconOnly` drops the visible label, e.g. for pages with a tight icon bar. +export function PagePrimaryButton({ id, label, shortLabel, icon: Icon = Plus, onClick, to, disabled = false, iconOnly = false }) { + const navigate = useNavigate(); + const run = to ? () => navigate(to) : onClick; + usePagePrimaryAction({ id, label, onClick: run, disabled }); + + return ( + + ); +} + +export default PagePrimaryButton; diff --git a/frontend/src/contexts/PagePrimaryActionProvider.jsx b/frontend/src/contexts/PagePrimaryActionProvider.jsx new file mode 100644 index 00000000..1d259cd5 --- /dev/null +++ b/frontend/src/contexts/PagePrimaryActionProvider.jsx @@ -0,0 +1,15 @@ +import { useState } from 'react'; + +import { createPrimaryActionStore } from './pagePrimaryActionStore.js'; +import { PagePrimaryActionContext } from './pagePrimaryAction.js'; + +export function PagePrimaryActionProvider({ children }) { + const [store] = useState(createPrimaryActionStore); + return ( + + {children} + + ); +} + +export default PagePrimaryActionProvider; diff --git a/frontend/src/contexts/pagePrimaryAction.js b/frontend/src/contexts/pagePrimaryAction.js new file mode 100644 index 00000000..8c04aad5 --- /dev/null +++ b/frontend/src/contexts/pagePrimaryAction.js @@ -0,0 +1,27 @@ +import { createContext, useContext, useEffect, useRef, useSyncExternalStore } from 'react'; + +export const PagePrimaryActionContext = createContext(null); + +const noopSubscribe = () => () => {}; +const none = () => null; + +// The action currently registered by the page, or null. Read by MobileTopBar. +export function useRegisteredPrimaryAction() { + const store = useContext(PagePrimaryActionContext); + return useSyncExternalStore(store ? store.subscribe : noopSubscribe, store ? store.get : none); +} + +// A page registers its ONE primary create action; the mobile header "+" runs +// it. Cleared on unmount. onClick is kept in a ref so a new closure every +// render does not re-register (and so cannot loop); only id/label/disabled do. +// No-op outside the provider. +export function usePagePrimaryAction({ id, label, onClick, disabled = false }) { + const store = useContext(PagePrimaryActionContext); + const latest = useRef(onClick); + latest.current = onClick; + + useEffect(() => { + if (!store) return undefined; + return store.register({ id, label, disabled, run: () => latest.current?.() }); + }, [store, id, label, disabled]); +} diff --git a/frontend/src/contexts/pagePrimaryActionStore.js b/frontend/src/contexts/pagePrimaryActionStore.js new file mode 100644 index 00000000..c2a5b04b --- /dev/null +++ b/frontend/src/contexts/pagePrimaryActionStore.js @@ -0,0 +1,29 @@ +// Holds the create action the current page registered for the mobile header +// "+". Plain store (no React) so the claim/release rules are testable. +// Claims are kept in registration order: the newest live claim wins, and a +// release removes only its own, so the earlier one takes over again. +export function createPrimaryActionStore() { + let claims = []; + let current = null; + const listeners = new Set(); + const update = (next) => { + claims = next; + current = claims.length ? claims[claims.length - 1] : null; + listeners.forEach((fn) => fn()); + }; + + return { + get: () => current, + subscribe(fn) { + listeners.add(fn); + return () => listeners.delete(fn); + }, + register(action) { + const claim = { ...action }; + update([...claims, claim]); + return () => { + if (claims.includes(claim)) update(claims.filter((c) => c !== claim)); + }; + }, + }; +} diff --git a/frontend/src/contexts/pagePrimaryActionStore.test.mjs b/frontend/src/contexts/pagePrimaryActionStore.test.mjs new file mode 100644 index 00000000..b6e31986 --- /dev/null +++ b/frontend/src/contexts/pagePrimaryActionStore.test.mjs @@ -0,0 +1,42 @@ +import assert from 'node:assert/strict'; +import test from 'node:test'; + +import { createPrimaryActionStore } from './pagePrimaryActionStore.js'; + +test('register publishes the action and release clears it', () => { + const store = createPrimaryActionStore(); + let notified = 0; + store.subscribe(() => { notified += 1; }); + + const release = store.register({ id: 'a', label: 'Add' }); + assert.equal(store.get().label, 'Add'); + release(); + assert.equal(store.get(), null); + assert.equal(notified, 2); +}); + +test('a stale release does not clear a newer registration', () => { + const store = createPrimaryActionStore(); + const first = store.register({ id: 'a', label: 'One' }); + store.register({ id: 'a', label: 'Two' }); + first(); + assert.equal(store.get().label, 'Two'); +}); + +test('releasing the later claim restores the earlier one', () => { + const store = createPrimaryActionStore(); + store.register({ id: 'a', label: 'One' }); + const second = store.register({ id: 'b', label: 'Two' }); + assert.equal(store.get().label, 'Two'); + second(); + assert.equal(store.get().label, 'One'); +}); + +test('releasing the earlier claim keeps the later one', () => { + const store = createPrimaryActionStore(); + const first = store.register({ id: 'a', label: 'One' }); + store.register({ id: 'b', label: 'Two' }); + first(); + assert.equal(store.get().label, 'Two'); + assert.equal(store.get(), store.get()); +}); diff --git a/frontend/src/i18n/locales/ar.json b/frontend/src/i18n/locales/ar.json index ce15d9dc..fd8ffa01 100644 --- a/frontend/src/i18n/locales/ar.json +++ b/frontend/src/i18n/locales/ar.json @@ -730,7 +730,8 @@ "uploadToRemoteStorage": "قم بتحميل {{name}} إلى وحدة التخزين البعيدة", "uploadToRemoteStorageAfterBackup": "تحميل إلى التخزين البعيد بعد النسخ الاحتياطي", "warning": "تحذير:", - "yourServerDiskUsuallyFree": "قرص الخادم الخاص بك — عادةً ما يكون مجانيًا" + "yourServerDiskUsuallyFree": "قرص الخادم الخاص بك — عادةً ما يكون مجانيًا", + "backUpShort": "نسخ احتياطي" }, "backupsOverview": { "allSnapshots": "جميع اللقطات", @@ -4808,7 +4809,8 @@ "thisRemovesTheWireguardTunnel": "يؤدي هذا إلى إزالة نفق WireGuard", "thisServer": "هذا الخادم", "toAPublicHostnameOverA": "إلى اسم مضيف عام عبر نفق WireGuard. يقوم ServerKit بإقران هذا المضيف بخادم طرفي له عنوان IP عام.", - "tunnelTornDown": "النفق هدم" + "tunnelTornDown": "النفق هدم", + "exposeShort": "كشف" }, "remoteTerminal": { "closeTerminal": "إغلاق المحطة", @@ -7990,7 +7992,8 @@ "stop": "قف", "test": "امتحان", "tryAgain": "حاول ثانية", - "uninstall": "إلغاء التثبيت" + "uninstall": "إلغاء التثبيت", + "new": "جديد" }, "checking": "جارٍ التحقق...", "confirm": { diff --git a/frontend/src/i18n/locales/bn.json b/frontend/src/i18n/locales/bn.json index 54fb1310..a2d57197 100644 --- a/frontend/src/i18n/locales/bn.json +++ b/frontend/src/i18n/locales/bn.json @@ -730,7 +730,8 @@ "uploadToRemoteStorage": "দূরবর্তী সঞ্চয়স্থানে {{name}} আপলোড করুন", "uploadToRemoteStorageAfterBackup": "ব্যাকআপের পরে দূরবর্তী সঞ্চয়স্থানে আপলোড করুন", "warning": "সতর্কতা:", - "yourServerDiskUsuallyFree": "আপনার সার্ভার ডিস্ক - সাধারণত বিনামূল্যে" + "yourServerDiskUsuallyFree": "আপনার সার্ভার ডিস্ক - সাধারণত বিনামূল্যে", + "backUpShort": "ব্যাকআপ" }, "backupsOverview": { "allSnapshots": "সব স্ন্যাপশট", @@ -4808,7 +4809,8 @@ "thisRemovesTheWireguardTunnel": "এটি ওয়্যারগার্ড টানেলটি সরিয়ে দেয়", "thisServer": "এই সার্ভার", "toAPublicHostnameOverA": "একটি ওয়্যারগার্ড টানেলের উপরে একটি সর্বজনীন হোস্টনামে। ServerKit এই হোস্টটিকে একটি প্রান্ত সার্ভারের সাথে যুক্ত করে যার একটি পাবলিক আইপি রয়েছে।", - "tunnelTornDown": "টানেল ভেঙে গেছে" + "tunnelTornDown": "টানেল ভেঙে গেছে", + "exposeShort": "এক্সপোজ" }, "remoteTerminal": { "closeTerminal": "টার্মিনাল বন্ধ করুন", @@ -7990,7 +7992,8 @@ "stop": "থামো", "test": "পরীক্ষা", "tryAgain": "আবার চেষ্টা করুন", - "uninstall": "আনইনস্টল করুন" + "uninstall": "আনইনস্টল করুন", + "new": "নতুন" }, "checking": "পরীক্ষা করা হচ্ছে...", "confirm": { diff --git a/frontend/src/i18n/locales/de.json b/frontend/src/i18n/locales/de.json index 3eae1549..8213f5d4 100644 --- a/frontend/src/i18n/locales/de.json +++ b/frontend/src/i18n/locales/de.json @@ -730,7 +730,8 @@ "uploadToRemoteStorage": "Laden Sie {{name}} in den Remote-Speicher hoch", "uploadToRemoteStorageAfterBackup": "Nach der Sicherung in den Remote-Speicher hochladen", "warning": "Warnung:", - "yourServerDiskUsuallyFree": "Ihre Serverfestplatte – normalerweise kostenlos" + "yourServerDiskUsuallyFree": "Ihre Serverfestplatte – normalerweise kostenlos", + "backUpShort": "Sichern" }, "backupsOverview": { "allSnapshots": "Alles Schnappschüsse", @@ -4808,7 +4809,8 @@ "thisRemovesTheWireguardTunnel": "Dadurch wird der WireGuard-Tunnel entfernt", "thisServer": "diesen Server", "toAPublicHostnameOverA": "an einen öffentlichen Hostnamen über einen WireGuard-Tunnel. ServerKit koppelt diesen Host mit einem Edge-Server, der über eine öffentliche IP verfügt.", - "tunnelTornDown": "Tunnel abgerissen" + "tunnelTornDown": "Tunnel abgerissen", + "exposeShort": "Freigeben" }, "remoteTerminal": { "closeTerminal": "Terminal schließen", @@ -7990,7 +7992,8 @@ "stop": "Stopp", "test": "Testen", "tryAgain": "Versuchen Sie es erneut", - "uninstall": "Deinstallieren" + "uninstall": "Deinstallieren", + "new": "Neu" }, "checking": "Überprüfen...", "confirm": { diff --git a/frontend/src/i18n/locales/en.json b/frontend/src/i18n/locales/en.json index 7e0924d1..7519ce78 100644 --- a/frontend/src/i18n/locales/en.json +++ b/frontend/src/i18n/locales/en.json @@ -652,6 +652,7 @@ "autoUploadNewBackupsToRemote": "Auto-upload new backups to remote storage", "b2GbMonth": "B2 ($/GB/month)", "backUpNow": "Back up now", + "backUpShort": "Back up", "backblazeB2": "Backblaze B2", "backupDeleted": "Backup deleted", "backupName": "Backup name", @@ -4924,6 +4925,7 @@ "exposeService": "Expose service", "exposeServicesOn": "Expose services on", "exposeServicesRunningOn": "Expose services running on", + "exposeShort": "Expose", "exposed": "Exposed {{hostname}}", "failedToExposeService": "Couldn't expose the service.", "failedToLoadTunnels": "Couldn't load tunnels.", @@ -8370,6 +8372,7 @@ "logOut": "Sign out", "moveDown": "Move down", "moveUp": "Move up", + "new": "New", "next": "Next", "open": "Open", "publish": "Publish", diff --git a/frontend/src/i18n/locales/es.json b/frontend/src/i18n/locales/es.json index 35080b11..aa3374cb 100644 --- a/frontend/src/i18n/locales/es.json +++ b/frontend/src/i18n/locales/es.json @@ -730,7 +730,8 @@ "uploadToRemoteStorage": "Subir {{name}} al almacenamiento remoto", "uploadToRemoteStorageAfterBackup": "Subir al almacenamiento remoto después de la copia", "warning": "Advertencia:", - "yourServerDiskUsuallyFree": "El disco de tu servidor: normalmente gratis" + "yourServerDiskUsuallyFree": "El disco de tu servidor: normalmente gratis", + "backUpShort": "Respaldar" }, "backupsOverview": { "allSnapshots": "Todas las instantáneas", @@ -4809,7 +4810,8 @@ "thisRemovesTheWireguardTunnel": "Esto elimina el túnel WireGuard", "thisServer": "este servidor", "toAPublicHostnameOverA": "hacia un hostname público mediante un túnel WireGuard. ServerKit empareja este host con un servidor de borde que tiene IP pública.", - "tunnelTornDown": "Túnel desmontado" + "tunnelTornDown": "Túnel desmontado", + "exposeShort": "Exponer" }, "remoteTerminal": { "closeTerminal": "Cerrar terminal", @@ -7991,7 +7993,8 @@ "stop": "Detener", "test": "Probar", "tryAgain": "Reintentar", - "uninstall": "Desinstalar" + "uninstall": "Desinstalar", + "new": "Nuevo" }, "checking": "Comprobando...", "confirm": { diff --git a/frontend/src/i18n/locales/fr.json b/frontend/src/i18n/locales/fr.json index 9912be50..7dbf8a5f 100644 --- a/frontend/src/i18n/locales/fr.json +++ b/frontend/src/i18n/locales/fr.json @@ -730,7 +730,8 @@ "uploadToRemoteStorage": "Télécharger {{name}} sur le stockage distant", "uploadToRemoteStorageAfterBackup": "Télécharger sur le stockage distant après la sauvegarde", "warning": "Avertissement:", - "yourServerDiskUsuallyFree": "Le disque de votre serveur – généralement gratuit" + "yourServerDiskUsuallyFree": "Le disque de votre serveur – généralement gratuit", + "backUpShort": "Sauvegarder" }, "backupsOverview": { "allSnapshots": "Tous les instantanés", @@ -4808,7 +4809,8 @@ "thisRemovesTheWireguardTunnel": "Cela supprime le tunnel WireGuard", "thisServer": "ce serveur", "toAPublicHostnameOverA": "à un nom d'hôte public via un tunnel WireGuard. ServerKit associe cet hôte à un serveur Edge doté d'une adresse IP publique.", - "tunnelTornDown": "Tunnel démoli" + "tunnelTornDown": "Tunnel démoli", + "exposeShort": "Exposer" }, "remoteTerminal": { "closeTerminal": "Fermer le terminal", @@ -7990,7 +7992,8 @@ "stop": "Arrêt", "test": "Test", "tryAgain": "Essayer à nouveau", - "uninstall": "Désinstaller" + "uninstall": "Désinstaller", + "new": "Nouveau" }, "checking": "Vérification...", "confirm": { diff --git a/frontend/src/i18n/locales/id.json b/frontend/src/i18n/locales/id.json index 4cdf0cd7..0deb3725 100644 --- a/frontend/src/i18n/locales/id.json +++ b/frontend/src/i18n/locales/id.json @@ -730,7 +730,8 @@ "uploadToRemoteStorage": "Unggah {{name}} ke penyimpanan jarak jauh", "uploadToRemoteStorageAfterBackup": "Unggah ke penyimpanan jarak jauh setelah pencadangan", "warning": "Peringatan:", - "yourServerDiskUsuallyFree": "Disk server Anda — biasanya gratis" + "yourServerDiskUsuallyFree": "Disk server Anda — biasanya gratis", + "backUpShort": "Cadangkan" }, "backupsOverview": { "allSnapshots": "Semua cuplikan", @@ -4808,7 +4809,8 @@ "thisRemovesTheWireguardTunnel": "Ini menghilangkan terowongan WireGuard", "thisServer": "server ini", "toAPublicHostnameOverA": "ke nama host publik melalui terowongan WireGuard. ServerKit memasangkan host ini dengan server edge yang memiliki IP publik.", - "tunnelTornDown": "Terowongan dirobohkan" + "tunnelTornDown": "Terowongan dirobohkan", + "exposeShort": "Ekspos" }, "remoteTerminal": { "closeTerminal": "Tutup terminalnya", @@ -7990,7 +7992,8 @@ "stop": "Berhenti", "test": "Tes", "tryAgain": "Coba lagi", - "uninstall": "Hapus instalasi" + "uninstall": "Hapus instalasi", + "new": "Baru" }, "checking": "Memeriksa...", "confirm": { diff --git a/frontend/src/i18n/locales/it.json b/frontend/src/i18n/locales/it.json index dcc94578..35d70d00 100644 --- a/frontend/src/i18n/locales/it.json +++ b/frontend/src/i18n/locales/it.json @@ -730,7 +730,8 @@ "uploadToRemoteStorage": "Carica {{name}} nell'archivio remoto", "uploadToRemoteStorageAfterBackup": "Carica nell'archivio remoto dopo il backup", "warning": "Avvertimento:", - "yourServerDiskUsuallyFree": "Il disco del tuo server, solitamente gratuito" + "yourServerDiskUsuallyFree": "Il disco del tuo server, solitamente gratuito", + "backUpShort": "Backup" }, "backupsOverview": { "allSnapshots": "Tutte le istantanee", @@ -4808,7 +4809,8 @@ "thisRemovesTheWireguardTunnel": "Questo rimuove il tunnel WireGuard", "thisServer": "questo server", "toAPublicHostnameOverA": "a un nome host pubblico su un tunnel WireGuard. ServerKit associa questo host a un server periferico con un IP pubblico.", - "tunnelTornDown": "Tunnel demolito" + "tunnelTornDown": "Tunnel demolito", + "exposeShort": "Esponi" }, "remoteTerminal": { "closeTerminal": "Chiudi il terminale", @@ -7990,7 +7992,8 @@ "stop": "Fermare", "test": "Test", "tryAgain": "Riprova", - "uninstall": "Disinstalla" + "uninstall": "Disinstalla", + "new": "Nuovo" }, "checking": "Controllo...", "confirm": { diff --git a/frontend/src/i18n/locales/ko.json b/frontend/src/i18n/locales/ko.json index 3da12633..f443a27d 100644 --- a/frontend/src/i18n/locales/ko.json +++ b/frontend/src/i18n/locales/ko.json @@ -730,7 +730,8 @@ "uploadToRemoteStorage": "원격 저장소에 {{name}} 업로드", "uploadToRemoteStorageAfterBackup": "백업 후 원격 저장소에 업로드", "warning": "경고:", - "yourServerDiskUsuallyFree": "서버 디스크 – 일반적으로 무료" + "yourServerDiskUsuallyFree": "서버 디스크 – 일반적으로 무료", + "backUpShort": "백업" }, "backupsOverview": { "allSnapshots": "모든 스냅샷", @@ -4808,7 +4809,8 @@ "thisRemovesTheWireguardTunnel": "WireGuard 터널이 제거됩니다.", "thisServer": "이 서버", "toAPublicHostnameOverA": "WireGuard 터널을 통해 공개 호스트 이름으로. ServerKit은 이 호스트를 공용 IP가 있는 에지 서버와 연결합니다.", - "tunnelTornDown": "터널이 철거됨" + "tunnelTornDown": "터널이 철거됨", + "exposeShort": "노출" }, "remoteTerminal": { "closeTerminal": "터미널 닫기", @@ -7990,7 +7992,8 @@ "stop": "중지", "test": "테스트", "tryAgain": "다시 시도하세요", - "uninstall": "제거" + "uninstall": "제거", + "new": "새로 만들기" }, "checking": "확인 중...", "confirm": { diff --git a/frontend/src/i18n/locales/pl.json b/frontend/src/i18n/locales/pl.json index 82272ff7..be143d55 100644 --- a/frontend/src/i18n/locales/pl.json +++ b/frontend/src/i18n/locales/pl.json @@ -730,7 +730,8 @@ "uploadToRemoteStorage": "Prześlij {{name}} do zdalnej pamięci masowej", "uploadToRemoteStorageAfterBackup": "Prześlij do magazynu zdalnego po utworzeniu kopii zapasowej", "warning": "Ostrzeżenie:", - "yourServerDiskUsuallyFree": "Dysk Twojego serwera — zazwyczaj bezpłatny" + "yourServerDiskUsuallyFree": "Dysk Twojego serwera — zazwyczaj bezpłatny", + "backUpShort": "Kopia" }, "backupsOverview": { "allSnapshots": "Wszystkie migawki", @@ -4808,7 +4809,8 @@ "thisRemovesTheWireguardTunnel": "Spowoduje to usunięcie tunelu WireGuard", "thisServer": "ten serwer", "toAPublicHostnameOverA": "do publicznej nazwy hosta przez tunel WireGuard. ServerKit łączy ten host z serwerem brzegowym mającym publiczny adres IP.", - "tunnelTornDown": "Tunel rozebrany" + "tunnelTornDown": "Tunel rozebrany", + "exposeShort": "Udostępnij" }, "remoteTerminal": { "closeTerminal": "Zamknij terminal", @@ -7990,7 +7992,8 @@ "stop": "Zatrzymywać się", "test": "Test", "tryAgain": "Spróbuj ponownie", - "uninstall": "Odinstaluj" + "uninstall": "Odinstaluj", + "new": "Nowy" }, "checking": "Kontrola...", "confirm": { diff --git a/frontend/src/i18n/locales/pt.json b/frontend/src/i18n/locales/pt.json index 39d5ff7b..c2da6733 100644 --- a/frontend/src/i18n/locales/pt.json +++ b/frontend/src/i18n/locales/pt.json @@ -730,7 +730,8 @@ "uploadToRemoteStorage": "Carregar {{name}} para armazenamento remoto", "uploadToRemoteStorageAfterBackup": "Fazer upload para armazenamento remoto após backup", "warning": "Aviso:", - "yourServerDiskUsuallyFree": "O disco do seu servidor — geralmente gratuito" + "yourServerDiskUsuallyFree": "O disco do seu servidor — geralmente gratuito", + "backUpShort": "Backup" }, "backupsOverview": { "allSnapshots": "Todos os instantâneos", @@ -4808,7 +4809,8 @@ "thisRemovesTheWireguardTunnel": "Isso remove o túnel WireGuard", "thisServer": "este servidor", "toAPublicHostnameOverA": "para um nome de host público em um túnel WireGuard. O ServerKit emparelha esse host com um servidor de borda que possui um IP público.", - "tunnelTornDown": "Túnel demolido" + "tunnelTornDown": "Túnel demolido", + "exposeShort": "Expor" }, "remoteTerminal": { "closeTerminal": "Fechar terminal", @@ -7990,7 +7992,8 @@ "stop": "Pare", "test": "Teste", "tryAgain": "Tente novamente", - "uninstall": "Desinstalar" + "uninstall": "Desinstalar", + "new": "Novo" }, "checking": "Verificando...", "confirm": { diff --git a/frontend/src/i18n/locales/ru.json b/frontend/src/i18n/locales/ru.json index 33ce357b..309072fa 100644 --- a/frontend/src/i18n/locales/ru.json +++ b/frontend/src/i18n/locales/ru.json @@ -730,7 +730,8 @@ "uploadToRemoteStorage": "Загрузите {{name}} в удаленное хранилище.", "uploadToRemoteStorageAfterBackup": "Загрузка в удаленное хранилище после резервного копирования", "warning": "Предупреждение:", - "yourServerDiskUsuallyFree": "Диск вашего сервера — обычно бесплатно" + "yourServerDiskUsuallyFree": "Диск вашего сервера — обычно бесплатно", + "backUpShort": "Бэкап" }, "backupsOverview": { "allSnapshots": "Все снимки", @@ -4808,7 +4809,8 @@ "thisRemovesTheWireguardTunnel": "Это удалит туннель WireGuard.", "thisServer": "этот сервер", "toAPublicHostnameOverA": "к общедоступному имени хоста через туннель WireGuard. ServerKit соединяет этот хост с пограничным сервером, имеющим общедоступный IP-адрес.", - "tunnelTornDown": "Туннель снесен" + "tunnelTornDown": "Туннель снесен", + "exposeShort": "Открыть" }, "remoteTerminal": { "closeTerminal": "Закрыть терминал", @@ -7990,7 +7992,8 @@ "stop": "Остановить", "test": "Проверить", "tryAgain": "Попробуйте еще раз", - "uninstall": "Удалить" + "uninstall": "Удалить", + "new": "Создать" }, "checking": "Проверка...", "confirm": { diff --git a/frontend/src/i18n/locales/th.json b/frontend/src/i18n/locales/th.json index 8f1eeecd..28985eb8 100644 --- a/frontend/src/i18n/locales/th.json +++ b/frontend/src/i18n/locales/th.json @@ -730,7 +730,8 @@ "uploadToRemoteStorage": "อัปโหลด {{name}} ไปยังที่จัดเก็บข้อมูลระยะไกล", "uploadToRemoteStorageAfterBackup": "อัปโหลดไปยังที่จัดเก็บข้อมูลระยะไกลหลังการสำรองข้อมูล", "warning": "คำเตือน:", - "yourServerDiskUsuallyFree": "ดิสก์เซิร์ฟเวอร์ของคุณ — ปกติจะฟรี" + "yourServerDiskUsuallyFree": "ดิสก์เซิร์ฟเวอร์ของคุณ — ปกติจะฟรี", + "backUpShort": "สำรอง" }, "backupsOverview": { "allSnapshots": "สแนปชอตทั้งหมด", @@ -4808,7 +4809,8 @@ "thisRemovesTheWireguardTunnel": "การดำเนินการนี้จะลบอุโมงค์ WireGuard", "thisServer": "เซิร์ฟเวอร์นี้", "toAPublicHostnameOverA": "ไปยังชื่อโฮสต์สาธารณะผ่านอุโมงค์ WireGuard ServerKit จับคู่โฮสต์นี้กับเซิร์ฟเวอร์ Edge ที่มี IP สาธารณะ", - "tunnelTornDown": "อุโมงค์ถูกรื้อลง" + "tunnelTornDown": "อุโมงค์ถูกรื้อลง", + "exposeShort": "เปิดเผย" }, "remoteTerminal": { "closeTerminal": "ปิดเทอร์มินัล", @@ -7990,7 +7992,8 @@ "stop": "หยุด", "test": "ทดสอบ", "tryAgain": "ลองอีกครั้ง", - "uninstall": "ถอนการติดตั้ง" + "uninstall": "ถอนการติดตั้ง", + "new": "ใหม่" }, "checking": "กำลังตรวจสอบ...", "confirm": { diff --git a/frontend/src/i18n/locales/tr.json b/frontend/src/i18n/locales/tr.json index a1095ac9..9a793f13 100644 --- a/frontend/src/i18n/locales/tr.json +++ b/frontend/src/i18n/locales/tr.json @@ -730,7 +730,8 @@ "uploadToRemoteStorage": "{{name}}'yi uzak depolama birimine yükleyin", "uploadToRemoteStorageAfterBackup": "Yedeklemeden sonra uzak depolama birimine yükleyin", "warning": "Uyarı:", - "yourServerDiskUsuallyFree": "Sunucu diskiniz — genellikle ücretsizdir" + "yourServerDiskUsuallyFree": "Sunucu diskiniz — genellikle ücretsizdir", + "backUpShort": "Yedekle" }, "backupsOverview": { "allSnapshots": "Tüm anlık görüntüler", @@ -4808,7 +4809,8 @@ "thisRemovesTheWireguardTunnel": "Bu, WireGuard tünelini kaldırır", "thisServer": "bu sunucu", "toAPublicHostnameOverA": "WireGuard tüneli üzerinden genel bir ana bilgisayar adına. ServerKit, bu ana bilgisayarı genel IP'ye sahip bir uç sunucuyla eşleştirir.", - "tunnelTornDown": "Tünel yıkıldı" + "tunnelTornDown": "Tünel yıkıldı", + "exposeShort": "Aç" }, "remoteTerminal": { "closeTerminal": "Terminali kapat", @@ -7990,7 +7992,8 @@ "stop": "Durmak", "test": "Test", "tryAgain": "Tekrar deneyin", - "uninstall": "Kaldır" + "uninstall": "Kaldır", + "new": "Yeni" }, "checking": "Kontrol ediliyor...", "confirm": { diff --git a/frontend/src/i18n/locales/vi.json b/frontend/src/i18n/locales/vi.json index cb7b793d..ec51356a 100644 --- a/frontend/src/i18n/locales/vi.json +++ b/frontend/src/i18n/locales/vi.json @@ -730,7 +730,8 @@ "uploadToRemoteStorage": "Tải {{name}} lên bộ nhớ từ xa", "uploadToRemoteStorageAfterBackup": "Tải lên bộ nhớ từ xa sau khi sao lưu", "warning": "Cảnh báo:", - "yourServerDiskUsuallyFree": "Đĩa máy chủ của bạn - thường miễn phí" + "yourServerDiskUsuallyFree": "Đĩa máy chủ của bạn - thường miễn phí", + "backUpShort": "Sao lưu" }, "backupsOverview": { "allSnapshots": "Tất cả ảnh chụp nhanh", @@ -4808,7 +4809,8 @@ "thisRemovesTheWireguardTunnel": "Thao tác này sẽ xóa đường hầm WireGuard", "thisServer": "máy chủ này", "toAPublicHostnameOverA": "tới tên máy chủ công cộng qua đường hầm WireGuard. ServerKit ghép nối máy chủ này với máy chủ biên có IP công cộng.", - "tunnelTornDown": "Đường hầm bị phá bỏ" + "tunnelTornDown": "Đường hầm bị phá bỏ", + "exposeShort": "Mở" }, "remoteTerminal": { "closeTerminal": "Đóng thiết bị đầu cuối", @@ -7990,7 +7992,8 @@ "stop": "Dừng lại", "test": "Bài kiểm tra", "tryAgain": "Thử lại", - "uninstall": "Gỡ cài đặt" + "uninstall": "Gỡ cài đặt", + "new": "Mới" }, "checking": "Đang kiểm tra...", "confirm": { diff --git a/frontend/src/i18n/locales/zh-Hans.json b/frontend/src/i18n/locales/zh-Hans.json index fbe7f319..b79a7c37 100644 --- a/frontend/src/i18n/locales/zh-Hans.json +++ b/frontend/src/i18n/locales/zh-Hans.json @@ -730,7 +730,8 @@ "uploadToRemoteStorage": "将 {{name}} 上传到远程存储", "uploadToRemoteStorageAfterBackup": "备份后上传至远程存储", "warning": "警告:", - "yourServerDiskUsuallyFree": "您的服务器磁盘 — 通常是免费的" + "yourServerDiskUsuallyFree": "您的服务器磁盘 — 通常是免费的", + "backUpShort": "备份" }, "backupsOverview": { "allSnapshots": "所有快照", @@ -4808,7 +4809,8 @@ "thisRemovesTheWireguardTunnel": "这将删除 WireGuard 隧道", "thisServer": "该服务器", "toAPublicHostnameOverA": "通过 WireGuard 隧道到公共主机名。 ServerKit 将此主机与具有公共 IP 的边缘服务器配对。", - "tunnelTornDown": "隧道被拆除" + "tunnelTornDown": "隧道被拆除", + "exposeShort": "公开" }, "remoteTerminal": { "closeTerminal": "关闭终端", @@ -7990,7 +7992,8 @@ "stop": "停止", "test": "测试", "tryAgain": "重试", - "uninstall": "卸载" + "uninstall": "卸载", + "new": "新建" }, "checking": "检查...", "confirm": { diff --git a/frontend/src/i18n/locales/zh-Hant.json b/frontend/src/i18n/locales/zh-Hant.json index 6c0afa61..a95be96b 100644 --- a/frontend/src/i18n/locales/zh-Hant.json +++ b/frontend/src/i18n/locales/zh-Hant.json @@ -730,7 +730,8 @@ "uploadToRemoteStorage": "上傳{{name}}到遠端儲存", "uploadToRemoteStorageAfterBackup": "備份後上傳至遠端儲存", "warning": "警告:", - "yourServerDiskUsuallyFree": "您的伺服器磁碟 — 通常是免費的" + "yourServerDiskUsuallyFree": "您的伺服器磁碟 — 通常是免費的", + "backUpShort": "備份" }, "backupsOverview": { "allSnapshots": "所有快照", @@ -4808,7 +4809,8 @@ "thisRemovesTheWireguardTunnel": "這將刪除 WireGuard 隧道", "thisServer": "該伺服器", "toAPublicHostnameOverA": "上執行的服務透過 WireGuard 隧道公開至對外可存取的主機名稱。ServerKit 會將此主機與具有公用 IP 位址的邊緣伺服器配對。", - "tunnelTornDown": "隧道被拆除" + "tunnelTornDown": "隧道被拆除", + "exposeShort": "公開" }, "remoteTerminal": { "closeTerminal": "關閉終端機", @@ -7990,7 +7992,8 @@ "stop": "停止", "test": "測試", "tryAgain": "再試一次", - "uninstall": "解除安裝" + "uninstall": "解除安裝", + "new": "新增" }, "checking": "檢查中…", "confirm": { diff --git a/frontend/src/layouts/DashboardLayout.jsx b/frontend/src/layouts/DashboardLayout.jsx index 094600d4..3c9aafd0 100644 --- a/frontend/src/layouts/DashboardLayout.jsx +++ b/frontend/src/layouts/DashboardLayout.jsx @@ -18,6 +18,7 @@ import OperationsDock from '../components/OperationsDock'; import ErrorBoundary from '../components/ErrorBoundary'; import { useShortcut } from '../hooks/useShortcut'; import { useTranslation } from 'react-i18next'; +import { PagePrimaryActionProvider } from '../contexts/PagePrimaryActionProvider'; import { OperationsProvider } from '../contexts/OperationsContext'; import { ManagedProfileProvider } from '../contexts/ManagedProfileContext'; import { useManagedProfile } from '../contexts/useManagedProfile'; @@ -114,6 +115,7 @@ const DashboardLayout = () => { }, []); return ( + @@ -154,6 +156,7 @@ const DashboardLayout = () => { + ); }; diff --git a/frontend/src/pages/Backups.jsx b/frontend/src/pages/Backups.jsx index 66e9d8a1..0775d46a 100644 --- a/frontend/src/pages/Backups.jsx +++ b/frontend/src/pages/Backups.jsx @@ -1,6 +1,6 @@ import { useState, useEffect, useCallback, useMemo, useId } from 'react'; import useTabParam from '../hooks/useTabParam'; -import { Upload, Check, AlertTriangle, Archive, Clock, Database, Package, FolderArchive, HardDrive, History, Cloud, RefreshCw, Trash2, Plus, FileArchive, DollarSign } from 'lucide-react'; +import { Upload, Check, AlertTriangle, Archive, Clock, Database, Package, FolderArchive, HardDrive, History, Cloud, RefreshCw, Trash2, FileArchive, DollarSign } from 'lucide-react'; import api from '../services/api'; import { formatBytes } from '@/utils/formatBytes'; import { scrollBehavior } from '@/utils/reducedMotion'; @@ -10,6 +10,7 @@ import EmptyState from '../components/EmptyState'; import Modal from '@/components/Modal'; import { FormField, FormRow } from '../components/FormField'; import { Button } from '@/components/ui/button'; +import PagePrimaryButton from '@/components/PagePrimaryButton'; import { Input } from '@/components/ui/input'; import { Textarea } from '@/components/ui/textarea'; import { Select, SelectTrigger, SelectContent, SelectItem, SelectValue } from '@/components/ui/select'; @@ -688,15 +689,20 @@ const Backups = () => { useTopbarActions(() => ( <> {activeTab === 'schedules' && !backupsManaged ? ( - + setShowScheduleModal(true)} + /> ) : ( - + setShowBackupModal(true)} + /> )} {activeTab === 'snapshots' && ( { // two fixed-width icon buttons. useTopbarActions(() => ( <> - + setShowAddModal(true)} + /> diff --git a/frontend/src/pages/Monitors.jsx b/frontend/src/pages/Monitors.jsx index 236c1247..8e9b4668 100644 --- a/frontend/src/pages/Monitors.jsx +++ b/frontend/src/pages/Monitors.jsx @@ -27,6 +27,7 @@ import { useTableChrome, GridViewPicker, GridChips, GridToolsMenu, } from '@/components/ds/grid'; import { Button } from '@/components/ui/button'; +import PagePrimaryButton from '@/components/PagePrimaryButton'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Switch } from '@/components/ui/switch'; @@ -264,9 +265,12 @@ export default function Monitors() { - + ), [q, activeFilterCount, load]); diff --git a/frontend/src/pages/Projects.jsx b/frontend/src/pages/Projects.jsx index e8a496b6..3e00350a 100644 --- a/frontend/src/pages/Projects.jsx +++ b/frontend/src/pages/Projects.jsx @@ -9,6 +9,7 @@ import { useTopbarActions } from '@/hooks/useTopbarActions'; import useFocusParam from '@/hooks/useFocusParam'; import { SearchField, ServiceTile } from '@/components/ds'; import { Button } from '@/components/ui/button'; +import PagePrimaryButton from '@/components/PagePrimaryButton'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Textarea } from '@/components/ui/textarea'; @@ -80,9 +81,12 @@ const Projects = () => { useTopbarActions(() => ( <> - + setShowCreate(true)} + /> ), [search]); diff --git a/frontend/src/pages/QueueOperations.jsx b/frontend/src/pages/QueueOperations.jsx index 068fdd45..5cfd7051 100644 --- a/frontend/src/pages/QueueOperations.jsx +++ b/frontend/src/pages/QueueOperations.jsx @@ -19,6 +19,7 @@ import EmptyState from '../components/EmptyState'; import InfoTip from '@/components/InfoTip'; import Modal from '@/components/Modal'; import { Button } from '@/components/ui/button'; +import PagePrimaryButton from '@/components/PagePrimaryButton'; import { Tip } from '@/components/ui/tooltip'; import PageLayout from '../layouts/PageLayout'; import { Input } from '@/components/ui/input'; @@ -470,11 +471,12 @@ const QueueOperations = () => { - - - + setShowQueueModal(true)} + /> ); // Header action lives in the shared Servers top bar when this page is used // as a tab in the Servers group. When embedded inside a single server's // detail page we render the action inline instead. - useTopbarActions(() => exposeButton, [loading]); + useTopbarActions(() => ( + openWizard(null)} + disabled={loading} + /> + ), [loading]); return (
diff --git a/frontend/src/pages/Servers.jsx b/frontend/src/pages/Servers.jsx index 6c6d458d..24f7deca 100644 --- a/frontend/src/pages/Servers.jsx +++ b/frontend/src/pages/Servers.jsx @@ -11,6 +11,7 @@ import EmptyState from '../components/EmptyState'; import ErrorState from '../components/ErrorState'; import Modal from '@/components/Modal'; import { Button } from '@/components/ui/button'; +import PagePrimaryButton from '@/components/PagePrimaryButton'; import { Input } from '@/components/ui/input'; import { Select, SelectTrigger, SelectContent, SelectItem, SelectValue, @@ -387,9 +388,12 @@ const Servers = () => { - + setShowAddModal(true)} + /> { useTopbarActions(() => <> - - + { {t('common.actions.refresh', 'Refresh')} {isAdmin && ( - + setShowCreatePage(true)} + /> )} ), diff --git a/frontend/src/pages/Vaults.jsx b/frontend/src/pages/Vaults.jsx index a6283bd2..347598df 100644 --- a/frontend/src/pages/Vaults.jsx +++ b/frontend/src/pages/Vaults.jsx @@ -2,6 +2,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react'; import InfoTip from '@/components/InfoTip'; import api from '../services/api'; import { Button } from '@/components/ui/button'; +import PagePrimaryButton from '@/components/PagePrimaryButton'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Textarea } from '@/components/ui/textarea'; @@ -178,16 +179,22 @@ export default function Vaults() { - + setSecretForm({ open: true, name: '', value: '', description: '' })} + /> ) : ( <> - + setVaultForm({ open: true, name: '', description: '', workspace_id: activeWorkspaceId })} + /> )), [selectedVault, search, activeWorkspaceId]); diff --git a/frontend/src/pages/Workspaces.jsx b/frontend/src/pages/Workspaces.jsx index bb17d59a..e9402052 100644 --- a/frontend/src/pages/Workspaces.jsx +++ b/frontend/src/pages/Workspaces.jsx @@ -4,11 +4,12 @@ import api from '../services/api'; import { useToast } from '../contexts/useToast.js'; import Modal from '@/components/Modal'; import ResourceListPage from '../components/layouts/ResourceListPage'; -import { LayoutGrid, Plus, ChevronRight } from 'lucide-react'; +import { LayoutGrid, ChevronRight } from 'lucide-react'; import { Pill, ServiceTile, SearchField } from '@/components/ds'; import { useTopbarActions } from '@/hooks/useTopbarActions'; import useFocusParam from '@/hooks/useFocusParam'; import { Button } from '@/components/ui/button'; +import PagePrimaryButton from '@/components/PagePrimaryButton'; import { Input } from '@/components/ui/input'; import { Textarea } from '@/components/ui/textarea'; import { useWorkspace } from '../contexts/useWorkspace.js'; @@ -120,10 +121,12 @@ const Workspaces = () => { useTopbarActions(() => ( <> {isAdmin && ( - + setShowCreateModal(true)} + /> )} .sk-topbar__chrome > .sk-gridicon { order: 2; } } + // Primary is hidden here, so a strip holding only it (and an empty chrome + // slot) is a 0-height flex item that still costs the topbar a row-gap. + @media (max-width: $breakpoint-md) { + // Only the topbar copy hides; the same button in a page body stays. + &__actions > &__primary { display: none; } + &__actions:has(> .sk-topbar__primary):not(:has(> :not(.sk-topbar__primary, .sk-topbar__chrome), > .sk-topbar__chrome > *)) { display: none; } + } + // The portal target a table's chrome renders into. It must not become a box // of its own, or the whole chrome would be one order:0 blob. &__chrome { display: contents; }