fix(ui): align project overview counts and complete functional labels
Device Core qualification / qualify (push) Successful in 8m43s
Device Core qualification / qualify (push) Successful in 8m43s
This commit is contained in:
@@ -58,6 +58,8 @@ import type {
|
||||
ProjectWorkspace,
|
||||
} from "./types";
|
||||
import { EnvironmentMediaPlaylistEditor } from "./EnvironmentMediaPlaylistEditor";
|
||||
import { useB2Inventory } from "./b2/useB2Inventory";
|
||||
import { capabilityLabel, projectRoleLabel } from "./presentationLabels";
|
||||
import {
|
||||
DeviceControlView,
|
||||
type ControlViewId,
|
||||
@@ -779,14 +781,6 @@ function EnvironmentBackdrop({
|
||||
);
|
||||
}
|
||||
|
||||
function Metric({ label, value, detail, tone = "neutral" }: { label: string; value: number; detail: string; tone?: "neutral" | "success" | "warning" }) {
|
||||
return (
|
||||
<SettingsCard title={label}>
|
||||
<ResourceRow title={String(value)} metadata={detail} status={<StatusBadge variant="indicator" tone={tone} aria-label={label} />} />
|
||||
</SettingsCard>
|
||||
);
|
||||
}
|
||||
|
||||
function ProjectView({ selectedHostRef, onSelectHost, view, workspace, canManageCollections, canClaim, canConfigure, canManageProject, inventoryDetail, session, onRefresh, onPoll, onError, onCreateCollection, onClaim, onInventoryDetailChange }: {
|
||||
selectedHostRef: string | null;
|
||||
onSelectHost: (hostRef: string | null) => void;
|
||||
@@ -849,16 +843,28 @@ function ProjectView({ selectedHostRef, onSelectHost, view, workspace, canManage
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
return <ProjectOverview key={workspace.project.projectRef} workspace={workspace} />;
|
||||
}
|
||||
|
||||
function ProjectOverview({ workspace }: { workspace: ProjectWorkspace }) {
|
||||
const b2 = useB2Inventory(workspace.project.projectRef, workspace);
|
||||
const [showPermissions, setShowPermissions] = useState(false);
|
||||
const incomplete = !b2.data || b2.data.hosts.some((host) => !host.reachable);
|
||||
const deviceCount = incomplete ? null : workspace.devices.filter((device) => !['suspended', 'retired'].includes(device.lifecycleState)).length + b2.data!.items.length;
|
||||
const deviceDetail = !incomplete ? 'В реестре' : (b2.error || b2.data) ? 'Данные VPS недоступны' : 'Загрузка…';
|
||||
const metrics = [
|
||||
{ label: 'Устройства', value: deviceCount, detail: deviceDetail },
|
||||
{ label: 'Ожидают проверки', value: workspace.discoveries.filter((item) => item.lifecycleState === 'quarantine').length, detail: 'Обнаружены' },
|
||||
{ label: 'Коллекции', value: workspace.collections.length, detail: 'Группы устройств' },
|
||||
];
|
||||
return (
|
||||
<div className="device-manager-overview-grid">
|
||||
<Metric label="Устройства" value={workspace.devices.length} detail="В реестре" />
|
||||
<Metric label="Ожидают проверки" value={workspace.discoveries.filter((item) => item.lifecycleState === "quarantine").length} detail="Обнаружены" />
|
||||
<Metric label="Коллекции" value={workspace.collections.length} detail="Группы устройств" />
|
||||
<SettingsCard title="Права проекта" description={workspace.project.access.projectRole || "read"}>
|
||||
<div className="device-manager-capabilities">
|
||||
{workspace.project.access.capabilities.map((capability) => <StatusBadge key={capability}>{capability}</StatusBadge>)}
|
||||
</div>
|
||||
</SettingsCard>
|
||||
<ResourceList>{metrics.map((metric) => <li key={metric.label}><ResourceRow title={metric.label} metadata={metric.detail} status={<StatusBadge>{metric.value ?? '—'}</StatusBadge>} /></li>)}</ResourceList>
|
||||
<ResourceRow title="Ваш доступ" metadata={projectRoleLabel(workspace.project.access.projectRole || 'read')}
|
||||
actions={<IconButton label="Права в проекте" aria-expanded={showPermissions} aria-controls="project-permissions" onClick={() => setShowPermissions(!showPermissions)}><Icon name={showPermissions ? 'chevron-up' : 'chevron-down'} /></IconButton>} />
|
||||
{showPermissions ? <div id="project-permissions"><ResourceList>
|
||||
{workspace.project.access.capabilities.map((capability) => <li key={capability}><ResourceRow title={capabilityLabel(capability)} /></li>)}
|
||||
</ResourceList></div> : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1460,11 +1466,11 @@ function viewTitle(view: ViewId) {
|
||||
collections: "Коллекции",
|
||||
catalog: "Модели и адаптеры",
|
||||
hosts: "VPS и хосты",
|
||||
infrastructure: "Edges и маршруты",
|
||||
sessions: "Gateway sessions",
|
||||
bindings: "Data bindings",
|
||||
commands: "Command ledger",
|
||||
audit: "Immutable audit",
|
||||
infrastructure: "Узлы и маршруты",
|
||||
sessions: "Подключения устройств",
|
||||
bindings: "Связи с Foundry",
|
||||
commands: "Команды",
|
||||
audit: "Аудит",
|
||||
access: "Доступ к проекту",
|
||||
settings: "Настройки и конфигурации",
|
||||
})[view];
|
||||
|
||||
Reference in New Issue
Block a user