diff --git a/components/dashboard/src/App.tsx b/components/dashboard/src/App.tsx index 732c856e4f9496..68c9f01c6db330 100644 --- a/components/dashboard/src/App.tsx +++ b/components/dashboard/src/App.tsx @@ -277,7 +277,7 @@ function App() { - + @@ -307,9 +307,6 @@ function App() { if (resourceOrPrebuild === "configure") { return ; } - if (resourceOrPrebuild === "workspaces") { - return ; - } if (resourceOrPrebuild === "prebuilds") { return ; } @@ -346,9 +343,6 @@ function App() { if (resourceOrPrebuild === "settings") { return ; } - if (resourceOrPrebuild === "workspaces") { - return ; - } if (resourceOrPrebuild === "prebuilds") { return ; } diff --git a/components/dashboard/src/Menu.tsx b/components/dashboard/src/Menu.tsx index 0f0ad18379a641..f13773e1125396 100644 --- a/components/dashboard/src/Menu.tsx +++ b/components/dashboard/src/Menu.tsx @@ -97,10 +97,6 @@ export default function Menu() { title: 'Branches', link: `${teamOrUserSlug}/${projectSlug}`, }, - { - title: 'Workspaces', - link: `${teamOrUserSlug}/${projectSlug}/workspaces`, - }, { title: 'Prebuilds', link: `${teamOrUserSlug}/${projectSlug}/prebuilds`, @@ -120,11 +116,7 @@ export default function Menu() { { title: 'Projects', link: `/t/${team.slug}/projects`, - }, - { - title: 'Workspaces', - link: `/t/${team.slug}/workspaces`, - alternatives: [`/t/${team.slug}`] + alternatives: ([] as string[]) }, { title: 'Members', @@ -143,15 +135,15 @@ export default function Menu() { } // User menu return [ - { - title: 'Projects', - link: '/projects' - }, { title: 'Workspaces', link: '/workspaces', alternatives: ['/'] }, + { + title: 'Projects', + link: '/projects' + }, { title: 'Settings', link: '/settings', @@ -240,18 +232,11 @@ export default function Menu() { ) } - const gitpodIconUrl = () => { - if (team) { - return `/t/${team.slug}`; - } - return "/" - } - return <>
- + Gitpod's logo {!isMinimalUI &&
diff --git a/components/dashboard/src/workspaces/Workspaces.tsx b/components/dashboard/src/workspaces/Workspaces.tsx index fc059cf727168e..0b8236893257fb 100644 --- a/components/dashboard/src/workspaces/Workspaces.tsx +++ b/components/dashboard/src/workspaces/Workspaces.tsx @@ -5,7 +5,7 @@ */ import { useContext, useEffect, useState } from "react"; -import { Project, Team, WhitelistedRepository, Workspace, WorkspaceInfo } from "@gitpod/gitpod-protocol"; +import { WhitelistedRepository, Workspace, WorkspaceInfo } from "@gitpod/gitpod-protocol"; import Header from "../components/Header"; import DropDown from "../components/DropDown"; import { WorkspaceModel } from "./workspace-model"; @@ -15,8 +15,6 @@ import { StartWorkspaceModal, WsStartEntry } from "./StartWorkspaceModal"; import { ItemsList } from "../components/ItemsList"; import { getCurrentTeam, TeamsContext } from "../teams/teams-context"; import { useLocation, useRouteMatch } from "react-router"; -import { toRemoteURL } from "../projects/render-utils"; -import { Link, useHistory } from "react-router-dom"; export interface WorkspacesProps { } @@ -29,33 +27,16 @@ export interface WorkspacesState { export default function () { const location = useLocation(); - const history = useHistory(); const { teams } = useContext(TeamsContext); const team = getCurrentTeam(location, teams); const match = useRouteMatch<{ team: string, resource: string }>("/(t/)?:team/:resource"); const projectSlug = match?.params?.resource !== 'workspaces' ? match?.params?.resource : undefined; - const [projects, setProjects] = useState([]); const [activeWorkspaces, setActiveWorkspaces] = useState([]); const [inactiveWorkspaces, setInactiveWorkspaces] = useState([]); const [repos, setRepos] = useState([]); const [isTemplateModelOpen, setIsTemplateModelOpen] = useState(false); const [workspaceModel, setWorkspaceModel] = useState(); - const [teamsProjects, setTeamsProjects] = useState([]); - const [teamsWorkspaceModel, setTeamsWorkspaceModel] = useState(); - const [teamsActiveWorkspaces, setTeamsActiveWorkspaces] = useState([]); - - const newProjectUrl = !!team ? `/new?team=${team.slug}` : '/new?user=1'; - const onNewProject = () => { - history.push(newProjectUrl); - } - - const fetchTeamsProjects = async () => { - const projectsPerTeam = await Promise.all((teams || []).map(t => getGitpodService().server.getTeamProjects(t.id))); - const allTeamsProjects = projectsPerTeam.flat(1); - setTeamsProjects(allTeamsProjects); - return allTeamsProjects; - } useEffect(() => { // only show example repos on the global user context @@ -63,30 +44,7 @@ export default function () { getGitpodService().server.getFeaturedRepositories().then(setRepos); } (async () => { - const projects = (!!team - ? await getGitpodService().server.getTeamProjects(team.id) - : await getGitpodService().server.getUserProjects()); - - let project: Project | undefined = undefined; - if (projectSlug) { - project = projects.find(p => p.slug ? p.slug === projectSlug : p.name === projectSlug); - if (project) { - setProjects([project]); - } - } else { - setProjects(projects); - } - let workspaceModel; - if (!!project) { - workspaceModel = new WorkspaceModel(setActiveWorkspaces, setInactiveWorkspaces, Promise.resolve([project.id]), false); - } else if (!!team) { - workspaceModel = new WorkspaceModel(setActiveWorkspaces, setInactiveWorkspaces, getGitpodService().server.getTeamProjects(team?.id).then(projects => projects.map(p => p.id)), false); - } else { - workspaceModel = new WorkspaceModel(setActiveWorkspaces, setInactiveWorkspaces, getGitpodService().server.getUserProjects().then(projects => projects.map(p => p.id)), true); - // Don't await - const teamsProjectIdsPromise = fetchTeamsProjects().then(tp => tp.map(p => p.id)); - setTeamsWorkspaceModel(new WorkspaceModel(setTeamsActiveWorkspaces, () => {}, teamsProjectIdsPromise, false)); - } + const workspaceModel = new WorkspaceModel(setActiveWorkspaces, setInactiveWorkspaces); setWorkspaceModel(workspaceModel); })(); }, [teams, location]); @@ -95,16 +53,6 @@ export default function () { const hideStartWSModal = () => setIsTemplateModelOpen(false); const getRecentSuggestions: () => WsStartEntry[] = () => { - if (projectSlug || team) { - return projects.map(p => { - const remoteUrl = toRemoteURL(p.cloneUrl); - return { - title: (team ? team.name + '/' : '') + p.name, - description: remoteUrl, - startUrl: gitpodHostUrl.withContext(remoteUrl).toString() - }; - }); - } if (workspaceModel) { const all = workspaceModel.getAllFetchedWorkspaces(); if (all && all.size > 0) { @@ -169,9 +117,6 @@ export default function () {
- { - teamsWorkspaceModel?.initialized && - } { activeWorkspaces.map(e => { return getGitpodService().server.stopWorkspace(wsId)} /> @@ -193,23 +138,14 @@ export default function () { :
- {teamsWorkspaceModel?.initialized && }
- {!!team && projects.length === 0 - ?<> -

No Projects

-
This team doesn't have any projects, yet.
- - - - - :<> + <>

No Workspaces

Prefix any Git repository URL with {window.location.host}/# or create a new workspace for a recently used project. Learn more
- } +
@@ -229,25 +165,3 @@ export default function () { } -function ActiveTeamWorkspaces(props: { teams?: Team[], teamProjects: Project[], teamWorkspaces: WorkspaceInfo[] }) { - if (!props.teams || props.teamWorkspaces.length === 0) { - return <>; - } - return
-
- There are currently more active workspaces in the following teams: - { - props.teams - .map(t => { - const projects = props.teamProjects.filter(p => p.teamId === t.id); - const count = props.teamWorkspaces.filter(w => projects.some(p => p.id === w.workspace.projectId)).length; - if (count < 1) { - return undefined; - } - return {t.name}; - }) - .filter(t => !!t) - .map((t, i) => <>{i > 0 && , }{t}) - } -
; -} diff --git a/components/dashboard/src/workspaces/workspace-model.ts b/components/dashboard/src/workspaces/workspace-model.ts index 5a69d8e64fde10..3ed662a35e15b0 100644 --- a/components/dashboard/src/workspaces/workspace-model.ts +++ b/components/dashboard/src/workspaces/workspace-model.ts @@ -26,9 +26,7 @@ export class WorkspaceModel implements Disposable, Partial { constructor( protected setActiveWorkspaces: (ws: WorkspaceInfo[]) => void, - protected setInActiveWorkspaces: (ws: WorkspaceInfo[]) => void, - protected projectIds: Promise, - protected includeWithoutProject?: boolean) { + protected setInActiveWorkspaces: (ws: WorkspaceInfo[]) => void) { this.internalRefetch(); } @@ -38,14 +36,12 @@ export class WorkspaceModel implements Disposable, Partial { const [infos, pinned] = await Promise.all([ getGitpodService().server.getWorkspaces({ limit: this.internalLimit, - projectId: await this.projectIds, - includeWithoutProject: !!this.includeWithoutProject + includeWithoutProject: true }), getGitpodService().server.getWorkspaces({ limit: this.internalLimit, pinnedOnly: true, - projectId: await this.projectIds, - includeWithoutProject: !!this.includeWithoutProject + includeWithoutProject: true }) ]); @@ -63,14 +59,6 @@ export class WorkspaceModel implements Disposable, Partial { } } - protected async isIncluded(info: WorkspaceInfo): Promise { - if (info.workspace.projectId) { - return (await this.projectIds).some(id => id === info.workspace.projectId); - } else { - return !!this.includeWithoutProject; - } - } - dispose(): void { this.disposables.dispose(); } @@ -87,7 +75,7 @@ export class WorkspaceModel implements Disposable, Partial { try { this.currentlyFetching.add(instance.workspaceId); const info = await getGitpodService().server.getWorkspace(instance.workspaceId); - if (info.workspace.type === 'regular' && await this.isIncluded(info)) { + if (info.workspace.type === 'regular') { this.workspaces.set(instance.workspaceId, info); this.notifyWorkpaces(); }