Skip to content

Commit

Permalink
Enable devfile registry by default
Browse files Browse the repository at this point in the history
Signed-off-by: Anna Shumilova <ashumilo@redhat.com>

Fix the run workspace button

Signed-off-by: Anna Shumilova <ashumilo@redhat.com>

Fix adding projects to devfile

Signed-off-by: Anna Shumilova <ashumilo@redhat.com>

Fix adding projects to devfile

Signed-off-by: Anna Shumilova <ashumilo@redhat.com>
  • Loading branch information
ashumilova committed Jun 13, 2019
1 parent 4b23324 commit f7e7d53
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 12 deletions.
2 changes: 1 addition & 1 deletion dashboard/src/app/ide/ide.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class IdeSvc {
}

startWorkspace(data: any): ng.IPromise<any> {
let startWorkspacePromise = this.cheAPI.getWorkspace().startWorkspace(data.id, data.config.defaultEnv);
let startWorkspacePromise = this.cheAPI.getWorkspace().startWorkspace(data.id, data.config ? data.config.defaultEnv: null);
return startWorkspacePromise;
}

Expand Down
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 @@ -50,13 +50,13 @@ export class WorkspaceStatusController {
return;
}
const workspace = this.cheWorkspace.getWorkspaceById(this.workspaceId);
if (!workspace || !workspace.config) {
if (!workspace) {
return;
}

const status = this.getWorkspaceStatus();
const isRunButton = status !== WorkspaceStatus.RUNNING && status !== WorkspaceStatus.STOPPING && status !== WorkspaceStatus.STARTING;
const environment = workspace.config.defaultEnv;
const environment = workspace.config ? workspace.config.defaultEnv : null;

if (isRunButton) {
this.updateRecentWorkspace(this.workspaceId);
Expand All @@ -65,7 +65,6 @@ export class WorkspaceStatusController {
this.cheWorkspace.fetchStatusChange(this.workspaceId, 'ERROR').then((data: any) => {
this.cheNotification.showError(data.error);
});

const promise = isRunButton ? this.cheWorkspace.startWorkspace(this.workspaceId, environment) : this.cheWorkspace.stopWorkspace(this.workspaceId);
promise.catch((error: any) => {
this.cheNotification.showError(`${isRunButton ? 'Run' : 'Stop'} workspace error.`, error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,13 @@ export class WorkspaceDetailsProjectsCtrl {
if (!projectTemplate.type && projectTemplate.projectType) {
projectTemplate.type = projectTemplate.projectType;
}

this.workspaceDetailsProjectsService.addProjectTemplate(projectTemplate);
this.workspaceDataManager.addProject(this.workspaceDetails, projectTemplate);
});
this.createWorkspaceSvc.addProjectCommands(this.workspaceDetails, projectTemplates);
//TODO waits for fix https://github.com/eclipse/che/issues/13514 to enable for devfile
if (this.workspaceDetails.config) {
this.createWorkspaceSvc.addProjectCommands(this.workspaceDetails, projectTemplates);
}
this.projectsOnChange();
}

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
2 changes: 1 addition & 1 deletion deploy/openshift/deploy_che.sh
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export DEVFILE_REGISTRY_IMAGE=${DEVFILE_REGISTRY_IMAGE:-${DEFAULT_DEVFILE_REGIST
DEFAULT_DEVFILE_REGISTRY_IMAGE_PULL_POLICY="Always"
export DEVFILE_REGISTRY_IMAGE_PULL_POLICY=${DEVFILE_REGISTRY_IMAGE_PULL_POLICY:-${DEFAULT_DEVFILE_REGISTRY_IMAGE_PULL_POLICY}}

DEFAULT_DEVFILE__REGISTRY__URL="NULL"
DEFAULT_DEVFILE__REGISTRY__URL="https://che-devfile-registry.openshift.io/"
export DEVFILE__REGISTRY__URL=${DEVFILE__REGISTRY__URL:-${DEFAULT_DEVFILE__REGISTRY__URL}}


Expand Down

0 comments on commit f7e7d53

Please sign in to comment.