Skip to content

Commit

Permalink
fix(turborepo): Allow users to select a Vercel team when linking a re…
Browse files Browse the repository at this point in the history
…pository to a Space (#5533)
  • Loading branch information
mknichel authored Jul 18, 2023
1 parent 814f0a2 commit 5955625
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions crates/turborepo-lib/src/commands/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub(crate) const REMOTE_CACHING_INFO: &str = " Remote Caching shares your cache
This results in faster build times and deployments for your team.";
pub(crate) const REMOTE_CACHING_URL: &str =
"https://turbo.build/repo/docs/core-concepts/remote-caching";
pub(crate) const SPACES_URL: &str = "https://vercel.com/docs/spaces";
pub(crate) const SPACES_URL: &str = "https://vercel.com/docs/workflow-collaboration/vercel-spaces";

/// Verifies that caching status for a team is enabled, or prompts the user to
/// enable it.
Expand Down Expand Up @@ -205,8 +205,31 @@ pub async fn link(
return Err(anyhow!("canceled"));
}

let user_response = api_client
.get_user(token)
.await
.context("could not get user information")?;

let user_display_name = user_response
.user
.name
.as_deref()
.unwrap_or(user_response.user.username.as_str());

let teams_response = api_client
.get_teams(token)
.await
.context("could not get team information")?;

let selected_team = select_team(base, &teams_response.teams, user_display_name)?;

let team_id = match selected_team {
SelectedTeam::User => user_response.user.id.as_str(),
SelectedTeam::Team(team) => team.id.as_str(),
};

let spaces_response = api_client
.get_spaces(token, base.repo_config()?.team_id())
.get_spaces(token, Some(team_id))
.await
.context("could not get spaces information")?;

Expand Down

0 comments on commit 5955625

Please sign in to comment.