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

View file

@ -1,5 +1,6 @@
import { useEffect, useMemo, useState } from "react";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { useSearchParams } from "react-router-dom";
import {
fetchCliTargets,
fetchFabricEdges,
@ -28,6 +29,7 @@ export function LldpLinksPage() {
const { t } = useI18n();
const { showOk, showError } = useToast();
const queryClient = useQueryClient();
const [searchParams, setSearchParams] = useSearchParams();
const [jobPage, setJobPage] = useState(1);
const [expandedJobId, setExpandedJobId] = useState("");
@ -91,6 +93,23 @@ export function LldpLinksPage() {
setPolicyHydrated(true);
}, [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({
queryKey: queryKeys.lldpCollectJobs(jobPage),
queryFn: () => fetchLldpCollectJobs({ page: jobPage, pageSize: 10 }),

View file

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