|
| 1 | +use tauri::AppHandle; |
| 2 | + |
| 3 | +use crate::managed_agents::project_connections::{ |
| 4 | + self, CreateProjectConnectionRequest, ProjectConnection, ProjectConnectionScope, |
| 5 | + UpdateProjectConnectionRequest, |
| 6 | +}; |
| 7 | + |
| 8 | +#[tauri::command] |
| 9 | +pub fn list_project_connections( |
| 10 | + app: AppHandle, |
| 11 | + project_scope: ProjectConnectionScope, |
| 12 | +) -> Result<Vec<ProjectConnection>, String> { |
| 13 | + project_connections::list_project_connections(&app, &project_scope) |
| 14 | +} |
| 15 | + |
| 16 | +#[tauri::command] |
| 17 | +pub fn create_project_connection( |
| 18 | + app: AppHandle, |
| 19 | + input: CreateProjectConnectionRequest, |
| 20 | +) -> Result<ProjectConnection, String> { |
| 21 | + project_connections::create_project_connection(&app, input) |
| 22 | +} |
| 23 | + |
| 24 | +#[tauri::command] |
| 25 | +pub fn update_project_connection( |
| 26 | + app: AppHandle, |
| 27 | + input: UpdateProjectConnectionRequest, |
| 28 | +) -> Result<ProjectConnection, String> { |
| 29 | + project_connections::update_project_connection(&app, input) |
| 30 | +} |
| 31 | + |
| 32 | +#[tauri::command] |
| 33 | +pub async fn test_project_connection( |
| 34 | + app: AppHandle, |
| 35 | + project_scope: ProjectConnectionScope, |
| 36 | + connection_id: String, |
| 37 | +) -> Result<ProjectConnection, String> { |
| 38 | + tauri::async_runtime::spawn_blocking(move || { |
| 39 | + project_connections::test_project_connection(&app, &project_scope, &connection_id) |
| 40 | + }) |
| 41 | + .await |
| 42 | + .map_err(|error| format!("Project connection test task failed: {error}"))? |
| 43 | +} |
| 44 | + |
| 45 | +#[tauri::command] |
| 46 | +pub fn delete_project_connection( |
| 47 | + app: AppHandle, |
| 48 | + project_scope: ProjectConnectionScope, |
| 49 | + connection_id: String, |
| 50 | +) -> Result<(), String> { |
| 51 | + project_connections::delete_project_connection(&app, &project_scope, &connection_id) |
| 52 | +} |
0 commit comments