1
This commit is contained in:
parent
788ebcb72b
commit
2c7aff7ba1
@ -104,10 +104,10 @@ const GitManager: React.FC = () => {
|
||||
};
|
||||
|
||||
// 同步项目
|
||||
const handleSyncProjects = async (groupId: number) => {
|
||||
const handleSyncProjects = async () => {
|
||||
if (!selectedInstance) return;
|
||||
try {
|
||||
await syncGitProjects(selectedInstance, groupId);
|
||||
await syncGitProjects(selectedInstance);
|
||||
message.success('项目同步任务已启动');
|
||||
loadInstanceInfo();
|
||||
} catch (error) {
|
||||
@ -116,10 +116,10 @@ const GitManager: React.FC = () => {
|
||||
};
|
||||
|
||||
// 同步分支
|
||||
const handleSyncBranches = async (projectId: number) => {
|
||||
const handleSyncBranches = async () => {
|
||||
if (!selectedInstance) return;
|
||||
try {
|
||||
await syncGitBranches(selectedInstance, projectId);
|
||||
await syncGitBranches(selectedInstance);
|
||||
message.success('分支同步任务已启动');
|
||||
loadInstanceInfo();
|
||||
} catch (error) {
|
||||
@ -127,38 +127,6 @@ const GitManager: React.FC = () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 批量同步项目
|
||||
const handleSyncAllProjects = async () => {
|
||||
if (!selectedInstance || !instanceInfo?.repositoryGroupList) return;
|
||||
try {
|
||||
await Promise.all(
|
||||
instanceInfo.repositoryGroupList.map(group =>
|
||||
syncGitProjects(selectedInstance, group.groupId)
|
||||
)
|
||||
);
|
||||
message.success('所有项目同步任务已启动');
|
||||
loadInstanceInfo();
|
||||
} catch (error) {
|
||||
message.error('同步失败');
|
||||
}
|
||||
};
|
||||
|
||||
// 批量同步分支
|
||||
const handleSyncAllBranches = async () => {
|
||||
if (!selectedInstance || !instanceInfo?.repositoryProjectList) return;
|
||||
try {
|
||||
await Promise.all(
|
||||
instanceInfo.repositoryProjectList.map(project =>
|
||||
syncGitBranches(selectedInstance, project.projectId)
|
||||
)
|
||||
);
|
||||
message.success('所有分支同步任务已启动');
|
||||
loadInstanceInfo();
|
||||
} catch (error) {
|
||||
message.error('同步失败');
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
loadInstances();
|
||||
}, []);
|
||||
@ -238,7 +206,7 @@ const GitManager: React.FC = () => {
|
||||
</div>
|
||||
<div className="text-sm font-normal text-muted-foreground mt-1">项目</div>
|
||||
</CardTitle>
|
||||
<Button variant="ghost" size="sm" onClick={handleSyncAllProjects}>
|
||||
<Button variant="ghost" size="sm" onClick={handleSyncProjects}>
|
||||
<RefreshCw className="h-4 w-4" />
|
||||
</Button>
|
||||
</CardHeader>
|
||||
@ -258,7 +226,7 @@ const GitManager: React.FC = () => {
|
||||
</div>
|
||||
<div className="text-sm font-normal text-muted-foreground mt-1">分支</div>
|
||||
</CardTitle>
|
||||
<Button variant="ghost" size="sm" onClick={handleSyncAllBranches}>
|
||||
<Button variant="ghost" size="sm" onClick={handleSyncBranches}>
|
||||
<RefreshCw className="h-4 w-4" />
|
||||
</Button>
|
||||
</CardHeader>
|
||||
@ -301,7 +269,7 @@ const GitManager: React.FC = () => {
|
||||
</TableCell>
|
||||
<TableCell>{group.description}</TableCell>
|
||||
<TableCell>
|
||||
<Button variant="ghost" size="sm" onClick={() => handleSyncProjects(group.groupId)}>
|
||||
<Button variant="ghost" size="sm" onClick={handleSyncProjects}>
|
||||
<RefreshCw className="mr-2 h-4 w-4" />
|
||||
同步项目
|
||||
</Button>
|
||||
@ -336,7 +304,7 @@ const GitManager: React.FC = () => {
|
||||
<TableCell>{new Date(project.lastActivityAt).toLocaleString()}</TableCell>
|
||||
<TableCell>
|
||||
<div className="flex gap-2">
|
||||
<Button variant="ghost" size="sm" onClick={() => handleSyncBranches(project.projectId)}>
|
||||
<Button variant="ghost" size="sm" onClick={handleSyncBranches}>
|
||||
<RefreshCw className="mr-2 h-4 w-4" />
|
||||
同步分支
|
||||
</Button>
|
||||
|
||||
@ -25,9 +25,9 @@ export const syncGitGroups = (externalSystemId: number) =>
|
||||
request.post<void>(`${BASE_URL}/${externalSystemId}/sync-groups`);
|
||||
|
||||
// 同步 Git 项目
|
||||
export const syncGitProjects = (externalSystemId: number, groupId: number) =>
|
||||
request.post<void>(`${BASE_URL}/${externalSystemId}/groups/${groupId}/sync-projects`);
|
||||
export const syncGitProjects = (externalSystemId: number) =>
|
||||
request.post<void>(`${BASE_URL}/${externalSystemId}/groups/sync-projects`);
|
||||
|
||||
// 同步 Git 分支
|
||||
export const syncGitBranches = (externalSystemId: number, projectId: number) =>
|
||||
request.post<void>(`${BASE_URL}/${externalSystemId}/projects/${projectId}/sync-branches`);
|
||||
export const syncGitBranches = (externalSystemId: number) =>
|
||||
request.post<void>(`${BASE_URL}/${externalSystemId}/projects/sync-branches`);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user