Skip to content

Commit ee55176

Browse files
fix: Refactor runhook creation
1 parent 6caee9a commit ee55176

File tree

16 files changed

+362
-344
lines changed

16 files changed

+362
-344
lines changed

apps/webservice/src/app/[workspaceSlug]/(app)/systems/[systemSlug]/_components/EditAgentConfigDialog.tsx

Lines changed: 0 additions & 137 deletions
This file was deleted.

apps/webservice/src/app/[workspaceSlug]/(app)/systems/[systemSlug]/deployments/[deploymentSlug]/NavigationMenuAction.tsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client";
22

33
import React from "react";
4-
import { usePathname } from "next/navigation";
4+
import { useParams, usePathname } from "next/navigation";
55

66
import { Button } from "@ctrlplane/ui/button";
77

@@ -15,6 +15,7 @@ export const NavigationMenuAction: React.FC<{
1515
deploymentId: string;
1616
systemId: string;
1717
}> = ({ deploymentId, systemId }) => {
18+
const { workspaceSlug } = useParams<{ workspaceSlug: string }>();
1819
const pathname = usePathname();
1920
const isVariablesActive = pathname.includes("variables");
2021
const isReleaseChannelsActive = pathname.includes("release-channels");
@@ -24,8 +25,13 @@ export const NavigationMenuAction: React.FC<{
2425
api.deployment.releaseChannel.list.byDeploymentId.useQuery(deploymentId);
2526
const releaseChannels = releaseChannelsQ.data ?? [];
2627

27-
const runbooksQ = api.runbook.bySystemId.useQuery(systemId);
28-
const runbooks = runbooksQ.data ?? [];
28+
const workspaceQ = api.workspace.bySlug.useQuery(workspaceSlug);
29+
const workspace = workspaceQ.data;
30+
31+
const jobAgentsQ = api.job.agent.byWorkspaceId.useQuery(workspace?.id ?? "", {
32+
enabled: workspace != null,
33+
});
34+
const jobAgents = jobAgentsQ.data ?? [];
2935

3036
return (
3137
<div>
@@ -48,8 +54,12 @@ export const NavigationMenuAction: React.FC<{
4854
</CreateReleaseChannelDialog>
4955
)}
5056

51-
{isHooksActive && (
52-
<CreateHookDialog deploymentId={deploymentId} runbooks={runbooks}>
57+
{isHooksActive && workspace != null && (
58+
<CreateHookDialog
59+
deploymentId={deploymentId}
60+
jobAgents={jobAgents}
61+
workspace={workspace}
62+
>
5363
<Button size="sm" variant="secondary">
5464
New Hook
5565
</Button>

0 commit comments

Comments
 (0)