From 4c5d7cffc637731f2e12cc9705217338bec16fbf Mon Sep 17 00:00:00 2001 From: Lu Yang Date: Fri, 11 Oct 2024 21:15:13 +0100 Subject: [PATCH] change open into a tag --- lapdev-conductor/src/server.rs | 10 +++-- lapdev-dashboard/src/workspace.rs | 63 ++++++++++------------------- lapdev-enterprise/src/enterprise.rs | 25 ++++++++++++ 3 files changed, 53 insertions(+), 45 deletions(-) diff --git a/lapdev-conductor/src/server.rs b/lapdev-conductor/src/server.rs index ce7a8eb..3be0ece 100644 --- a/lapdev-conductor/src/server.rs +++ b/lapdev-conductor/src/server.rs @@ -521,7 +521,7 @@ impl Conductor { } fn format_repo_url(&self, repo: &str) -> String { - let repo = repo.trim(); + let repo = repo.trim().to_lowercase(); let repo = if !repo.starts_with("http://") && !repo.starts_with("https://") && !repo.starts_with("ssh://") @@ -1094,7 +1094,9 @@ impl Conductor { let (id_rsa, public_key) = self.generate_key_pair()?; let osuser = org.id.to_string().replace('-', ""); - self.enterprise.check_organization_limit(org).await?; + self.enterprise + .check_organization_limit(org, user.id) + .await?; let txn = self.db.conn.begin().await?; if let Some(quota) = self @@ -2275,7 +2277,9 @@ impl Conductor { } let org = self.db.get_organization(workspace.organization_id).await?; - self.enterprise.check_organization_limit(&org).await?; + self.enterprise + .check_organization_limit(&org, workspace.user_id) + .await?; let txn = self.db.conn.begin().await?; if let Some(quota) = self diff --git a/lapdev-dashboard/src/workspace.rs b/lapdev-dashboard/src/workspace.rs index 983391d..4cb0be1 100644 --- a/lapdev-dashboard/src/workspace.rs +++ b/lapdev-dashboard/src/workspace.rs @@ -199,42 +199,6 @@ fn OpenWorkspaceView( ); }; - let open_workspace = { - dropdown_hidden.set(true); - let workspace_name = workspace_name.clone(); - let workspace_hostname = workspace_hostname.clone(); - move |_| { - let _ = window().open_with_url_and_target( - &format!("http://{workspace_name}.{workspace_hostname}/"), - "_blank", - ); - } - }; - - let open_workspace_in_vscode = { - dropdown_hidden.set(true); - let workspace_name = workspace_name.clone(); - let workspace_folder = workspace_folder.clone(); - let cluster_info = expect_context::>>(); - move |_| { - let port = cluster_info - .with_untracked(|i| i.as_ref().map(|i| i.ssh_proxy_port).unwrap_or(2222)); - let _ = window() - .open_with_url_and_target( - &format!( - "vscode://vscode-remote/ssh-remote+{workspace_name}@{}{}/workspaces/{workspace_folder}", - workspace_hostname.split(':').next().unwrap_or(""), - if port == 22 { - "".to_string() - } else { - format!(":{port}") - } - ), - "_blank" - ); - } - }; - let open_button_class = if workspace_status == WorkspaceStatus::Running { "bg-green-700 dark:bg-green-600 hover:bg-green-800 dark:hover:bg-green-700" } else { @@ -242,18 +206,23 @@ fn OpenWorkspaceView( }; let open_button_class = format!("{open_button_class} py-2 text-sm font-medium text-white focus:ring-4 focus:ring-green-300 focus:outline-none dark:focus:ring-green-800"); + let workspace_hostname = workspace_hostname.clone(); + let cluster_info = expect_context::>>(); + let port = + cluster_info.with_untracked(|i| i.as_ref().map(|i| i.ssh_proxy_port).unwrap_or(2222)); view! {
- +