-
Notifications
You must be signed in to change notification settings - Fork 24
Introduce resource manage views #595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
430833c
Modify EnvironmentCard and DeployCard components
rasika2012 7f6f0f4
Add resource-configs API client and hooks
rasika2012 2a9978f
Updated `DeployCard` to include resource usage metrics with auto-refr…
rasika2012 0605e7b
Add a `EditResourceConfigsDrawer` component for managing resource r…
rasika2012 63d6fee
Refactor DeploymentConfig and EnvironmentVariable components
rasika2012 b78cc92
Enhance API client error handling and improve date handling in metric…
rasika2012 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
console/workspaces/libs/api-client/src/apis/resource-configs.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| /** | ||
| * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com). | ||
| * | ||
| * WSO2 LLC. licenses this file to you under the Apache License, | ||
| * Version 2.0 (the "License"); you may not use this file except | ||
| * in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| import { httpGET, httpPUT, SERVICE_BASE } from "../utils"; | ||
| import type { | ||
| AgentResourceConfigsResponse, | ||
| GetAgentResourceConfigsPathParams, | ||
| GetAgentResourceConfigsQuery, | ||
| UpdateAgentResourceConfigsPathParams, | ||
| UpdateAgentResourceConfigsQuery, | ||
| UpdateAgentResourceConfigsRequest, | ||
| } from "@agent-management-platform/types"; | ||
|
|
||
| function buildBaseUrl(params: GetAgentResourceConfigsPathParams): string { | ||
| const orgName = params.orgName ?? "default"; | ||
| const projName = params.projName ?? "default"; | ||
| const agentName = params.agentName; | ||
| if (!agentName) { | ||
| throw new Error("agentName is required"); | ||
| } | ||
| return `${SERVICE_BASE}/orgs/${encodeURIComponent(orgName)}/projects/${encodeURIComponent(projName)}/agents/${encodeURIComponent(agentName)}/resource-configs`; | ||
| } | ||
|
|
||
| export async function getAgentResourceConfigs( | ||
| params: GetAgentResourceConfigsPathParams, | ||
| query?: GetAgentResourceConfigsQuery, | ||
| getToken?: () => Promise<string> | ||
| ): Promise<AgentResourceConfigsResponse> { | ||
| const baseUrl = buildBaseUrl(params); | ||
| const token = getToken ? await getToken() : undefined; | ||
|
|
||
| const searchParams: Record<string, string> = {}; | ||
| if (query?.environment !== undefined) { | ||
| searchParams.environment = query.environment; | ||
| } | ||
|
|
||
| const res = await httpGET(baseUrl, { | ||
| token, | ||
| searchParams: Object.keys(searchParams).length > 0 ? searchParams : undefined, | ||
| }); | ||
| let body: unknown; | ||
| try { | ||
| body = await res.json(); | ||
| } catch { | ||
| body = await res.text().catch(() => "Failed to parse response"); | ||
| } | ||
| if (!res.ok) { | ||
| const err = new Error(typeof body === "string" ? body : "Request failed") as Error & { status?: number; statusText?: string; body?: unknown }; | ||
| err.status = res.status; | ||
| err.statusText = res.statusText; | ||
| err.body = body; | ||
| throw err; | ||
| } | ||
| return body as AgentResourceConfigsResponse; | ||
rasika2012 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| export async function updateAgentResourceConfigs( | ||
| params: UpdateAgentResourceConfigsPathParams, | ||
| body: UpdateAgentResourceConfigsRequest, | ||
| query?: UpdateAgentResourceConfigsQuery, | ||
| getToken?: () => Promise<string> | ||
| ): Promise<AgentResourceConfigsResponse> { | ||
| const baseUrl = buildBaseUrl(params); | ||
| const token = getToken ? await getToken() : undefined; | ||
|
|
||
| const searchParams: Record<string, string> = {}; | ||
| if (query?.environment !== undefined) { | ||
| searchParams.environment = query.environment; | ||
| } | ||
|
|
||
| const res = await httpPUT(baseUrl, body, { | ||
| token, | ||
| searchParams: Object.keys(searchParams).length > 0 ? searchParams : undefined, | ||
| }); | ||
| let responseBody: unknown; | ||
| try { | ||
| responseBody = await res.json(); | ||
| } catch { | ||
| responseBody = await res.text().catch(() => "Failed to parse response"); | ||
| } | ||
| if (!res.ok) { | ||
| const err = new Error(typeof responseBody === "string" ? responseBody : "Request failed") as Error & { status?: number; statusText?: string; body?: unknown }; | ||
| err.status = res.status; | ||
| err.statusText = res.statusText; | ||
| err.body = responseBody; | ||
| throw err; | ||
| } | ||
| return responseBody as AgentResourceConfigsResponse; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
console/workspaces/libs/api-client/src/hooks/resource-configs.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| /** | ||
| * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com). | ||
| * | ||
| * WSO2 LLC. licenses this file to you under the Apache License, | ||
| * Version 2.0 (the "License"); you may not use this file except | ||
| * in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| import { useQueryClient } from "@tanstack/react-query"; | ||
| import { useAuthHooks } from "@agent-management-platform/auth"; | ||
| import { useApiMutation, useApiQuery } from "./react-query-notifications"; | ||
| import { | ||
| getAgentResourceConfigs, | ||
| updateAgentResourceConfigs, | ||
| } from "../apis/resource-configs"; | ||
| import type { | ||
| AgentResourceConfigsResponse, | ||
| GetAgentResourceConfigsPathParams, | ||
| GetAgentResourceConfigsQuery, | ||
| UpdateAgentResourceConfigsPathParams, | ||
| UpdateAgentResourceConfigsQuery, | ||
| UpdateAgentResourceConfigsRequest, | ||
| } from "@agent-management-platform/types"; | ||
|
|
||
| const QUERY_KEY = "resource-configs"; | ||
|
|
||
| export function useGetAgentResourceConfigs( | ||
| params: GetAgentResourceConfigsPathParams, | ||
| query?: GetAgentResourceConfigsQuery | ||
| ) { | ||
| const { getToken } = useAuthHooks(); | ||
| return useApiQuery<AgentResourceConfigsResponse>({ | ||
| queryKey: [QUERY_KEY, params, query], | ||
| queryFn: () => getAgentResourceConfigs(params, query, getToken), | ||
| enabled: | ||
| !!params.orgName && !!params.projName && !!params.agentName, | ||
| }); | ||
| } | ||
|
|
||
| export function useUpdateAgentResourceConfigs() { | ||
| const { getToken } = useAuthHooks(); | ||
| const queryClient = useQueryClient(); | ||
| return useApiMutation< | ||
| AgentResourceConfigsResponse, | ||
| unknown, | ||
| { | ||
| params: UpdateAgentResourceConfigsPathParams; | ||
| body: UpdateAgentResourceConfigsRequest; | ||
| query?: UpdateAgentResourceConfigsQuery; | ||
| } | ||
| >({ | ||
| action: { verb: "update", target: "agent resource configs" }, | ||
| mutationFn: ({ params, body, query }) => | ||
| updateAgentResourceConfigs(params, body, query, getToken), | ||
| onSuccess: () => { | ||
| queryClient.invalidateQueries({ queryKey: [QUERY_KEY] }); | ||
| }, | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.