Skip to content

Commit 7660432

Browse files
committed
implement new managed obj endpoints
1 parent 2b4a718 commit 7660432

File tree

6 files changed

+182
-181
lines changed

6 files changed

+182
-181
lines changed

client/packages/lowcoder/src/pages/setting/environments/context/WorkspaceContext.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ import React, {
1212
import { useSingleEnvironmentContext } from "./SingleEnvironmentContext";
1313
import { fetchWorkspaceById } from "../services/environments.service";
1414
import { Workspace } from "../types/workspace.types";
15-
import { getManagedWorkspaces } from "../services/enterprise.service";
16-
import { ManagedObjectType, setManagedObject, unsetManagedObject } from "../services/managed-objects.service";
15+
import { getManagedObjects, ManagedObjectType, setManagedObject, unsetManagedObject } from "../services/managed-objects.service";
1716

1817
interface WorkspaceContextState {
1918
// Workspace data
@@ -87,10 +86,10 @@ import React, {
8786
}
8887

8988
// Fetch managed workspaces to check if this one is managed
90-
const managedWorkspaces = await getManagedWorkspaces(environment.environmentId);
89+
const managedWorkspaces = await getManagedObjects(environment.environmentId, ManagedObjectType.ORG);
9190

9291
// Set the managed status
93-
const isManaged = managedWorkspaces.some(org => org.orgGid === workspaceData.gid);
92+
const isManaged = managedWorkspaces.some(org => org.objGid === workspaceData.gid);
9493

9594
// Update the workspace with managed status
9695
setWorkspace({

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { getWorkspaceApps } from "./environments.service";
44
import { getManagedApps } from "./enterprise.service";
55
import { App, AppStats } from "../types/app.types";
66
import axios from "axios";
7+
import { getManagedObjects, ManagedObject } from "./managed-objects.service";
78

89

910
export interface MergedAppsResult {
@@ -24,10 +25,13 @@ export interface DeployAppParams {
2425

2526

2627
// Use your existing merge function with slight modification
27-
export const getMergedApps = (standardApps: App[], managedApps: any[]): App[] => {
28+
export const getMergedApps = (standardApps: App[], managedObjects: ManagedObject[]): App[] => {
2829
return standardApps.map((app) => ({
2930
...app,
30-
managed: managedApps.some((managedApp) => managedApp.appGid === app.applicationGid),
31+
managed: managedObjects.some((managedObj) =>
32+
managedObj.objGid === app.applicationGid &&
33+
managedObj.objType === "APP"
34+
),
3135
}));
3236
};
3337

@@ -71,17 +75,17 @@ export async function getMergedWorkspaceApps(
7175
};
7276
}
7377

74-
// Only fetch managed apps if we have regular apps
75-
let managedApps = [];
78+
// Fetch managed objects instead of managed apps
79+
let managedObjects: ManagedObject[] = [];
7680
try {
77-
managedApps = await getManagedApps(environmentId);
81+
managedObjects = await getManagedObjects(environmentId);
7882
} catch (error) {
79-
console.error("Failed to fetch managed apps:", error);
83+
console.error("Failed to fetch managed objects:", error);
8084
// Continue with empty managed list
8185
}
8286

83-
// Use your existing merge function
84-
const mergedApps = getMergedApps(regularApps, managedApps);
87+
// Use the updated merge function
88+
const mergedApps = getMergedApps(regularApps, managedObjects);
8589

8690
// Calculate stats
8791
const stats = calculateAppStats(mergedApps);

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import axios from 'axios';
33
import { message } from "antd";
44
import { DataSource, DataSourceWithMeta } from "../types/datasource.types";
5-
import { getManagedDataSources } from "./enterprise.service";
5+
import { getManagedObjects, ManagedObject, ManagedObjectType } from "./managed-objects.service";
66

77
export interface DataSourceStats {
88
total: number;
@@ -71,12 +71,12 @@ export async function getWorkspaceDataSources(
7171
}
7272

7373
// Function to merge regular and managed data sources
74-
export const getMergedDataSources = (standardDataSources: DataSourceWithMeta[], managedDataSources: any[]): DataSource[] => {
74+
export const getMergedDataSources = (standardDataSources: DataSourceWithMeta[], managedObjects: ManagedObject[]): DataSource[] => {
7575
return standardDataSources.map((dataSourceWithMeta) => {
7676
const dataSource = dataSourceWithMeta.datasource;
7777
return {
7878
...dataSource,
79-
managed: managedDataSources.some((managedDs) => managedDs.datasourceGid === dataSource.gid),
79+
managed: managedObjects.some((obj) => obj.objGid === dataSource.gid && obj.objType === ManagedObjectType.DATASOURCE),
8080
};
8181
});
8282
};
@@ -123,16 +123,16 @@ export async function getMergedWorkspaceDataSources(
123123
}
124124

125125
// Only fetch managed data sources if we have regular data sources
126-
let managedDataSources = [];
126+
let managedObjects: ManagedObject[] = [];
127127
try {
128-
managedDataSources = await getManagedDataSources(environmentId);
128+
managedObjects = await getManagedObjects(environmentId, ManagedObjectType.DATASOURCE);
129129
} catch (error) {
130130
console.error("Failed to fetch managed data sources:", error);
131131
// Continue with empty managed list
132132
}
133133

134134
// Use the merge function
135-
const mergedDataSources = getMergedDataSources(regularDataSourcesWithMeta, managedDataSources);
135+
const mergedDataSources = getMergedDataSources(regularDataSourcesWithMeta, managedObjects);
136136

137137
// Calculate stats
138138
const stats = calculateDataSourceStats(mergedDataSources);

0 commit comments

Comments
 (0)