Open LLDP job detail when jumping from canvas discover.

Pass job_id in the LLDP page URL so the network module auto-opens the task detail modal.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-08-05 19:27:52 +08:00
parent fa8e3abcc7
commit 84a4fc037a
3 changed files with 27 additions and 4 deletions

View file

@ -1602,6 +1602,7 @@ export function TopologyPage() {
const out: TopologyDiscoverOut = { const out: TopologyDiscoverOut = {
map_id: mapId, map_id: mapId,
protocol: "lldp", protocol: "lldp",
job_id: job.id,
scanned: job.done, scanned: job.done,
edges_added: job.edges_added, edges_added: job.edges_added,
edges_updated: job.edges_updated, edges_updated: job.edges_updated,
@ -3533,12 +3534,14 @@ export function TopologyPage() {
<button <button
type="button" type="button"
className="btn btn--sm btn--ghost" className="btn btn--sm btn--ghost"
onClick={() => onClick={() => {
const jobId = String(discoverReport?.job_id || "").trim();
const qs = jobId ? `?job_id=${encodeURIComponent(jobId)}` : "";
openOrFocusModule({ openOrFocusModule({
moduleId: "network", moduleId: "network",
path: "/network/topology/lldp", path: `/network/topology/lldp${qs}`,
}) });
} }}
> >
{t("topology.discoverGoLldp")} {t("topology.discoverGoLldp")}
</button> </button>

View file

@ -1,5 +1,6 @@
import { useEffect, useMemo, useState } from "react"; import { useEffect, useMemo, useState } from "react";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { useSearchParams } from "react-router-dom";
import { import {
fetchCliTargets, fetchCliTargets,
fetchFabricEdges, fetchFabricEdges,
@ -28,6 +29,7 @@ export function LldpLinksPage() {
const { t } = useI18n(); const { t } = useI18n();
const { showOk, showError } = useToast(); const { showOk, showError } = useToast();
const queryClient = useQueryClient(); const queryClient = useQueryClient();
const [searchParams, setSearchParams] = useSearchParams();
const [jobPage, setJobPage] = useState(1); const [jobPage, setJobPage] = useState(1);
const [expandedJobId, setExpandedJobId] = useState(""); const [expandedJobId, setExpandedJobId] = useState("");
@ -91,6 +93,23 @@ export function LldpLinksPage() {
setPolicyHydrated(true); setPolicyHydrated(true);
}, [dashQuery.data, policyHydrated]); }, [dashQuery.data, policyHydrated]);
// Deep link from topology canvas: /network/topology/lldp?job_id=…
useEffect(() => {
const jobId = String(searchParams.get("job_id") || "").trim();
if (!jobId) return;
setItemDetail(null);
setItemPage(1);
setExpandedJobId(jobId);
setSearchParams(
(prev) => {
const next = new URLSearchParams(prev);
if (next.get("job_id") === jobId) next.delete("job_id");
return next;
},
{ replace: true },
);
}, [searchParams, setSearchParams]);
const jobsQuery = useQuery({ const jobsQuery = useQuery({
queryKey: queryKeys.lldpCollectJobs(jobPage), queryKey: queryKeys.lldpCollectJobs(jobPage),
queryFn: () => fetchLldpCollectJobs({ page: jobPage, pageSize: 10 }), queryFn: () => fetchLldpCollectJobs({ page: jobPage, pageSize: 10 }),

View file

@ -636,6 +636,7 @@ export type TopologyDiscoverNeResult = TopologyDiscoverJobItem & {
export type TopologyDiscoverOut = { export type TopologyDiscoverOut = {
map_id?: string; map_id?: string;
protocol?: string; protocol?: string;
job_id?: string;
scanned: number; scanned: number;
edges_added: number; edges_added: number;
edges_updated: number; edges_updated: number;