Make search results open the actual entry, not just its list page
Previously a search result for a secret/IP/integration/DNS record only filtered or scrolled to the right page — you still had to find and click it yourself. Now: - Secrets/IPAM results pass ?editId= and the page auto-opens that row's existing edit form on load (viewers still just get the ?q= filter, since they can't edit). - Integration results now link to /integrations?editId= (which auto-opens IntegrationEditForm for that row) instead of the type's live dashboard page (/proxmox, /tailscale, etc.) — the dashboard can't distinguish between two integrations of the same type anyway, so it wasn't landing on "the" entry when more than one existed. - DNS record results now also pass recordType/recordName/recordContent so Dns.tsx, after auto-selecting the right zone, finds that exact record by (type, name, content) and opens its edit form too. That triple was used instead of an id because the records-list endpoint returns both the cache table's internal integer id and the provider's own string record id under different field names, and matching by content sidesteps that ambiguity entirely rather than risking picking the wrong one. Servers and DNS zones/providers already landed on their real entry (server detail page; zone/provider auto-selected) so those are unchanged. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
009bb3e027
commit
5c1376cf1c
5 files changed
+45
-18
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import { useEffect, useState, type CSSProperties } from "react";
|
||||
import { useSearchParams } from "react-router-dom";
|
||||
import { api, type CurrentUser, type IntegrationSummary, type IntegrationType } from "../api/client";
|
||||
import IntegrationForm from "../components/IntegrationForm";
|
||||
import IntegrationEditForm from "../components/IntegrationEditForm";
|
||||
@@ -23,6 +24,7 @@ function typeBadgeStyle(colors: Record<string, string>, type: IntegrationType):
|
||||
|
||||
export default function Integrations({ user }: { user: CurrentUser }) {
|
||||
const isAdmin = user.role === "admin";
|
||||
const [searchParams] = useSearchParams();
|
||||
|
||||
const [integrations, setIntegrations] = useState<IntegrationSummary[] | null>(null);
|
||||
const [adding, setAdding] = useState(false);
|
||||
@@ -39,7 +41,13 @@ export default function Integrations({ user }: { user: CurrentUser }) {
|
||||
function loadIntegrations() {
|
||||
api.integrations
|
||||
.list()
|
||||
.then((res) => setIntegrations(res.integrations))
|
||||
.then((res) => {
|
||||
setIntegrations(res.integrations);
|
||||
// Deep-link from global search (?editId=) — jump straight to that integration's edit form.
|
||||
const editId = Number(searchParams.get("editId"));
|
||||
const target = res.integrations.find((i) => i.id === editId);
|
||||
if (target && isAdmin) setEditingIntegration(target);
|
||||
})
|
||||
.catch((err) => setError(String(err)));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user