5
5
*/
6
6
7
7
import React , { Suspense , useContext , useEffect , useState } from "react" ;
8
- import { Project , StartPrebuildResult , WorkspaceInstance } from "@gitpod/gitpod-protocol" ;
9
- import PrebuildLogs from "../components/PrebuildLogs" ;
8
+ import { Project } from "@gitpod/gitpod-protocol" ;
10
9
import TabMenuItem from "../components/TabMenuItem" ;
11
10
import { getGitpodService } from "../service/service" ;
12
11
import Spinner from "../icons/Spinner.svg" ;
13
12
import NoAccess from "../icons/NoAccess.svg" ;
14
- import PrebuildLogsEmpty from "../images/prebuild-logs-empty.svg" ;
15
- import PrebuildLogsEmptyDark from "../images/prebuild-logs-empty-dark.svg" ;
16
- import { ThemeContext } from "../theme-context" ;
17
- import { PrebuildInstanceStatus } from "./Prebuilds" ;
18
13
import { ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error" ;
19
14
import { openAuthorizeWindow } from "../provider-utils" ;
20
15
import { ProjectSettingsPage } from "./ProjectSettings" ;
@@ -30,15 +25,6 @@ const TASKS = {
30
25
echo 'TODO: start app'` ,
31
26
} ;
32
27
33
- // const IMAGES = {
34
- // Default: 'gitpod/workspace-full',
35
- // '.NET': 'gitpod/workspace-dotnet',
36
- // MongoDB: 'gitpod/workspace-mongodb',
37
- // MySQL: 'gitpod/workspace-mysql',
38
- // PostgreSQL: 'gitpod/workspace-postgres',
39
- // 'Virtual Desktop (VNC)': 'gitpod/workspace-full-vnc',
40
- // }
41
-
42
28
export default function ( ) {
43
29
const { project } = useContext ( ProjectContext ) ;
44
30
const [ gitpodYml , setGitpodYml ] = useState < string > ( "" ) ;
@@ -47,11 +33,6 @@ export default function () {
47
33
const [ selectedEditor , setSelectedEditor ] = useState < ".gitpod.yml" | ".gitpod.Dockerfile" > ( ".gitpod.yml" ) ;
48
34
const [ isEditorDisabled , setIsEditorDisabled ] = useState < boolean > ( true ) ;
49
35
const [ isDetecting , setIsDetecting ] = useState < boolean > ( true ) ;
50
- const [ prebuildWasTriggered , setPrebuildWasTriggered ] = useState < boolean > ( false ) ;
51
- const [ prebuildWasCancelled , setPrebuildWasCancelled ] = useState < boolean > ( false ) ;
52
- const [ startPrebuildResult , setStartPrebuildResult ] = useState < StartPrebuildResult | undefined > ( ) ;
53
- const [ prebuildInstance , setPrebuildInstance ] = useState < WorkspaceInstance | undefined > ( ) ;
54
- const { isDark } = useContext ( ThemeContext ) ;
55
36
56
37
const [ showAuthBanner , setShowAuthBanner ] = useState < { host : string ; scope ?: string } | undefined > ( undefined ) ;
57
38
const [ buttonNewWorkspaceEnabled , setButtonNewWorkspaceEnabled ] = useState < boolean > ( true ) ;
@@ -108,7 +89,7 @@ export default function () {
108
89
< EditorMessage
109
90
type = "warning"
110
91
heading = "Configuration already exists in git."
111
- message = "Run a prebuild or open a new workspace to edit project configuration."
92
+ message = "Oopen a new workspace to edit project configuration."
112
93
/> ,
113
94
) ;
114
95
setGitpodYml ( repoConfigString ) ;
@@ -128,7 +109,7 @@ export default function () {
128
109
< EditorMessage
129
110
type = "success"
130
111
heading = "Project type detected."
131
- message = "You can edit project configuration below before running a prebuild "
112
+ message = "You can edit project configuration below before starting a workspace. "
132
113
/> ,
133
114
) ;
134
115
setGitpodYml ( guessedConfigString ) ;
@@ -138,7 +119,7 @@ export default function () {
138
119
< EditorMessage
139
120
type = "warning"
140
121
heading = "Project type could not be detected."
141
- message = "You can edit project configuration below before running a prebuild ."
122
+ message = "You can edit project configuration below before starting a workspace ."
142
123
/> ,
143
124
) ;
144
125
setGitpodYml ( TASKS . Other ) ;
@@ -176,60 +157,6 @@ export default function () {
176
157
} ) ;
177
158
} ;
178
159
179
- const buildProject = async ( ) => {
180
- if ( ! project ) {
181
- return ;
182
- }
183
- setEditorMessage ( null ) ;
184
- if ( ! ! startPrebuildResult ) {
185
- setStartPrebuildResult ( undefined ) ;
186
- }
187
- if ( ! ! prebuildInstance ) {
188
- setPrebuildInstance ( undefined ) ;
189
- }
190
- try {
191
- setPrebuildWasTriggered ( true ) ;
192
- if ( ! isEditorDisabled ) {
193
- await getGitpodService ( ) . server . setProjectConfiguration ( project . id , gitpodYml ) ;
194
- }
195
- const result = await getGitpodService ( ) . server . triggerPrebuild ( project . id , null ) ;
196
- setStartPrebuildResult ( result ) ;
197
- } catch ( error ) {
198
- setPrebuildWasTriggered ( false ) ;
199
- setEditorMessage (
200
- < EditorMessage
201
- type = "warning"
202
- heading = "Could not run prebuild."
203
- message = { String ( error ) . replace ( / E r r o r : R e q u e s t \w + f a i l e d w i t h m e s s a g e : / , "" ) }
204
- /> ,
205
- ) ;
206
- }
207
- } ;
208
-
209
- const cancelPrebuild = async ( ) => {
210
- if ( ! project || ! startPrebuildResult ) {
211
- return ;
212
- }
213
- setPrebuildWasCancelled ( true ) ;
214
- try {
215
- await getGitpodService ( ) . server . cancelPrebuild ( project . id , startPrebuildResult . prebuildId ) ;
216
- } catch ( error ) {
217
- setEditorMessage (
218
- < EditorMessage
219
- type = "warning"
220
- heading = "Could not cancel prebuild."
221
- message = { String ( error ) . replace ( / E r r o r : R e q u e s t \w + f a i l e d w i t h m e s s a g e : / , "" ) }
222
- /> ,
223
- ) ;
224
- } finally {
225
- setPrebuildWasCancelled ( false ) ;
226
- }
227
- } ;
228
-
229
- const onInstanceUpdate = ( instance : WorkspaceInstance ) => {
230
- setPrebuildInstance ( instance ) ;
231
- } ;
232
-
233
160
useEffect ( ( ) => {
234
161
document . title = "Configure Project — Gitpod" ;
235
162
} , [ ] ) ;
@@ -244,25 +171,15 @@ export default function () {
244
171
window . location . href = url . toString ( ) ;
245
172
} ;
246
173
247
- if (
248
- prebuildInstance ?. status . phase === "stopped" &&
249
- ! prebuildInstance ?. status . conditions . failed &&
250
- ! prebuildInstance ?. status . conditions . headlessTaskFailed
251
- ) {
252
- redirectToNewWorkspace ( ) ;
253
- return ;
254
- }
255
- if ( ! prebuildWasTriggered ) {
256
- await buildProject ( ) ;
257
- }
258
174
redirectToNewWorkspace ( ) ;
175
+ return ;
259
176
} ;
260
177
261
178
return (
262
179
< ProjectSettingsPage project = { project } >
263
180
< div className = "grid xl:grid-cols-2 grid-cols-1 gap-4" >
264
- < div className = "flex-1 h-96 rounded-xl overflow-hidden relative flex flex-col" >
265
- < div className = "flex bg-gray-50 dark:bg-gray-800 border-b border- gray-200 dark:border-gray-600 px-6 pt-3" >
181
+ < div className = "flex-1 h-96 overflow-hidden relative flex flex-col" >
182
+ < div className = "flex bg-gray-50 dark:bg-gray-800 border-gray-200 dark:border-gray-600 px-6 pt-3" >
266
183
< TabMenuItem
267
184
name = ".gitpod.yml"
268
185
selected = { selectedEditor === ".gitpod.yml" }
@@ -338,56 +255,10 @@ export default function () {
338
255
</ div >
339
256
) }
340
257
</ div >
341
- < div className = "flex-1 h-96 rounded-xl overflow-hidden bg-gray-100 dark:bg-gray-700 flex flex-col" >
342
- < div className = "flex-grow flex" >
343
- { startPrebuildResult ? (
344
- < PrebuildLogs workspaceId = { startPrebuildResult . wsid } onInstanceUpdate = { onInstanceUpdate } />
345
- ) : (
346
- ! prebuildWasTriggered && (
347
- < div className = "flex-grow flex flex-col items-center justify-center" >
348
- < img
349
- alt = ""
350
- className = "w-14"
351
- role = "presentation"
352
- src = { isDark ? PrebuildLogsEmptyDark : PrebuildLogsEmpty }
353
- />
354
- < h3 className = "text-center text-lg text-gray-500 dark:text-gray-50 mt-4" >
355
- No Recent Prebuild
356
- </ h3 >
357
- < p className = "text-center text-base text-gray-500 dark:text-gray-400 mt-2 w-64" >
358
- Edit the project configuration on the left to get started.{ " " }
359
- < a className = "gp-link" href = "https://www.gitpod.io/docs/config-gitpod-file/" >
360
- Learn more
361
- </ a >
362
- </ p >
363
- </ div >
364
- )
365
- ) }
366
- </ div >
367
- < 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" >
368
- { prebuildWasTriggered && < PrebuildInstanceStatus prebuildInstance = { prebuildInstance } /> }
369
- < div className = "flex-grow" />
370
- { prebuildWasTriggered && prebuildInstance ?. status . phase !== "stopped" ? (
371
- < button
372
- className = "danger flex items-center space-x-2"
373
- disabled = {
374
- prebuildWasCancelled ||
375
- ( prebuildInstance ?. status . phase !== "initializing" &&
376
- prebuildInstance ?. status . phase !== "running" )
377
- }
378
- onClick = { cancelPrebuild }
379
- >
380
- < span > Cancel Prebuild</ span >
381
- </ button >
382
- ) : (
383
- < button disabled = { isDetecting } className = "secondary" onClick = { buildProject } >
384
- Run Prebuild
385
- </ button >
386
- ) }
387
- < button disabled = { isDetecting && buttonNewWorkspaceEnabled } onClick = { onNewWorkspace } >
388
- New Workspace
389
- </ button >
390
- </ div >
258
+ < div className = "h-20 px-6 bg-gray-50 dark:bg-gray-800 border-gray-200 dark:border-gray-600 flex space-x-2" >
259
+ < button disabled = { isDetecting && buttonNewWorkspaceEnabled } onClick = { onNewWorkspace } >
260
+ New Workspace
261
+ </ button >
391
262
</ div >
392
263
</ div >
393
264
</ ProjectSettingsPage >
0 commit comments