Skip to content

Commit 3aee902

Browse files
committed
[projects] always enable New Workspace button on config page
1 parent a4a1719 commit 3aee902

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

components/dashboard/src/projects/ConfigureProject.tsx

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
import React, { Suspense, useContext, useEffect, useState } from "react";
8-
import { useLocation, useRouteMatch } from "react-router";
8+
import { useHistory, useLocation, useRouteMatch } from "react-router";
99
import { Project, StartPrebuildResult, WorkspaceInstance } from "@gitpod/gitpod-protocol";
1010
import PrebuildLogs from "../components/PrebuildLogs";
1111
import TabMenuItem from "../components/TabMenuItem";
@@ -43,8 +43,8 @@ const TASKS = {
4343
- init: pip install -r requirements.txt
4444
command: python main.py`,
4545
Other: `tasks:
46-
- init: # TODO: install dependencies, build project
47-
command: # TODO: start app`
46+
- init: echo 'TODO: build project'
47+
command: echo 'TODO: start app'`
4848
}
4949

5050
// const IMAGES = {
@@ -57,6 +57,7 @@ const TASKS = {
5757
// }
5858

5959
export default function () {
60+
const history = useHistory();
6061
const { teams } = useContext(TeamsContext);
6162
const location = useLocation();
6263
const team = getCurrentTeam(location, teams);
@@ -164,11 +165,10 @@ export default function () {
164165
});
165166
};
166167

167-
const buildProject = async (event: React.MouseEvent) => {
168+
const buildProject = async () => {
168169
if (!project) {
169170
return;
170171
}
171-
// (event.target as HTMLButtonElement).disabled = true;
172172
setEditorMessage(null);
173173
if (!!startPrebuildResult) {
174174
setStartPrebuildResult(undefined);
@@ -209,6 +209,17 @@ export default function () {
209209

210210
useEffect(() => { document.title = 'Configure Project — Gitpod' }, []);
211211

212+
const onNewWorkspace = async () => {
213+
if (prebuildInstance?.status.phase === "stopped" && !prebuildInstance?.status.conditions.failed && !prebuildInstance?.status.conditions.headlessTaskFailed) {
214+
history.push(`/#${project?.cloneUrl}`);
215+
return;
216+
}
217+
if (!prebuildWasTriggered) {
218+
await buildProject();
219+
}
220+
history.push(`/#${project?.cloneUrl}`);
221+
}
222+
212223
return <>
213224
<Header title="Configuration" subtitle="View and edit project configuration." />
214225
<div className="lg:px-28 px-10 mt-8 flex space-x-4">
@@ -257,9 +268,7 @@ export default function () {
257268
<div className="h-20 px-6 bg-gray-50 dark:bg-gray-800 border-t border-gray-200 dark:border-gray-600 flex space-x-2">
258269
{prebuildWasTriggered && <PrebuildInstanceStatus prebuildInstance={prebuildInstance} />}
259270
<div className="flex-grow" />
260-
{((!isDetecting && isEditorDisabled) || (prebuildInstance?.status.phase === "stopped" && !prebuildInstance?.status.conditions.failed && !prebuildInstance?.status.conditions.headlessTaskFailed))
261-
? <a className="my-auto" href={`/#${project?.cloneUrl}`}><button className="secondary">New Workspace</button></a>
262-
: <button disabled={true} className="secondary">New Workspace</button>}
271+
<button disabled={isDetecting} className="secondary" onClick={onNewWorkspace}>New Workspace</button>
263272
{(prebuildWasTriggered && prebuildInstance?.status.phase !== "stopped")
264273
? <button className="danger flex items-center space-x-2" disabled={prebuildWasCancelled || (prebuildInstance?.status.phase !== "initializing" && prebuildInstance?.status.phase !== "running")} onClick={cancelPrebuild}>
265274
<span>Cancel Prebuild</span>

0 commit comments

Comments
 (0)