Skip to content

[t&p] enable teams and projects ui #5957

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 6 additions & 17 deletions components/dashboard/src/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export default function Menu() {
}

const userFullName = user?.fullName || user?.name || '...';
const showTeamsUI = user?.rolesOrPermissions?.includes('teams-and-projects');
const team = getCurrentTeam(location, teams);

{
Expand All @@ -71,7 +70,7 @@ export default function Menu() {

const [ teamMembers, setTeamMembers ] = useState<Record<string, TeamMemberInfo[]>>({});
useEffect(() => {
if (!showTeamsUI || !teams) {
if (!teams) {
return;
}
(async () => {
Expand Down Expand Up @@ -127,10 +126,10 @@ export default function Menu() {
}
// User menu
return [
...(showTeamsUI ? [{
{
title: 'Projects',
link: '/projects'
}] : []),
},
{
title: 'Workspaces',
link: '/workspaces',
Expand Down Expand Up @@ -239,17 +238,7 @@ export default function Menu() {
<img src={gitpodIcon} className="h-6" />
</Link>
{!isMinimalUI && <div className="ml-2 text-base">
{showTeamsUI
? renderTeamMenu()
: <nav className="flex-1">
<ul className="flex flex-1 items-center justify-between text-base text-gray-700 space-x-2">
<li className="flex-1"></li>
{leftMenu.map(entry => <li key={entry.title}>
<PillMenuItem name={entry.title} selected={isSelected(entry, location)} link={entry.link}/>
</li>)}
</ul>
</nav>
}
{renderTeamMenu()}
</div>}
</div>
<div className="flex flex-1 items-center w-auto" id="menu">
Expand Down Expand Up @@ -283,10 +272,10 @@ export default function Menu() {
</div>
</div>
</div>
{!isMinimalUI && showTeamsUI && !prebuildId && <div className="flex">
{!isMinimalUI && !prebuildId && <div className="flex">
{leftMenu.map((entry: Entry) => <TabMenuItem key={entry.title} name={entry.title} selected={isSelected(entry, location)} link={entry.link}/>)}
</div>}
</header>
{showTeamsUI && <Separator />}
<Separator />
</>;
}
15 changes: 0 additions & 15 deletions components/dashboard/src/projects/NewProject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,6 @@ export default function NewProject() {
setProvider("github.com");
}
}
if (user) {
if (!user?.rolesOrPermissions?.includes('teams-and-projects')) {
(async () => {
setUser(await getGitpodService().server.getLoggedInUser());
})();

}
}
}, [user]);

useEffect(() => {
Expand Down Expand Up @@ -93,13 +85,6 @@ 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);
Expand Down
2 changes: 1 addition & 1 deletion components/dashboard/src/service/service-mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const u1: User = {
"primaryEmail": "tester@gitpod.io",
}
],
rolesOrPermissions: ["teams-and-projects"],
rolesOrPermissions: [],
additionalData: {
whatsNewSeen: {
"April-2021": "true",
Expand Down
8 changes: 0 additions & 8 deletions components/dashboard/src/teams/JoinTeam.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
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<Error>();
Expand All @@ -28,12 +26,6 @@ export default function() {
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(`/t/${team.slug}/members`);
} catch (error) {
console.error(error);
Expand Down
1 change: 0 additions & 1 deletion components/gitpod-protocol/src/permission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export const Permissions = {
"admin-api": undefined,
"ide-settings": undefined,
"new-workspace-cluster": undefined,
"teams-and-projects": undefined,
};
export type PermissionName = keyof (typeof Permissions);
export const Roles = {"devops": undefined, "viewer": undefined, "admin": undefined };
Expand Down
2 changes: 0 additions & 2 deletions components/server/ee/src/workspace/gitpod-server-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1503,8 +1503,6 @@ export class GitpodServerEEImpl extends GitpodServerImpl<GitpodClient, GitpodSer
const cloneUrlsInUse = new Set(projects.map(p => p.cloneUrl));
repositories.forEach(r => { r.inUse = cloneUrlsInUse.has(r.cloneUrl) });

await this.ensureTeamsEnabled();

return repositories;
}

Expand Down
12 changes: 0 additions & 12 deletions components/server/src/workspace/gitpod-server-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1442,8 +1442,6 @@ export class GitpodServerImpl<Client extends GitpodClient, Server extends Gitpod
await this.teamDB.addMemberToTeam(user.id, invite.teamId);
const team = await this.teamDB.findTeamById(invite.teamId);

await this.ensureTeamsEnabled();

this.analytics.track({
userId: user.id,
event: "team_joined",
Expand All @@ -1455,16 +1453,6 @@ export class GitpodServerImpl<Client extends GitpodClient, Server extends Gitpod
return team!;
}

protected async ensureTeamsEnabled() {
if (this.user && !this.user?.rolesOrPermissions?.includes('teams-and-projects')) {
this.user.rolesOrPermissions = [...(this.user.rolesOrPermissions || []), 'teams-and-projects'];
await this.userDB.updateUserPartial({
id: this.user.id,
rolesOrPermissions: this.user.rolesOrPermissions
})
}
}

public async setTeamMemberRole(teamId: string, userId: string, role: TeamMemberRole): Promise<void> {
this.checkAndBlockUser("setTeamMemberRole");
await this.guardTeamOperation(teamId, "update");
Expand Down