make "deploy new relay" open the modal

This commit is contained in:
x032205
2025-10-17 23:25:48 -04:00
parent 0024013a8b
commit 4c1b13d959
3 changed files with 25 additions and 3 deletions
@@ -166,7 +166,7 @@ export const DeployGatewayModal = ({ isOpen, onOpenChange }: Props) => {
onChange={(newValue) => { onChange={(newValue) => {
if ((newValue as SingleValue<{ id: string }>)?.id === "_create") { if ((newValue as SingleValue<{ id: string }>)?.id === "_create") {
navigate({ navigate({
search: { selectedTab: "relays" } search: (prev) => ({ ...prev, selectedTab: "relays", action: "deploy-relay" })
}); });
return; return;
} }
@@ -1,4 +1,4 @@
import { useState } from "react"; import { useEffect, useState } from "react";
import { import {
faArrowUpRightFromSquare, faArrowUpRightFromSquare,
faBookOpen, faBookOpen,
@@ -12,6 +12,7 @@ import {
faTrash faTrash
} from "@fortawesome/free-solid-svg-icons"; } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { useNavigate, useSearch } from "@tanstack/react-router";
import { formatRelative } from "date-fns"; import { formatRelative } from "date-fns";
import { createNotification } from "@app/components/notifications"; import { createNotification } from "@app/components/notifications";
@@ -36,6 +37,7 @@ import {
Tooltip, Tooltip,
Tr Tr
} from "@app/components/v2"; } from "@app/components/v2";
import { ROUTE_PATHS } from "@app/const/routes";
import { import {
OrgPermissionSubjects, OrgPermissionSubjects,
OrgRelayPermissionActions OrgRelayPermissionActions
@@ -75,6 +77,25 @@ export const RelayTab = withPermission(
"deployRelay" "deployRelay"
] as const); ] as const);
const action = useSearch({
from: ROUTE_PATHS.Organization.NetworkingPage.id,
select: (s) => s.action
});
const navigate = useNavigate({
from: ROUTE_PATHS.Organization.NetworkingPage.path
});
useEffect(() => {
if (action === "deploy-relay") {
handlePopUpOpen("deployRelay");
navigate({
search: (prev) => ({ ...prev, action: undefined }),
replace: true
});
}
}, [action]);
const deleteRelayById = useDeleteRelayById(); const deleteRelayById = useDeleteRelayById();
const handleDeleteRelay = async () => { const handleDeleteRelay = async () => {
@@ -5,7 +5,8 @@ import { z } from "zod";
import { NetworkingPage } from "./NetworkingPage"; import { NetworkingPage } from "./NetworkingPage";
const NetworkingPageQueryParams = z.object({ const NetworkingPageQueryParams = z.object({
selectedTab: z.string().catch("gateways") selectedTab: z.string().catch("gateways"),
action: z.string().optional()
}); });
export const Route = createFileRoute( export const Route = createFileRoute(