Skip to content

Commit 1348756

Browse files
committed
fix managed workspaces endpoint
1 parent 058db37 commit 1348756

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

client/packages/lowcoder/src/pages/setting/environments/EnvironmentDetail.tsx

+8
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import UserGroupsList from "./components/UserGroupsList";
2727
import { useEnvironmentContext } from "./context/EnvironmentContext";
2828
import { useEnvironmentWorkspaces } from "./hooks/useEnvironmentWorkspaces";
2929
import { useEnvironmentUserGroups } from "./hooks/useEnvironmentUserGroups";
30+
import { useManagedWorkspaces } from "./hooks/enterprise/useManagedWorkspaces";
3031

3132
const { Title, Text } = Typography;
3233
const { TabPane } = Tabs;
@@ -53,6 +54,13 @@ const EnvironmentDetail: React.FC = () => {
5354
workspaceStats,
5455
} = useEnvironmentWorkspaces(environment);
5556

57+
const {
58+
managedWorkspaces,
59+
managedLoading,
60+
managedError,
61+
refreshManagedWorkspaces,
62+
} = useManagedWorkspaces(environment);
63+
5664
const {
5765
userGroups,
5866
loading: userGroupsLoading,

client/packages/lowcoder/src/pages/setting/environments/hooks/enterprise/useManagedWorkspaces.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useEffect, useState } from "react";
1+
import { useEffect, useState, useCallback } from "react";
22
import { ManagedOrg } from "../../types/enterprise.types";
33
import {
44
getManagedWorkspaces,
@@ -12,7 +12,7 @@ export function useManagedWorkspaces(
1212
const [loading, setLoading] = useState<boolean>(false);
1313
const [error, setError] = useState<string | null>(null);
1414

15-
const fetchManaged = async () => {
15+
const fetchManaged = useCallback(async () => {
1616
if (!environment) return;
1717
setLoading(true);
1818
setError(null);
@@ -21,23 +21,26 @@ export function useManagedWorkspaces(
2121
try {
2222
const { environmentId, environmentApikey, environmentApiServiceUrl } = environment;
2323

24-
if (!environmentApikey || !environmentApiServiceUrl) {
24+
if (!environmentApikey) {
2525
setError("Missing API key or service URL for this environment.");
2626
setLoading(false);
2727
return;
2828
}
2929

30-
const result = await getManagedWorkspaces(environmentId, environmentApiServiceUrl);
30+
const result = await getManagedWorkspaces(environmentId);
31+
console.log("Managed workspaces:", result);
3132
setManaged(result);
3233
} catch (err: any) {
3334
setError(err.message ?? "Failed to load managed workspaces");
3435
} finally {
3536
setLoading(false);
3637
}
37-
};
38+
} , [environment]);
3839

3940
useEffect(() => {
40-
fetchManaged();
41+
if(environment) {
42+
fetchManaged();
43+
}
4144
}, [environment, fetchManaged]);
4245

4346
return {

client/packages/lowcoder/src/pages/setting/environments/services/enterprise.service.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ import { ManagedOrg } from "../types/enterprise.types";
1212

1313
export async function getManagedWorkspaces(
1414
environmentId: string,
15-
apiServiceUrl: string
15+
1616
): Promise<ManagedOrg[]> {
17-
if (!environmentId || !apiServiceUrl) {
18-
throw new Error("Missing environmentId or apiServiceUrl");
17+
if (!environmentId) {
18+
throw new Error("Missing environmentId");
1919
}
2020

2121
try {
22-
const res = await axios.get(`${apiServiceUrl}/api/plugins/enterprise/org`);
22+
const res = await axios.get(`/api/plugins/enterprise/org/list`);
2323
const all: ManagedOrg[] = res.data;
2424
return all.filter(org => org.environmentId === environmentId);
2525
} catch (err) {

0 commit comments

Comments
 (0)