@@ -14,6 +14,7 @@ type ICreateWorkspaceParams = {
1414 organizationId : string ;
1515 ignoreRunningWorkspaceOnSameCommit : true ;
1616 ignoreRunningPrebuild : true ;
17+ worksspaceClass : "g1-standard" | "g1-large" ;
1718 ideSetting : {
1819 defaultIde : string ;
1920 useLatestVersion : false ;
@@ -35,6 +36,7 @@ export class IWorkspace implements GitpodDataModel {
3536 private ownerId : string ;
3637 private projectId : string ;
3738 private ideURL : string ;
39+ private workspaceClass ?: "g1-standard" | "g1-large" ;
3840 private context : {
3941 contextURL : string ;
4042 git : {
@@ -49,6 +51,40 @@ export class IWorkspace implements GitpodDataModel {
4951 } ;
5052
5153 private repository : string ;
54+ private totalUntrackedFiles ?: number ;
55+ private untrackedFiles ?: string [ ] ;
56+ private recentFolders ?: string [ ] ;
57+
58+ private totalUncommittedFiles ?: number ;
59+ private UncommittedFiles ?: string [ ] ;
60+
61+ getUntrackedFiles ( ) {
62+ return this . untrackedFiles
63+ }
64+
65+ getUncommittedFiles ( ) {
66+ return this . UncommittedFiles
67+ }
68+
69+ getRecentFolders ( ) {
70+ return this . recentFolders ;
71+ }
72+
73+ getTotalUntrackedFiles ( ) {
74+ return this . totalUntrackedFiles
75+ }
76+
77+ getTotatUncommittedFiles ( ) {
78+ return this . totalUncommittedFiles
79+ }
80+
81+ getWorkspaceClass ( ) {
82+ return this . workspaceClass
83+ }
84+
85+ setWorkspaceClass ( workspaceClass : "g1-standard" | "g1-large" ) {
86+ this . workspaceClass = workspaceClass
87+ }
5288
5389 getIDEURL ( ) {
5490 return this . ideURL ;
@@ -125,28 +161,52 @@ export class IWorkspace implements GitpodDataModel {
125161 this . createdAt = workspace . status . instance . createdAt ;
126162 this . ideURL = workspace . status . instance ? workspace . status . instance . status . url : "https://gitpod.io" ;
127163 this . repository = workspace . context . git . repository . name ;
164+
165+ if ( workspace . status . instance . status . gitStatus ) {
166+ if ( workspace . status . instance . status . gitStatus . totalUntrackedFiles ) {
167+ this . totalUntrackedFiles = workspace . status . instance . status . gitStatus . totalUntrackedFiles ;
168+ this . untrackedFiles = workspace . status . instance . status . gitStatus . untrackedFiles ;
169+ }
170+
171+ if ( workspace . status . instance . status . gitStatus . uncommitedFiles ) {
172+ this . totalUncommittedFiles = workspace . status . instance . status . gitStatus . totalUncommitedFiles
173+ this . UncommittedFiles = workspace . status . instance . status . gitStatus . uncommitedFiles
174+ }
175+ }
176+
177+ if ( workspace . status . instance . status . recentFolders ) {
178+ this . recentFolders = workspace . status . instance . status . recentFolders as string [ ] ;
179+ }
128180 }
129181
130182 parse ( json : string ) : IWorkspace {
131183 const data = JSON . parse ( json ) ;
132- this . workspaceId = data . result . workspaceId ;
133- this . ownerId = data . result . ownerId ;
134- this . projectId = data . result . context . git . normalizedContextUrl . split ( "/" ) . slice ( - 2 ) [ 0 ] ;
184+ const workspace = data . result ;
185+ this . workspaceId = workspace . workspaceId ;
186+ this . ownerId = workspace . ownerId ;
187+ this . projectId = workspace . context . git . normalizedContextUrl . split ( "/" ) . slice ( - 2 ) [ 0 ] ;
135188 this . context = {
136- contextURL : data . result . context . contextUrl ,
189+ contextURL : workspace . context . contextUrl ,
137190 git : {
138- normalizedContextUrl : data . result . context . git . normalizedContextUrl ,
191+ normalizedContextUrl : workspace . context . git . normalizedContextUrl ,
139192 } ,
140193 } ;
141- this . repository = data . result . context . git . repository . name ;
142- this . instanceId = data . result . status . instance . instanceId ;
143- this . description = data . result . description ;
194+ this . repository = workspace . context . git . repository . name ;
195+ this . instanceId = workspace . status . instance . instanceId ;
196+ this . description = workspace . description ;
144197 this . status = {
145- phase : data . result . status . instance . status . phase ,
198+ phase : workspace . status . instance . status . phase ,
146199 } ;
147- this . ideURL = data . result . status . instance ? data . result . status . instance . status . url : "" ;
200+ this . ideURL = workspace . status . instance ? data . result . status . instance . status . url : "" ;
201+
202+ this . createdAt = workspace . status . instance . createdAt ;
203+
204+ if ( workspace . status . instance . status . gitStatus . totalUntrackedFiles ) {
205+ this . totalUntrackedFiles = workspace . status . instance . status . gitStatus . totalUntrackedFiles ;
206+ this . untrackedFiles = workspace . status . instance . status . gitStatus . untrackedFiles ;
207+ }
148208
149- this . createdAt = data . result . status . instance . createdAt ;
209+ this . recentFolders = workspace . status . instance . status . recentFolders ;
150210
151211 return this ;
152212 }
@@ -270,27 +330,35 @@ export class IWorkspace implements GitpodDataModel {
270330
271331 const json = ( await response . json ( ) ) as any ;
272332
273- json . result . map ( ( workspace : unknown ) => {
274- const space = new IWorkspace ( workspace , token ) ;
275- workspaceMap . set ( space . workspaceId , space ) ;
276- } ) ;
333+ if ( json . result ) {
334+ json . result . map ( ( workspace : unknown ) => {
335+ const space = new IWorkspace ( workspace , token ) ;
336+ workspaceMap . set ( space . workspaceId , space ) ;
337+ } ) ;
338+ }
277339 return workspaceMap ;
278340 } ;
279341
280- // public delete = async () => {
281- // const response = await fetch(workspaceURLs.deleteWorkspace, {
282- // method: "GET",
283- // headers: {
284- // "Content-Type": "application/json",
285- // Authorization: `Bearer ${this.token}`,
286- // },
287- // body: JSON.stringify({ workspaceId: this.workspaceId }),
288- // });
289- // const result = await response.json();
290- // if (response.status !== 200) {
291- // throw new Error(`Failed to delete workspace: ${result.message}`);
292- // }
293-
294- // this.dispose();
295- // };
342+ public delete = async ( ) => {
343+
344+ const workspace_id = this . workspaceId
345+ const response = await fetch ( workspaceURLs . deleteWorkspace , {
346+ method : "POST" ,
347+ headers : {
348+ "content-type" : "application/json" ,
349+ Authorization : `Bearer ${ this . token } ` ,
350+ } ,
351+ body : JSON . stringify ( { workspaceId : workspace_id } ) ,
352+ } ) ;
353+
354+ if ( response . status !== 200 ) {
355+ const error : IWorkspaceError = {
356+ name : "WorkspaceDeleteError" ,
357+ code : response . status ,
358+ message : "Error Occured in Deleting Workspace" ,
359+ } ;
360+ throw error ;
361+ }
362+ return workspace_id
363+ } ;
296364}
0 commit comments