diff --git a/components/dashboard/src/projects/NewProject.tsx b/components/dashboard/src/projects/NewProject.tsx index c4e711f76c5455..61eb33c720ce09 100644 --- a/components/dashboard/src/projects/NewProject.tsx +++ b/components/dashboard/src/projects/NewProject.tsx @@ -45,6 +45,14 @@ export default function NewProject() { setProvider("github.com"); } } + if (user) { + if (!user?.rolesOrPermissions?.includes('teams-and-projects')) { + (async () => { + setUser(await getGitpodService().server.getLoggedInUser()); + })(); + + } + } }, [user]); useEffect(() => { @@ -84,6 +92,13 @@ export default function NewProject() { (async () => { updateOrgsState(); const repos = await updateReposInAccounts(); + + { // automatically enable T&P + if (!user?.rolesOrPermissions?.includes('teams-and-projects')) { + setUser(await getGitpodService().server.getLoggedInUser()); + } + } + const first = repos[0]; if (first) { setSelectedAccount(first.account); diff --git a/components/dashboard/src/teams/JoinTeam.tsx b/components/dashboard/src/teams/JoinTeam.tsx index 7dc0dbd0484b6e..15870986a7971c 100644 --- a/components/dashboard/src/teams/JoinTeam.tsx +++ b/components/dashboard/src/teams/JoinTeam.tsx @@ -7,10 +7,12 @@ import { useContext, useEffect, useState } from "react"; import { useHistory } from "react-router-dom"; import { getGitpodService } from "../service/service"; +import { UserContext } from "../user-context"; import { TeamsContext } from "./teams-context"; export default function() { const { setTeams } = useContext(TeamsContext); + const { user, setUser } = useContext(UserContext); const history = useHistory(); const [ joinError, setJoinError ] = useState(); @@ -25,6 +27,13 @@ export default function() { const team = await getGitpodService().server.joinTeam(inviteId); const teams = await getGitpodService().server.getTeams(); setTeams(teams); + + { // automatically enable T&P + if (!user?.rolesOrPermissions?.includes('teams-and-projects')) { + setUser(await getGitpodService().server.getLoggedInUser()); + } + } + history.push(`/${team.slug}/members`); } catch (error) { console.error(error); diff --git a/components/server/ee/src/workspace/gitpod-server-impl.ts b/components/server/ee/src/workspace/gitpod-server-impl.ts index 4666e6cbb60de0..677132fef0bfc3 100644 --- a/components/server/ee/src/workspace/gitpod-server-impl.ts +++ b/components/server/ee/src/workspace/gitpod-server-impl.ts @@ -1499,6 +1499,8 @@ export class GitpodServerEEImpl extends GitpodServerImpl p.cloneUrl)); repositories.forEach(r => { r.inUse = cloneUrlsInUse.has(r.cloneUrl) }); + await this.ensureTeamsEnabled(); + return repositories; } diff --git a/components/server/src/workspace/gitpod-server-impl.ts b/components/server/src/workspace/gitpod-server-impl.ts index 1268ad5404b9f4..83a0538d941b36 100644 --- a/components/server/src/workspace/gitpod-server-impl.ts +++ b/components/server/src/workspace/gitpod-server-impl.ts @@ -1427,9 +1427,22 @@ export class GitpodServerImpl { this.checkAndBlockUser("setTeamMemberRole"); await this.guardTeamOperation(teamId, "update");