Restructure ARNavi contour UX and expose project-scoped VPS inventory
Device Core qualification / qualify (push) Successful in 7m42s

This commit is contained in:
DCCONSTRUCTIONS
2026-09-30 19:35:18 +03:00
parent 1bf3ee6d41
commit c0487ca17b
17 changed files with 508 additions and 388 deletions
+27 -7
View File
@@ -1,4 +1,4 @@
import { useEffect, useMemo, useState, type FormEvent } from "react";
import { useEffect, useMemo, useRef, useState, type FormEvent } from "react";
import {
AdminNavigationPanel,
AppHeader,
@@ -188,6 +188,9 @@ export function DeviceManagerApp() {
const [workspace, setWorkspace] = useState<ProjectWorkspace | null>(null);
const [activeOwnerRef, setActiveOwnerRef] = useState("");
const [activeProjectRef, setActiveProjectRef] = useState("");
const projectRefCurrent = useRef(activeProjectRef);
projectRefCurrent.current = activeProjectRef;
const [selectedHostRef, setSelectedHostRef] = useState<string | null>(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
const [projectDialogOpen, setProjectDialogOpen] = useState(false);
@@ -286,9 +289,12 @@ export function DeviceManagerApp() {
}, [activeOwnerRef, activeProjectRef, visibleProjects]);
const selectProject = (projectRef: string) => {
if (projectRef === activeProjectRef) return;
setInventoryDetail(null);
projectRefCurrent.current = projectRef;
setWorkspace(null);
setSelectedHostRef(null);
setActiveProjectRef(projectRef);
shell.closeView();
};
const openSection = (section: PrimarySection) => {
@@ -305,14 +311,18 @@ export function DeviceManagerApp() {
};
const selectOwner = (ownerRef: string) => {
if (ownerRef === activeOwnerRef) return;
setActiveOwnerRef(ownerRef);
setInventoryDetail(null);
setSelectedHostRef(null);
setWorkspace(null);
const nextProject = projects.find((project) => project.ownerScope.ownerRef === ownerRef);
if (nextProject) {
projectRefCurrent.current = nextProject.projectRef;
setActiveProjectRef(nextProject.projectRef);
shell.closeView();
}
else {
projectRefCurrent.current = "";
setActiveProjectRef("");
setWorkspace(null);
shell.closeView();
@@ -322,6 +332,7 @@ export function DeviceManagerApp() {
const refreshWorkspace = async () => {
if (!activeProjectRef) return;
const next = await loadWorkspace(activeProjectRef);
if (projectRefCurrent.current !== activeProjectRef) return;
setWorkspace(next);
await refreshProjects();
};
@@ -329,14 +340,14 @@ export function DeviceManagerApp() {
const pollWorkspace = async () => {
if (!activeProjectRef) return;
const next = await loadWorkspace(activeProjectRef);
setWorkspace(next);
if (projectRefCurrent.current === activeProjectRef) setWorkspace(next);
};
if (loading || !session) {
return <div className="device-manager-boot">Подключаем Device Core…</div>;
}
const activeView = shell.activeView;
const activeView = visibleNavigationItems.some((item) => item.id === shell.activeView) ? shell.activeView : null;
const selectedInventoryDevice = inventoryDetail
? workspace?.devices.find((device) => device.deviceRef === inventoryDetail.deviceRef) ?? null
: null;
@@ -490,13 +501,18 @@ export function DeviceManagerApp() {
onDetailChange={setInventoryDetail}
/>
) : undefined}
utilityActions={[{
utilityActions={[...(activeView === "hosts" && selectedHostRef ? [{
label: "Вернуться к VPS и хостам", icon: "chevron-left" as const, onClick: () => setSelectedHostRef(null),
}] : []), {
label: "Обновить данные",
icon: "refresh",
onClick: () => refreshWorkspace().catch((reason) => setError(errorText(reason))),
}]}
>
<ProjectView
key={activeProjectRef}
selectedHostRef={selectedHostRef}
onSelectHost={setSelectedHostRef}
view={activeView}
workspace={workspace}
canManageCollections={canManageCollections}
@@ -783,7 +799,9 @@ function Metric({ label, value, detail, tone = "neutral" }: { label: string; val
);
}
function ProjectView({ view, workspace, canManageCollections, canClaim, canConfigure, canManageProject, inventoryDetail, session, onRefresh, onPoll, onError, onCreateCollection, onClaim, onInventoryDetailChange }: {
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;
view: ViewId;
workspace: ProjectWorkspace | null;
canManageCollections: boolean;
@@ -802,6 +820,8 @@ function ProjectView({ view, workspace, canManageCollections, canClaim, canConfi
if (!workspace) return <div className="device-manager-panel-empty">Загружаем проект…</div>;
if (["catalog", "hosts", "infrastructure", "sessions", "bindings", "commands", "audit", "access", "settings"].includes(view)) {
return <DeviceControlView
selectedHostRef={selectedHostRef}
onSelectHost={onSelectHost}
view={view as ControlViewId}
workspace={workspace}
session={session}