Skip to content

Commit

Permalink
fix get porter app event
Browse files Browse the repository at this point in the history
  • Loading branch information
Feroze Mohideen committed May 20, 2024
1 parent 7cd7e37 commit 95be4ae
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 32 deletions.
56 changes: 28 additions & 28 deletions api/server/router/porter_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<SupportedEventFocusViewEvent | null>(null);

const { data } = useQuery(
["getPorterAppEvent", projectId, clusterId, eventId, event],
["getPorterAppEvent", projectId, clusterId, eventId, event, appName],
async () => {
if (eventId == null || eventId === "") {
return null;
Expand All @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions dashboard/src/shared/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<
Expand Down

0 comments on commit 95be4ae

Please sign in to comment.