Skip to content

Commit 3accc7f

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

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

components/dashboard/src/projects/ConfigureProject.tsx

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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 = {
@@ -164,11 +164,10 @@ export default function () {
164164
});
165165
};
166166

167-
const buildProject = async (event: React.MouseEvent) => {
167+
const buildProject = async () => {
168168
if (!project) {
169169
return;
170170
}
171-
// (event.target as HTMLButtonElement).disabled = true;
172171
setEditorMessage(null);
173172
if (!!startPrebuildResult) {
174173
setStartPrebuildResult(undefined);
@@ -209,6 +208,28 @@ export default function () {
209208

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

211+
const onNewWorkspace = async () => {
212+
const redirectToNewWorkspace = () => {
213+
// instead of `history.push` we want forcibly to redirect here in order to avoid a following redirect from `/` -> `/projects` (cf. App.tsx)
214+
const url = new URL(window.location.toString());
215+
url.pathname = "/";
216+
url.hash = project?.cloneUrl!;
217+
window.location.href = url.toString();
218+
}
219+
220+
if (prebuildInstance?.status.phase === "stopped" && !prebuildInstance?.status.conditions.failed && !prebuildInstance?.status.conditions.headlessTaskFailed) {
221+
redirectToNewWorkspace();
222+
return;
223+
}
224+
if (!prebuildWasTriggered && project) {
225+
// await buildProject();
226+
227+
await getGitpodService().server.setProjectConfiguration(project.id, gitpodYml);
228+
getGitpodService().server.triggerPrebuild(project.id, null);
229+
}
230+
redirectToNewWorkspace();
231+
}
232+
212233
return <>
213234
<Header title="Configuration" subtitle="View and edit project configuration." />
214235
<div className="app-container mt-8 flex space-x-4">
@@ -257,14 +278,12 @@ export default function () {
257278
<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">
258279
{prebuildWasTriggered && <PrebuildInstanceStatus prebuildInstance={prebuildInstance} />}
259280
<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>}
263281
{(prebuildWasTriggered && prebuildInstance?.status.phase !== "stopped")
264282
? <button className="danger flex items-center space-x-2" disabled={prebuildWasCancelled || (prebuildInstance?.status.phase !== "initializing" && prebuildInstance?.status.phase !== "running")} onClick={cancelPrebuild}>
265283
<span>Cancel Prebuild</span>
266284
</button>
267-
: <button disabled={isDetecting} onClick={buildProject}>Run Prebuild</button>}
285+
: <button disabled={isDetecting} className="secondary" onClick={buildProject}>Run Prebuild</button>}
286+
<button disabled={isDetecting} onClick={onNewWorkspace}>New Workspace</button>
268287
</div>
269288
</div>
270289
</div>

0 commit comments

Comments
 (0)