Skip to content

Commit

Permalink
feat: list team projects on beta (#1772)
Browse files Browse the repository at this point in the history
  • Loading branch information
chesedo authored May 15, 2024
1 parent 01c3763 commit f87b873
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 17 deletions.
6 changes: 6 additions & 0 deletions cargo-shuttle/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@ impl ShuttleApiClient {
pub async fn get_team_projects_list(&self, team_id: &str) -> Result<Vec<project::Response>> {
self.get(format!("/teams/{team_id}/projects")).await
}
pub async fn get_team_projects_list_beta(
&self,
team_id: &str,
) -> Result<Vec<project::ResponseBeta>> {
self.get(format!("/teams/{team_id}/projects")).await
}

pub async fn get_logs(
&self,
Expand Down
46 changes: 29 additions & 17 deletions cargo-shuttle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2169,26 +2169,38 @@ impl Shuttle {
println!("{}", "Personal Projects".bold());
println!("{projects_table}\n");

if self.beta {
println!("Not listing team projects (not implemented yet on beta)");
return Ok(CommandOutcome::Ok);
}

let teams = client.get_teams_list().await?;

for team in teams {
let team_projects = client
.get_team_projects_list(&team.id)
.await
.map_err(|err| {
suggestions::project::project_request_failure(
err,
"Getting teams projects list failed",
false,
"getting the team projects list fails repeatedly",
)
})?;
let team_projects_table = project::get_projects_table(&team_projects, raw);
let team_projects_table = if self.beta {
let team_projects =
client
.get_team_projects_list_beta(&team.id)
.await
.map_err(|err| {
suggestions::project::project_request_failure(
err,
"Getting teams projects list failed",
false,
"getting the team projects list fails repeatedly",
)
})?;
project::get_projects_table_beta(&team_projects)
} else {
let team_projects =
client
.get_team_projects_list(&team.id)
.await
.map_err(|err| {
suggestions::project::project_request_failure(
err,
"Getting teams projects list failed",
false,
"getting the team projects list fails repeatedly",
)
})?;
project::get_projects_table(&team_projects, raw)
};

println!("{}", format!("{}'s Projects", team.display_name).bold());
println!("{team_projects_table}\n");
Expand Down

0 comments on commit f87b873

Please sign in to comment.