Skip to content
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

[dashboard] Re-implement running workspace selector for new dashboard #3464

Merged
merged 4 commits into from
Mar 16, 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
2 changes: 1 addition & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
image: eu.gcr.io/gitpod-core-dev/dev/dev-environment:aledbf-grpc.46
image: eu.gcr.io/gitpod-core-dev/dev/dev-environment:at-dev-env.5
workspaceLocation: gitpod/gitpod-ws.theia-workspace
checkoutLocation: gitpod
ports:
Expand Down
2 changes: 1 addition & 1 deletion .werft/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pod:
- name: MYSQL_TCP_PORT
value: 23306
- name: build
image: eu.gcr.io/gitpod-core-dev/dev/dev-environment:aledbf-grpc.46
image: eu.gcr.io/gitpod-core-dev/dev/dev-environment:at-dev-env.5
workingDir: /workspace
imagePullPolicy: Always
volumeMounts:
Expand Down
6 changes: 3 additions & 3 deletions components/dashboard/src/components/StartPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function ProgressBar(props: { phase: number, error: boolean }) {
let classes = 'h-2 w-10 mx-1 my-2 rounded-full';
if (i < props.phase) {
// Already passed this phase successfully
classes += ' bg-green-light';
classes += ' bg-green-400';
} else if (i > props.phase) {
// Haven't reached this phase yet
classes += ' bg-gray-200';
Expand All @@ -21,9 +21,9 @@ function ProgressBar(props: { phase: number, error: boolean }) {
classes += ' bg-red';
} else {
// This phase is currently running
classes += ' bg-green-light animate-pulse';
classes += ' bg-green-400 animate-pulse';
}
return <div className={classes}/>;
return <div key={'phase-'+i} className={classes}/>;
})}
</div>;
}
Expand Down
49 changes: 36 additions & 13 deletions components/dashboard/src/start/CreateWorkspace.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React, { Suspense } from "react";
import { CreateWorkspaceMode, GitpodService, WorkspaceCreationResult } from "@gitpod/gitpod-protocol";
import { ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error";
import Modal from "../components/Modal";
import { StartPage, StartPhase } from "../components/StartPage";
import StartWorkspace from "./StartWorkspace";
import React, { Suspense } from "react";

const WorkspaceLogs = React.lazy(() => import('./WorkspaceLogs'));

Expand Down Expand Up @@ -32,11 +33,11 @@ export class CreateWorkspace extends React.Component<CreateWorkspaceProps, Creat
this.createWorkspace();
}

async createWorkspace() {
async createWorkspace(mode = CreateWorkspaceMode.SelectIfRunning) {
try {
const result = await this.props.gitpodService.server.createWorkspace({
contextUrl: this.props.contextUrl,
mode: CreateWorkspaceMode.SelectIfRunning
mode
});
if (result.workspaceURL) {
window.location.href = result.workspaceURL;
Expand Down Expand Up @@ -80,8 +81,28 @@ export class CreateWorkspace extends React.Component<CreateWorkspaceProps, Creat
}

else if (result?.existingWorkspaces) {
// FIXME Force create
statusMessage = <div className="text-base text-gray-400">Existing workspaces:<ul>{result.existingWorkspaces.map(w => <li>→ <a className="text-blue" href={w.latestInstance?.ideUrl}>{w.workspace.id}</a></li>)}</ul></div>;
statusMessage = <Modal visible={true} closeable={false}>
jankeromnes marked this conversation as resolved.
Show resolved Hide resolved
<h3>Running Workspaces</h3>
<div className="border-t border-b border-gray-200 mt-2 -mx-6 px-6 py-2">
<p className="mt-1 mb-2 text-base">You already have running workspaces with the same context. You can open an existing one or open a new workspace.</p>
<>
{result?.existingWorkspaces?.map(w =>
<a href={w.latestInstance?.ideUrl} className="rounded-xl group hover:bg-gray-100 flex p-3 my-1">
<div className="w-full">
<p className="text-base text-black font-bold">{w.workspace.id}</p>
<p>{w.workspace.contextURL}</p>
</div>
<div className="flex">
<button className="px-3 py-1 my-auto opacity-0 group-hover:opacity-100 bg-green-600 hover:bg-green-700 border-green-800">Open</button>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: Tailwind black magic. 🔮

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, thanks! I even went down the rabbit hole of configurable variants in order to try and get invisible group-hover:visible to work, but it kept refusing to. Turns out group-hover works out of the box with opacity, so I switched to that. 🤷

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DOES. THE. JOB. Let's ship this! 🚢

</div>
</a>
)}
</>
</div>
<div className="flex justify-end mt-4">
<button className="bg-green-600 hover:bg-green-700 border-green-800" onClick={() => this.createWorkspace(CreateWorkspaceMode.Default)}>New Workspace</button>
</div>
</Modal>;
}

else if (result?.runningWorkspacePrebuild) {
Expand All @@ -95,14 +116,16 @@ export class CreateWorkspace extends React.Component<CreateWorkspaceProps, Creat
return <StartPage phase={phase} error={!!error}>
{statusMessage}
{logsView}
<button className="mt-8">Go back to dashboard</button>
<p className="mt-10 text-base text-gray-400 flex space-x-2">
<a href="https://www.gitpod.io/docs/">Docs</a>
<span>—</span>
<a href="https://status.gitpod.io/">Status</a>
<span>—</span>
<a href="https://www.gitpod.io/blog/">Blog</a>
</p>
{error && <>
<button className="mt-8">Go back to dashboard</button>
<p className="mt-10 text-base text-gray-400 flex space-x-2">
<a href="https://www.gitpod.io/docs/">Docs</a>
<span>—</span>
<a href="https://status.gitpod.io/">Status</a>
<span>—</span>
<a href="https://www.gitpod.io/blog/">Blog</a>
</p>
</>}
</StartPage>;
}

Expand Down
Loading