diff --git a/frontend/src/components/detail/DetailHeaderMeta.jsx b/frontend/src/components/detail/DetailHeaderMeta.jsx deleted file mode 100644 index 75ae1779..00000000 --- a/frontend/src/components/detail/DetailHeaderMeta.jsx +++ /dev/null @@ -1,28 +0,0 @@ -import InfoTip from '@/components/InfoTip'; -import { StatusDot } from '@/components/ds'; - -// The top-bar meta every entity detail page shares (services, servers): -// [status dot] [(i) with the facts the header used to spell out] [star]. -// Anything page-specific (an "open" link) rides along as children. -// -// status: { kind, label } kind = Pill vocabulary -// rows: [{ label, value }] falsy values are skipped -export default function DetailHeaderMeta({ status, infoTitle, rows, favorite, children }) { - return ( - <> - - -
- {rows.filter((row) => row.value).map((row) => ( -
-
{row.label}
-
{row.value}
-
- ))} -
-
- {favorite} - {children} - - ); -} diff --git a/frontend/src/components/detail/DetailPage.jsx b/frontend/src/components/detail/DetailPage.jsx new file mode 100644 index 00000000..196fd4aa --- /dev/null +++ b/frontend/src/components/detail/DetailPage.jsx @@ -0,0 +1,77 @@ +import { Link } from 'react-router-dom'; +import PageLayout from '@/layouts/PageLayout'; +import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs'; +import { cn } from '@/lib/utils'; + +// One anatomy for entity detail pages (services, servers): +// +// top bar Parent / Name [star] [actions] +// identity [tile] Name [status] [badges] +// meta line · meta line +// tabs [Overview] [Logs] … [Settings] +// content +// +// Feature pages own their data, actions and tab bodies; this module owns the +// frame so the two pages cannot drift apart again. +export function DetailPage({ className, topbarClassName, icon, parentTo, parentLabel, name, favorite, actions, children }) { + return ( + + {parentLabel} + + {name} + + )} + meta={favorite} + actions={actions} + > + {children} + + ); +} + +// The entity's name, state and key facts, directly under the top bar. +export function DetailIdentity({ avatar, name, badges, meta, description }) { + return ( +
+ {avatar} +
+
+

{name}

+ {badges} +
+ {meta &&
{meta}
} + {description &&

{description}

} +
+
+ ); +} + +// Separator between facts on the identity meta line. +export function DetailMetaSep() { + return ; +} + +// The tab strip under the identity. `items`: [{ id, label, icon, badge }]. +// Settings always sits at the far end of the strip. +export function DetailTabs({ items, value, onValueChange, ariaLabel, children }) { + return ( + + + {items.map(({ id, label, icon: Icon, badge }) => ( + + {Icon && + ))} + +
{children}
+
+ ); +} diff --git a/frontend/src/components/serverdetail/ServerHeaderMeta.jsx b/frontend/src/components/serverdetail/ServerHeaderMeta.jsx deleted file mode 100644 index 1c100359..00000000 --- a/frontend/src/components/serverdetail/ServerHeaderMeta.jsx +++ /dev/null @@ -1,33 +0,0 @@ -import { useTranslation } from 'react-i18next'; -import FavoriteStar from '@/components/FavoriteStar'; -import CopyButton from '@/components/CopyButton'; -import DetailHeaderMeta from '@/components/detail/DetailHeaderMeta'; -import { serverStatusKind } from './serverDetailData'; - -// Header meta: [status dot] [(i) with endpoint + ID] [star]. Everything the -// header used to spell out lives behind the (i). -export default function ServerHeaderMeta({ server }) { - const { t } = useTranslation(); - const status = server.status || 'pending'; - const endpoint = server.hostname || server.ip_address || t('app.serverDetail.noEndpointConfigured', 'No endpoint configured'); - return ( - - {server.id} - - - ), - }, - ]} - favorite={} - /> - ); -} diff --git a/frontend/src/i18n/locales/en.json b/frontend/src/i18n/locales/en.json index d47eb31f..adb3d63d 100644 --- a/frontend/src/i18n/locales/en.json +++ b/frontend/src/i18n/locales/en.json @@ -5530,18 +5530,18 @@ "sshKeys": "SSH keys" }, "serverDetail": { + "agentVersion": "agent {{version}}", "alerts": "Alerts", "areYouSureYouWantTo": "Remove this server? This can't be undone.", "backToServers": "Back to servers", - "copyId": "Copy ID", + "copyServerId": "Copy server ID", "cron": "Cron", - "details": "Server details", - "endpoint": "Endpoint", "errorLoadingServer": "Couldn't load the server.", "failedToAcknowledgeAlert": "Couldn't acknowledge the alert.", "failedToPingServer": "Couldn't ping the server.", "failedToRemoveServer": "Couldn't remove the server.", "failedToResolveAlert": "Couldn't resolve the alert.", + "lastSeen": "last seen", "limitedMode": "Limited mode", "loadingServerDetails": "Loading server details", "metrics": "Metrics", @@ -5555,7 +5555,6 @@ "restorePoints": "Restore points", "sections": "Server sections", "serverDidNotRespond": "Server did not respond", - "serverId": "ID", "serverNotFound": "Server not found", "serverRemovedSuccessfully": "Server removed", "serverRespondedInMs": "Server responded in {{latency}}ms", @@ -5964,7 +5963,6 @@ "deployLatestCommit": "Deploy latest commit", "deploying": "Deploying…", "deploymentStarted": "Deployment started", - "details": "Service details", "dockerCompose": "Docker Compose", "failedToDeleteService": "Couldn't delete the service.", "failedToDeployLatestCommit": "Couldn't deploy the latest commit.", diff --git a/frontend/src/pages/ServerDetail.jsx b/frontend/src/pages/ServerDetail.jsx index c3ef972a..52086481 100644 --- a/frontend/src/pages/ServerDetail.jsx +++ b/frontend/src/pages/ServerDetail.jsx @@ -1,5 +1,7 @@ -import { isPlaceholderServerName } from '../components/serverdetail/serverDetailData'; -import ServerHeaderMeta from '../components/serverdetail/ServerHeaderMeta'; +import { isPlaceholderServerName, serverStatusKind } from '../components/serverdetail/serverDetailData'; +import { DetailPage, DetailIdentity, DetailMetaSep, DetailTabs } from '@/components/detail/DetailPage'; +import FavoriteStar from '@/components/FavoriteStar'; +import { Pill, ServiceTile } from '@/components/ds'; import { useState, useEffect, useCallback } from 'react'; import { useParams, Link, useNavigate } from 'react-router-dom'; import api from '../services/api'; @@ -7,10 +9,8 @@ import { useToast } from '../contexts/useToast.js'; import { useConfirm } from '../hooks/useConfirm'; import { useRecordVisit } from '@/hooks/useRecordVisit'; import { Button } from '@/components/ui/button'; -import { Tabs, TabsContent } from '@/components/ui/tabs'; -import { Tip } from '@/components/ui/tooltip'; -import { Server, ArrowLeft } from 'lucide-react'; -import PageLayout from '../layouts/PageLayout'; +import { TabsContent } from '@/components/ui/tabs'; +import { Server, LayoutGrid, History, Container, Globe, Clock, Network, Package, Boxes, ScanSearch, Activity, Bell, Shield, Settings } from 'lucide-react'; import PackagesTab from '../components/serverdetail/PackagesTab'; import ServicesTab from '../components/serverdetail/ServicesTab'; import ServerOverviewTab from '../components/serverdetail/ServerOverviewTab'; @@ -22,6 +22,8 @@ import ServerMetricsTab from '../components/serverdetail/ServerMetricsTab'; import SurveyTab from '../components/serverdetail/SurveyTab'; import ServerSettingsTab, { TokenModal } from '../components/serverdetail/ServerSettingsTab'; import { + CopyChip, + FolderTinyIcon, RefreshIcon, } from '../components/serverdetail/serverDetailShared'; import ProxyStackPanel from '../components/proxy/ProxyStackPanel'; @@ -32,6 +34,10 @@ import { useTranslation } from 'react-i18next'; import { useAuth } from '../contexts/useAuth.js'; import ServerRestorePointsTab from '../components/serverdetail/ServerRestorePointsTab'; import { toastError } from '@/utils/errorMessage'; +import { formatDateTime } from '@/utils/intl'; + +// Edge of the identity tile next to the entity name, in px. +const IDENTITY_TILE_SIZE = 52; // Live host metrics cadence while the server is online. const METRICS_POLL_MS = 10000; @@ -254,57 +260,86 @@ const ServerDetail = () => { // hiding the tab matches the rest of the panel's "don't expose what // the host can't do" behaviour. const tabs = [ - { id: 'overview', label: t('common.labels.overview', 'Overview') }, - ...(isDeveloper ? [{ id: 'restore-points', label: t('app.serverDetail.restorePoints', 'Restore points') }] : []), - { id: 'docker', label: t('common.labels.docker', 'Docker') }, - { id: 'proxy', label: t('app.serverDetail.proxy', 'Proxy') }, - ...(server.capabilities?.cron ? [{ id: 'cron', label: t('app.serverDetail.cron', 'Cron') }] : []), - ...(server.capabilities?.cloudflared ? [{ id: 'cloudflared', label: t('app.serverDetail.tunnels', 'Tunnels') }] : []), - ...(server.capabilities?.packages ? [{ id: 'packages', label: t('app.serverDetail.packages', 'Packages') }] : []), - ...(server.capabilities?.systemd ? [{ id: 'services', label: t('common.labels.services', 'Services') }] : []), - ...(server.capabilities?.survey ? [{ id: 'survey', label: t('app.serverDetail.survey', 'Survey') }] : []), - { id: 'metrics', label: t('app.serverDetail.metrics', 'Metrics') }, + { id: 'overview', icon: LayoutGrid, label: t('common.labels.overview', 'Overview') }, + ...(isDeveloper ? [{ id: 'restore-points', icon: History, label: t('app.serverDetail.restorePoints', 'Restore points') }] : []), + { id: 'docker', icon: Container, label: t('common.labels.docker', 'Docker') }, + { id: 'proxy', icon: Globe, label: t('app.serverDetail.proxy', 'Proxy') }, + ...(server.capabilities?.cron ? [{ id: 'cron', icon: Clock, label: t('app.serverDetail.cron', 'Cron') }] : []), + ...(server.capabilities?.cloudflared ? [{ id: 'cloudflared', icon: Network, label: t('app.serverDetail.tunnels', 'Tunnels') }] : []), + ...(server.capabilities?.packages ? [{ id: 'packages', icon: Package, label: t('app.serverDetail.packages', 'Packages') }] : []), + ...(server.capabilities?.systemd ? [{ id: 'services', icon: Boxes, label: t('common.labels.services', 'Services') }] : []), + ...(server.capabilities?.survey ? [{ id: 'survey', icon: ScanSearch, label: t('app.serverDetail.survey', 'Survey') }] : []), + { id: 'metrics', icon: Activity, label: t('app.serverDetail.metrics', 'Metrics') }, ...(totalAlertCount > 0 - ? [{ id: 'alerts', label: t('app.serverDetail.alerts', 'Alerts'), badge: totalAlertCount }] - : [{ id: 'alerts', label: t('app.serverDetail.alerts', 'Alerts') }]), - ...(server.capabilities?.wireguard ? [{ id: 'remote-access', label: t('app.serverDetail.remoteAccess', 'Remote access') }] : []), - { id: 'settings', label: t('common.labels.settings', 'Settings') } + ? [{ id: 'alerts', icon: Bell, label: t('app.serverDetail.alerts', 'Alerts'), badge: totalAlertCount }] + : [{ id: 'alerts', icon: Bell, label: t('app.serverDetail.alerts', 'Alerts') }]), + ...(server.capabilities?.wireguard ? [{ id: 'remote-access', icon: Shield, label: t('app.serverDetail.remoteAccess', 'Remote access') }] : []), + { id: 'settings', icon: Settings, label: t('common.labels.settings', 'Settings') } ]; + const displayName = isPlaceholderServerName(server.name) ? t('app.serverDetail.pendingPairing', 'Pending pairing') : server.name; + return ( - } - title={isPlaceholderServerName(server.name) ? t('app.serverDetail.pendingPairing', 'Pending pairing') : server.name} - navLabel={t('app.serverDetail.sections', 'Server sections')} - meta={} - tabs={tabs.map((item) => ({ - id: item.id, - label: item.badge ? <>{item.label}{item.badge} : item.label, - active: item.id === activeTab, - onSelect: () => navigate(item.id === 'overview' ? `/servers/${id}` : `/servers/${id}/${item.id}`, { replace: true }), - }))} + parentTo="/servers" + parentLabel={t('common.labels.servers', 'Servers')} + name={displayName} + favorite={} actions={( - <> - - - - - - - + )} > - {server.description && ( -

