From 557a5da34eac3a9389f049d8a6463a1000f449a1 Mon Sep 17 00:00:00 2001 From: Feroze Mohideen Date: Mon, 20 May 2024 16:54:33 -0400 Subject: [PATCH] fix get porter app event (#4662) --- api/server/router/porter_app.go | 56 +++++++++---------- .../events/focus-views/EventFocusView.tsx | 6 +- dashboard/src/shared/api.tsx | 5 +- 3 files changed, 35 insertions(+), 32 deletions(-) diff --git a/api/server/router/porter_app.go b/api/server/router/porter_app.go index d90fdbb5e1..1bfd558c0a 100644 --- a/api/server/router/porter_app.go +++ b/api/server/router/porter_app.go @@ -398,34 +398,6 @@ func getPorterAppRoutes( Router: r, }) - // GET /api/projects/{project_id}/clusters/{cluster_id}/events/id -> porter_app.NewGetPorterAppEventHandler - getPorterAppEventEndpoint := factory.NewAPIEndpoint( - &types.APIRequestMetadata{ - Verb: types.APIVerbCreate, - Method: types.HTTPVerbGet, - Path: &types.Path{ - Parent: basePath, - RelativePath: fmt.Sprintf("/events/{%s}", types.URLParamPorterAppEventID), - }, - Scopes: []types.PermissionScope{ - types.UserScope, - types.ProjectScope, - types.ClusterScope, - }, - }, - ) - - getPorterAppEventHandler := porter_app.NewGetPorterAppEventHandler( - config, - factory.GetResultWriter(), - ) - - routes = append(routes, &router.Route{ - Endpoint: getPorterAppEventEndpoint, - Handler: getPorterAppEventHandler, - Router: r, - }) - // POST /api/projects/{project_id}/clusters/{cluster_id}/applications/analytics -> porter_app.NewPorterAppAnalyticsHandler porterAppAnalyticsEndpoint := factory.NewAPIEndpoint( &types.APIRequestMetadata{ @@ -1763,5 +1735,33 @@ func getPorterAppRoutes( Router: r, }) + // GET /api/projects/{project_id}/clusters/{cluster_id}/apps/{porter_app_name}/events/id -> porter_app.NewGetPorterAppEventHandler + getPorterAppEventEndpoint := factory.NewAPIEndpoint( + &types.APIRequestMetadata{ + Verb: types.APIVerbCreate, + Method: types.HTTPVerbGet, + Path: &types.Path{ + Parent: basePath, + RelativePath: fmt.Sprintf("%s/{%s}/events/{%s}", relPathV2, types.URLParamPorterAppName, types.URLParamPorterAppEventID), + }, + Scopes: []types.PermissionScope{ + types.UserScope, + types.ProjectScope, + types.ClusterScope, + }, + }, + ) + + getPorterAppEventHandler := porter_app.NewGetPorterAppEventHandler( + config, + factory.GetResultWriter(), + ) + + routes = append(routes, &router.Route{ + Endpoint: getPorterAppEventEndpoint, + Handler: getPorterAppEventHandler, + Router: r, + }) + return routes, newPath } diff --git a/dashboard/src/main/home/app-dashboard/app-view/tabs/activity-feed/events/focus-views/EventFocusView.tsx b/dashboard/src/main/home/app-dashboard/app-view/tabs/activity-feed/events/focus-views/EventFocusView.tsx index 7ddaf77802..038174cefb 100644 --- a/dashboard/src/main/home/app-dashboard/app-view/tabs/activity-feed/events/focus-views/EventFocusView.tsx +++ b/dashboard/src/main/home/app-dashboard/app-view/tabs/activity-feed/events/focus-views/EventFocusView.tsx @@ -33,12 +33,13 @@ const EventFocusView: React.FC = () => { const { search } = useLocation(); const queryParams = new URLSearchParams(search); const eventId = queryParams.get("event_id"); - const { projectId, clusterId, tabUrlGenerator } = useLatestRevision(); + const { projectId, clusterId, tabUrlGenerator, appName } = + useLatestRevision(); const [event, setEvent] = useState(null); const { data } = useQuery( - ["getPorterAppEvent", projectId, clusterId, eventId, event], + ["getPorterAppEvent", projectId, clusterId, eventId, event, appName], async () => { if (eventId == null || eventId === "") { return null; @@ -50,6 +51,7 @@ const EventFocusView: React.FC = () => { project_id: projectId, cluster_id: clusterId, event_id: eventId, + porter_app_name: appName, } ); return porterAppEventValidator.parse(eventResp.data.event); diff --git a/dashboard/src/shared/api.tsx b/dashboard/src/shared/api.tsx index 3899a51360..ec82930320 100644 --- a/dashboard/src/shared/api.tsx +++ b/dashboard/src/shared/api.tsx @@ -216,10 +216,11 @@ const getPorterAppEvent = baseApi< project_id: number; cluster_id: number; event_id: string; + porter_app_name: string; } >("GET", (pathParams) => { - const { project_id, cluster_id, event_id } = pathParams; - return `/api/projects/${project_id}/clusters/${cluster_id}/events/${event_id}`; + const { project_id, cluster_id, event_id, porter_app_name } = pathParams; + return `/api/projects/${project_id}/clusters/${cluster_id}/apps/${porter_app_name}/events/${event_id}`; }); const createPorterApp = baseApi<