Skip to content

Fix environments response for new plugin #1662

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
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export async function getManagedWorkspaces(

try {
const res = await axios.get(`/api/plugins/enterprise/org/list`);
const all: ManagedOrg[] = res.data;
const all: ManagedOrg[] = res.data.data;
return all.filter(org => org.environmentId === environmentId);
} catch (err) {
const errorMsg = err instanceof Error ? err.message : "Failed to fetch managed workspaces";
Expand Down Expand Up @@ -100,7 +100,7 @@ export async function unconnectManagedWorkspace(orgGid: string) {

export async function getManagedApps(environmentId: string) {
const res = await axios.get(`/api/plugins/enterprise/app/list`);
const allApps = res.data;
const allApps = res.data.data;
return allApps.filter((app: any) => app.environmentId === environmentId);
}

Expand Down Expand Up @@ -149,7 +149,7 @@ export const getManagedDataSources = async (environmentId: string): Promise<any[
const response = await axios.get(
`/api/plugins/enterprise/datasource/list?environmentId=${environmentId}`
);
return response.data || [];
return response.data.data || [];
} catch (error) {
console.error("Error fetching managed data sources:", error);
throw error;
Expand Down Expand Up @@ -204,14 +204,15 @@ export async function getManagedQueries(environmentId: string): Promise<Query[]>
environmentId
}
});
console.log("Managed queries response function:", response.data);

if (!response.data || !Array.isArray(response.data)) {
if (!response.data.data || !Array.isArray(response.data.data)) {
return [];
}

// Map the response to match our Query interface
// Note: You may need to adjust this mapping based on the actual response structure
return response.data.map((item: any) => ({
return response.data.data.map((item: any) => ({
id: item.id || item.qlQueryId,
gid: item.qlQueryGid,
name: item.qlQueryName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export async function getEnvironments(): Promise<Environment[]> {
);

// Return the data array directly from response.data
return response.data || [];
return response.data.data || [];
} catch (error) {
const errorMessage =
error instanceof Error ? error.message : "Failed to fetch environments";
Expand All @@ -82,7 +82,7 @@ export async function getEnvironmentById(id: string): Promise<Environment> {
throw new Error("Failed to fetch environment");
}

return response.data;
return response.data.data;
} catch (error) {
const errorMessage =
error instanceof Error ? error.message : "Failed to fetch environment";
Expand Down
Loading