{server.description}

- )} + } + name={displayName} + badges={( + <> + {server.status || 'pending'} + + + )} + meta={( + <> + {server.hostname || server.ip_address || t('app.serverDetail.noEndpointConfigured', 'No endpoint configured')} + {server.group_name && ( + <> + + {server.group_name} + + )} + {server.os_type && ( + <> + + {server.os_type} + + )} + {server.agent_version && ( + <> + + {t('app.serverDetail.agentVersion', 'agent {{version}}', { version: server.agent_version })} + + )} + {server.last_seen && ( + <> + + {t('app.serverDetail.lastSeen', 'last seen')} {formatDateTime(server.last_seen)} + + )} + + )} + description={server.description} + /> - + navigate(value === 'overview' ? `/servers/${id}` : `/servers/${id}/${value}`, { replace: true })} + >
{ />
-
+ {showTokenModal && server && ( { onGenerated={handleTokenGenerated} /> )} -
+ ); }; diff --git a/frontend/src/pages/ServiceDetail.jsx b/frontend/src/pages/ServiceDetail.jsx index 49bc0ddb..4f6d507d 100644 --- a/frontend/src/pages/ServiceDetail.jsx +++ b/frontend/src/pages/ServiceDetail.jsx @@ -23,12 +23,11 @@ import OverviewTab from '../components/service-detail/OverviewTab'; import PreviewList from '../components/previews/PreviewList'; import EmptyState from '../components/EmptyState'; import PluginSlot from '../components/PluginSlot'; -import { Layers, FileArchive, RotateCcw, ExternalLink } from 'lucide-react'; +import { Layers, FileArchive, RotateCcw, LayoutDashboard, History, ScrollText, Variable, Terminal, Activity, Package, Server, SquareTerminal, Settings, Eye, ExternalLink } from 'lucide-react'; import { Button } from '@/components/ui/button'; -import { statusKind } from '@/components/ds'; -import PageLayout from '../layouts/PageLayout'; +import { Pill, ServiceTile, statusKind } from '@/components/ds'; import FavoriteStar from '@/components/FavoriteStar'; -import DetailHeaderMeta from '@/components/detail/DetailHeaderMeta'; +import { DetailPage, DetailIdentity, DetailMetaSep, DetailTabs } from '@/components/detail/DetailPage'; import { useRecordVisit } from '@/hooks/useRecordVisit'; import { useTranslation } from 'react-i18next'; import { toastError } from '@/utils/errorMessage'; @@ -60,6 +59,24 @@ const RETIRED_TAB_REDIRECTS = { deploy: 'settings/git', }; +// Per-tab glyph for the detail tab strip. +const TAB_ICONS = { + overview: LayoutDashboard, + events: History, + logs: ScrollText, + environment: Variable, + shell: Terminal, + metrics: Activity, + packages: Package, + gunicorn: Server, + commands: SquareTerminal, + previews: Eye, + settings: Settings, +}; + +// Edge of the identity tile next to the entity name, in px. +const IDENTITY_TILE_SIZE = 52; + const ServiceDetail = () => { const { t } = useTranslation(); const { id, tab: rawTab } = useParams(); @@ -266,51 +283,14 @@ const ServiceDetail = () => { const openUrl = primaryDomain ? null : servicePortUrl(service); return ( - } - title={service.name} - navLabel={t('app.serviceDetail.sections', 'Service sections')} - meta={( - {primaryDomain} - ), - }, - ]} - favorite={} - > - {openUrl && ( - - - - )} - - )} - tabs={availableTabs.map(tab => ({ - id: tab, - label: TAB_LABELS[tab] || tab, - active: activeTab === tab, - onSelect: () => setActiveTab(tab), - }))} + parentTo="/services" + parentLabel={t('common.labels.services', 'Services')} + name={service.name} + favorite={} actions={( <> {/* Deploy dropdown */} @@ -423,6 +403,51 @@ const ServiceDetail = () => { )} > + } + name={service.name} + badges={( + <> + {openUrl && ( + + + + )} + {service.statusInfo.label} + + {service.typeInfo.label} + + + )} + meta={( + <> + {service.port && ( + <> + {t('common.labels.port', 'Port')} {service.port} + + + )} + {t('common.labels.created', 'Created')} {formatDate(service.created_at)} + {primaryDomain && ( + <> + + {primaryDomain} + + )} + + )} + /> + {/* Repo Connection Pill */}
{isUpload ? ( @@ -519,7 +544,12 @@ const ServiceDetail = () => {
)} - {/* Tab Content */} + ({ id: tab, label: TAB_LABELS[tab] || tab, icon: TAB_ICONS[tab] }))} + value={activeTab} + onValueChange={setActiveTab} + ariaLabel={t('app.serviceDetail.sections', 'Service sections')} + >
{activeTab === 'overview' && } {activeTab === 'events' && } @@ -541,10 +571,11 @@ const ServiceDetail = () => { /> )}
+
{/* Extension slot: widgets contributed to the service detail page */} -
+ ); }; diff --git a/frontend/src/styles/components/_detail-page.scss b/frontend/src/styles/components/_detail-page.scss index a959e84d..21f599fe 100644 --- a/frontend/src/styles/components/_detail-page.scss +++ b/frontend/src/styles/components/_detail-page.scss @@ -1,39 +1,153 @@ // ============================================ // ENTITY DETAIL PAGE -// What the service and server detail pages share, so the two read as one -// layout: the top-bar meta, the body rhythm and the settings shell. Feature -// stylesheets (_service-detail, _servers) own only what is inside the tabs. -// components/detail/DetailHeaderMeta.jsx [dot] [(i)] [star] -// components/detail/DetailSettings.jsx grouped nav + content column +// The frame the service and server detail pages share, so the two read as +// one layout (components/detail/DetailPage.jsx, DetailSettings.jsx): +// +// top bar Parent / Name [star] [actions] +// identity [tile] Name [status] [badges] + meta line +// tabs [Overview] [Logs] ... [Settings] +// content +// +// Feature stylesheets (_service-detail, _servers) own only what is inside +// the tabs. // ============================================ -// Header: dot / (i) / star share one centered row beside the title. +// Top bar: breadcrumb in the title slot, the star beside it. .sk-detail-page .sk-topbar { &__titles { align-items: center; } &__meta { display: inline-flex; align-items: center; gap: $space-2; } .fav-star { - width: 24px; // geometry: matches the InfoTip md footprint - height: 24px; // geometry: matches the InfoTip md footprint + width: 24px; // geometry: icon-button footprint + height: 24px; // geometry: icon-button footprint svg { width: 14px; height: 14px; } // geometry: inline icon opacity: 0.6; &:hover, &.is-on { opacity: 1; } } } -// Facts behind the header (i): label / value pairs. -.sk-detail-info { - display: grid; - grid-template-columns: auto 1fr; - gap: $space-1 $space-3; - margin: 0; +.sk-detail-crumbs { + display: inline-flex; + align-items: center; + flex-wrap: wrap; + gap: $space-2; + overflow-wrap: anywhere; - &__row { display: contents; } + a { + color: var(--text-dim); + font-weight: $font-weight-medium; + text-decoration: none; + &:hover { color: var(--text); } + } - dt { color: var(--text-faint); } - dd { margin: 0; min-width: 0; overflow-wrap: anywhere; } + > [aria-hidden] { color: var(--text-ghost); } +} - &__id { display: flex; align-items: center; gap: $space-1; code { font-family: $font-mono; } } +// Identity: tile + name + status, a meta line and an optional description. +.sk-detail-identity { + display: flex; + align-items: flex-start; + gap: $space-4; + + > :first-child { flex-shrink: 0; } + + &__body { min-inline-size: 0; flex: 1; } + + &__title { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: $space-3; + } + + h2 { + margin: 0; + font-size: $text-lg; + font-weight: $font-weight-semibold; + letter-spacing: -0.02em; + color: var(--text); + overflow-wrap: anywhere; + } + + &__meta { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: $space-2; + margin-block-start: $space-1; + font-size: $text-xs; + color: var(--text-dim); + overflow-wrap: anywhere; + + > span { display: inline-flex; align-items: center; gap: $space-1; } + a { color: var(--accent-bright); text-decoration: none; &:hover { text-decoration: underline; } } + } + + &__sep { color: var(--text-ghost); } + + &__description { + margin-block: $space-2 0; + font-size: $text-sm; + color: var(--text-dim); + } + + .copy-chip { + display: inline-flex; + align-items: center; + gap: $space-2; + padding: $space-1 $space-2; + border: 1px solid var(--border-soft); + border-radius: $radius-control; + background: var(--surface); + color: var(--text-dim); + font-size: $text-xs; + cursor: pointer; + + &:hover { border-color: var(--border-strong); color: var(--text); } + } + + .copy-chip__value { + max-inline-size: 22ch; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } +} + +// Tab strip under the identity: one quiet bar, Settings pinned to the end. +.sk-detail-page .sk-detail-tabs { + min-inline-size: 0; + + > .tabs { + gap: $space-1; + margin: 0; + padding: $space-1; + background: var(--surface); + border: 1px solid var(--border-soft); + border-radius: $radius-card; + } + + > .tabs .tab { + display: inline-flex; + align-items: center; + gap: $space-2; + padding: $space-2 $space-3; + border: 0; + border-radius: $radius-control; + font-size: $text-sm; + font-weight: $font-weight-medium; + color: var(--text-dim); + white-space: nowrap; + + &:hover { color: var(--text); } + &[data-state='active'] { background: var(--surface-hover); color: var(--text); } + } + + > .tabs .sk-detail-tabs__end { margin-inline-start: auto; order: 2; } + > .tabs .tabs-overflow-trigger { order: 1; } + + &__content { padding-block-start: $space-5; } + .tab-content-pane { margin: 0; padding: 0; } } // Body below the top bar: one column, one gap between its blocks. diff --git a/frontend/src/styles/pages/_servers.scss b/frontend/src/styles/pages/_servers.scss index 7a7960e8..4af16913 100644 --- a/frontend/src/styles/pages/_servers.scss +++ b/frontend/src/styles/pages/_servers.scss @@ -2368,18 +2368,6 @@ gap: $space-3; } -// Phones: the server's actions are two icon buttons, so the title block and -// actions stay on ONE row (title truncates), tabs below. The shared header -// rules (dot / (i) / star) live in components/_detail-page.scss. -.server-detail-page .sk-topbar { - @media (max-width: 768px) { - &__titles { flex: 1 1 0; min-width: 0; flex-wrap: nowrap; } - &__title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; overflow-wrap: normal; } - &__spacer { display: none; } - &__actions { order: 0; width: auto; margin-left: auto; justify-content: flex-end; overflow: visible; flex-wrap: nowrap; } - } -} - // Permission-level picker in the Add Server drawer .level-picker { display: grid;