mirror of
https://github.com/hansjone/netx.git
synced 2026-10-10 12:40:44 +08:00
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:
parent
fa8e3abcc7
commit
84a4fc037a
3 changed files with 27 additions and 4 deletions
|
|
@ -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 }),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue