Skip to content

Commit 7c82e60

Browse files
committed
Add workspace deployment endpoint
1 parent 6633573 commit 7c82e60

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

client/packages/lowcoder/src/pages/setting/environments/config/workspace.config.tsx

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import React from 'react';
33
import { Row, Col, Statistic, Tag } from 'antd';
44
import { ClusterOutlined, AuditOutlined } from '@ant-design/icons';
55
import { Workspace, WorkspaceStats, DeployableItemConfig } from '../types/deployable-item.types';
6+
import { Environment } from '../types/environment.types';
67
import { buildEnvironmentWorkspaceId } from '@lowcoder-ee/constants/routesURL';
7-
import { getMergedEnvironmentWorkspaces } from '../services/workspace.service';
8+
import { getMergedEnvironmentWorkspaces, deployWorkspace } from '../services/workspace.service';
89
import { connectManagedWorkspace, unconnectManagedWorkspace } from '../services/enterprise.service';
910
import {
1011
createNameColumn,
@@ -153,5 +154,27 @@ export const workspaceConfig: DeployableItemConfig<Workspace, WorkspaceStats> =
153154
tooltip: 'View audit logs for this workspace',
154155
getAuditUrl: (item, environment) =>
155156
`/setting/audit?environmentId=${environment.environmentId}&orgId=${item.id}&pageSize=100&pageNum=1`
157+
},
158+
159+
// Deploy configuration
160+
deploy: {
161+
enabled: true,
162+
fields: [
163+
{
164+
name: 'updateDependenciesIfNeeded',
165+
label: 'Update Dependencies If Needed',
166+
type: 'checkbox',
167+
defaultValue: false
168+
}
169+
],
170+
prepareParams: (item: Workspace, values: any, sourceEnv: Environment, targetEnv: Environment) => {
171+
return {
172+
envId: sourceEnv.environmentId,
173+
targetEnvId: targetEnv.environmentId,
174+
workspaceId: item.id,
175+
updateDependenciesIfNeeded: values.updateDependenciesIfNeeded
176+
};
177+
},
178+
execute: (params: any) => deployWorkspace(params)
156179
}
157180
};

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { getEnvironmentWorkspaces } from "./environments.service";
44
import { getManagedWorkspaces } from "./enterprise.service";
55
import { Workspace } from "../types/workspace.types";
66
import { ManagedOrg } from "../types/enterprise.types";
7+
import axios from "axios";
78

89
export interface WorkspaceStats {
910
total: number;
@@ -73,4 +74,25 @@ export async function getMergedEnvironmentWorkspaces(
7374
message.error(errorMessage);
7475
throw error;
7576
}
77+
}
78+
79+
/**
80+
* Deploy a workspace to another environment
81+
* @param params Deployment parameters
82+
* @returns Promise with boolean indicating success
83+
*/
84+
export async function deployWorkspace(params: {
85+
envId: string;
86+
targetEnvId: string;
87+
workspaceId: string;
88+
updateDependenciesIfNeeded?: boolean;
89+
}): Promise<boolean> {
90+
try {
91+
const response = await axios.post('/api/plugins/enterprise/deploy', params);
92+
return response.status === 200;
93+
} catch (error) {
94+
const errorMessage = error instanceof Error ? error.message : 'Failed to deploy workspace';
95+
message.error(errorMessage);
96+
throw error;
97+
}
7698
}

0 commit comments

Comments
 (0)