Skip to content

Commit

Permalink
Fix adding projects to devfile
Browse files Browse the repository at this point in the history
Signed-off-by: Anna Shumilova <ashumilo@redhat.com>
  • Loading branch information
ashumilova committed Jun 12, 2019
1 parent 00a7b0a commit 11b4fe5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ export class CreateWorkspaceController {
*/
createWorkspace(): ng.IPromise<che.IWorkspace> {
// update workspace name
this.selectedDevfile.name = this.workspaceName;
this.selectedDevfile.metadata.name = this.workspaceName;
return this.createWorkspaceSvc.createWorkspaceFromDevfile(this.selectedDevfile, null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,22 @@ export class CreateWorkspaceSvc {
const namespaceId = this.namespaceSelectorSvc.getNamespaceId(),
projectTemplates = this.projectSourceSelectorService.getProjectTemplates();

let projects = [];
projectTemplates.forEach((template: che.IProjectTemplate) => {
let project = {
name: template.displayName,
source: {
type: template.source.type,
location: template.source.location
}
};
projects.push(project);
});

return this.checkEditingProgress().then(() => {
workspaceDevfile.projects = projectTemplates;
this.addProjectCommands({devfile: workspaceDevfile}, projectTemplates);
workspaceDevfile.projects = projects;
//TODO waits for fix https://github.com/eclipse/che/issues/13514
//this.addProjectCommands({devfile: workspaceDevfile}, projectTemplates);
return this.cheWorkspace.createWorkspaceFromDevfile(namespaceId, workspaceDevfile, attributes).then((workspace: che.IWorkspace) => {
return this.cheWorkspace.fetchWorkspaces().then(() => this.cheWorkspace.getWorkspaceById(workspace.id));
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ export class WorkspaceDetailsProjectsCtrl {
if (!projectTemplate.type && projectTemplate.projectType) {
projectTemplate.type = projectTemplate.projectType;
}

this.workspaceDetailsProjectsService.addProjectTemplate(projectTemplate);
this.workspaceDataManager.addProject(this.workspaceDetails, projectTemplate);
});
Expand Down
11 changes: 9 additions & 2 deletions dashboard/src/components/api/workspace/workspace-data-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,17 @@ export class WorkspaceDataManager {
* @param workspace workspace
* @param project project to be added to pointed workspace
*/
addProject(workspace: che.IWorkspace, project: any): void {
addProject(workspace: che.IWorkspace, projectTemplate: che.IProjectTemplate): void {
if (workspace.config) {
workspace.config.projects.push(project);
workspace.config.projects.push(projectTemplate);
} else if (workspace.devfile) {
let project = {
name: projectTemplate.displayName,
source: {
type: projectTemplate.source.type,
location: projectTemplate.source.location
}
};
workspace.devfile.projects.push(project);
}
}
Expand Down

0 comments on commit 11b4fe5

Please sign in to comment.