diff --git a/dashboard/src/app/navbar/recent-workspaces/recent-workspaces.controller.ts b/dashboard/src/app/navbar/recent-workspaces/recent-workspaces.controller.ts
index e657da9035d..857d006dfcb 100644
--- a/dashboard/src/app/navbar/recent-workspaces/recent-workspaces.controller.ts
+++ b/dashboard/src/app/navbar/recent-workspaces/recent-workspaces.controller.ts
@@ -226,7 +226,7 @@ export class NavbarRecentWorkspacesController {
*/
getWorkspaceName(workspaceId: string): string {
let workspace = this.cheWorkspace.getWorkspaceById(workspaceId);
- return workspace ? workspace.config.name : 'unknown';
+ return workspace ? this.cheWorkspace.getWorkspaceDataManager().getName(workspace) : 'unknown';
}
/**
@@ -256,7 +256,7 @@ export class NavbarRecentWorkspacesController {
* @returns {string}
*/
getIdeLink(workspace: che.IWorkspace): string {
- return '#/ide/' + (workspace ? (workspace.namespace + '/' + workspace.config.name) : 'unknown');
+ return '#/ide/' + (workspace ? (workspace.namespace + '/' + this.cheWorkspace.getWorkspaceDataManager().getName(workspace)) : 'unknown');
}
/**
@@ -265,7 +265,7 @@ export class NavbarRecentWorkspacesController {
* @returns {string}
*/
getWorkspaceDetailsLink(workspace: che.IWorkspace): string {
- return '#/workspace/' + workspace.namespace + '/' + workspace.config.name;
+ return '#/workspace/' + workspace.namespace + '/' + this.cheWorkspace.getWorkspaceDataManager().getName(workspace);
}
/**
diff --git a/dashboard/src/app/navbar/recent-workspaces/recent-workspaces.html b/dashboard/src/app/navbar/recent-workspaces/recent-workspaces.html
index f98e7d2e799..2cab6dde761 100644
--- a/dashboard/src/app/navbar/recent-workspaces/recent-workspaces.html
+++ b/dashboard/src/app/navbar/recent-workspaces/recent-workspaces.html
@@ -39,7 +39,7 @@
- {{workspace.config.name}}
+ {{navbarRecentWorkspacesController.getWorkspaceName(workspace.id)}}
diff --git a/dashboard/src/app/workspaces/create-workspace/create-workspace.controller.ts b/dashboard/src/app/workspaces/create-workspace/create-workspace.controller.ts
index 3ffb26e07ae..041f7f64f7e 100644
--- a/dashboard/src/app/workspaces/create-workspace/create-workspace.controller.ts
+++ b/dashboard/src/app/workspaces/create-workspace/create-workspace.controller.ts
@@ -358,7 +358,7 @@ export class CreateWorkspaceController {
}
let attributes = {stackId: this.stack.id};
- return this.createWorkspaceSvc.createWorkspace(this.workspaceConfig, attributes);
+ return this.createWorkspaceSvc.createWorkspaceFromConfig(this.workspaceConfig, attributes);
}
/**
diff --git a/dashboard/src/app/workspaces/create-workspace/create-workspace.service.ts b/dashboard/src/app/workspaces/create-workspace/create-workspace.service.ts
index 2627d45cb58..3673ff17f47 100644
--- a/dashboard/src/app/workspaces/create-workspace/create-workspace.service.ts
+++ b/dashboard/src/app/workspaces/create-workspace/create-workspace.service.ts
@@ -156,20 +156,13 @@ export class CreateWorkspaceSvc {
return defer.promise;
}
- /**
- * Creates a workspace from config.
- *
- * @param {che.IWorkspaceConfig} workspaceConfig the config of workspace which will be created
- * @param {any} attributes the attributes of the workspace
- * @returns {ng.IPromise}
- */
- createWorkspace(workspaceConfig: che.IWorkspaceConfig, attributes: any): ng.IPromise {
+ createWorkspaceFromConfig(workspaceConfig: che.IWorkspaceConfig, attributes: any): ng.IPromise {
const namespaceId = this.namespaceSelectorSvc.getNamespaceId(),
projectTemplates = this.projectSourceSelectorService.getProjectTemplates();
return this.checkEditingProgress().then(() => {
workspaceConfig.projects = projectTemplates;
- this.addProjectCommands(workspaceConfig, projectTemplates);
+ this.addProjectCommands({config: workspaceConfig}, projectTemplates);
return this.cheWorkspace.createWorkspaceFromConfig(namespaceId, workspaceConfig, attributes).then((workspace: che.IWorkspace) => {
return this.cheWorkspace.fetchWorkspaces().then(() => this.cheWorkspace.getWorkspaceById(workspace.id));
})
@@ -196,6 +189,39 @@ export class CreateWorkspaceSvc {
});
}
+ /*createWorkspaceFromDevfile(workspaceDevfile: che.IWorkspaceDevfile, attributes: any): ng.IPromise {
+ const namespaceId = this.namespaceSelectorSvc.getNamespaceId(),
+ projectTemplates = this.projectSourceSelectorService.getProjectTemplates();
+
+ return this.checkEditingProgress().then(() => {
+ workspaceDevfile.projects = projectTemplates;
+ 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));
+ })
+ .then((workspace: che.IWorkspace) => {
+ this.projectSourceSelectorService.clearTemplatesList();
+ const workspaces = this.cheWorkspace.getWorkspaces();
+ if (workspaces.findIndex((_workspace: che.IWorkspace) => {
+ return _workspace.id === workspace.id;
+ }) === -1) {
+ workspaces.push(workspace);
+ }
+ this.cheWorkspace.startUpdateWorkspaceStatus(workspace.id);
+
+ return workspace;
+ }, (error: any) => {
+ let errorMessage = 'Creation workspace failed.';
+ if (error && error.data && error.data.message) {
+ errorMessage = error.data.message;
+ }
+ this.cheNotification.showError(errorMessage);
+
+ return this.$q.reject(error);
+ });
+ });
+ }*/
+
/**
* Show confirmation dialog when project editing is not completed.
*
@@ -233,19 +259,17 @@ export class CreateWorkspaceSvc {
}
/**
- * Adds commands from the bunch of project templates to provided workspace config.
+ * Adds commands from the bunch of project templates to provided workspace.
*
- * @param {che.IWorkspaceConfig} workspaceConfig workspace config
+ * @param {che.IWorkspace} workspace
* @param {Array} projectTemplates the list of project templates
*/
- addProjectCommands(workspaceConfig: che.IWorkspaceConfig, projectTemplates: Array): void {
- workspaceConfig.commands = workspaceConfig.commands || [];
-
+ addProjectCommands(workspace: che.IWorkspace, projectTemplates: Array): void {
projectTemplates.forEach((template: che.IProjectTemplate) => {
let projectName = template.name;
template.commands.forEach((command: any) => {
command.name = projectName + ':' + command.name;
- workspaceConfig.commands.push(command);
+ this.cheWorkspace.getWorkspaceDataManager().addCommand(workspace, command);
});
});
}
diff --git a/dashboard/src/app/workspaces/list-workspaces/list-workspaces.controller.ts b/dashboard/src/app/workspaces/list-workspaces/list-workspaces.controller.ts
index 12de8bebe14..eadda87f134 100644
--- a/dashboard/src/app/workspaces/list-workspaces/list-workspaces.controller.ts
+++ b/dashboard/src/app/workspaces/list-workspaces/list-workspaces.controller.ts
@@ -164,7 +164,8 @@ export class ListWorkspacesCtrl {
return this.$q.when();
}
let message = error.data && error.data.message ? ' Reason: ' + error.data.message : '';
- this.cheNotification.showError('Failed to retrieve workspace ' + workspace.config.name + ' data.' + message) ;
+ let workspaceName = this.cheWorkspace.getWorkspaceDataManager().getName(workspace);
+ this.cheNotification.showError('Failed to retrieve workspace ' + workspaceName + ' data.' + message) ;
return this.$q.reject(error);
})
.then(() => {
@@ -249,7 +250,7 @@ export class ListWorkspacesCtrl {
if (!workspace) {
return;
}
- workspaceName = workspace.config.name;
+ workspaceName = this.cheWorkspace.getWorkspaceDataManager().getName(workspace);
let stoppedStatusPromise = this.cheWorkspace.fetchStatusChange(workspaceId, 'STOPPED');
// stop workspace if it's status is RUNNING
diff --git a/dashboard/src/app/workspaces/list-workspaces/workspace-item/workspace-item.controller.ts b/dashboard/src/app/workspaces/list-workspaces/workspace-item/workspace-item.controller.ts
index 57ae0c29395..fbb1cf568ed 100644
--- a/dashboard/src/app/workspaces/list-workspaces/workspace-item/workspace-item.controller.ts
+++ b/dashboard/src/app/workspaces/list-workspaces/workspace-item/workspace-item.controller.ts
@@ -29,6 +29,7 @@ export class WorkspaceItemCtrl {
workspacesService: WorkspacesService;
workspace: che.IWorkspace;
+ workspaceName: string;
/**
* Default constructor that is using resource
@@ -41,6 +42,7 @@ export class WorkspaceItemCtrl {
this.lodash = lodash;
this.cheWorkspace = cheWorkspace;
this.workspacesService = workspacesService;
+ this.workspaceName = this.cheWorkspace.getWorkspaceDataManager().getName(this.workspace);
}
/**
@@ -57,7 +59,7 @@ export class WorkspaceItemCtrl {
* @param tab {string}
*/
redirectToWorkspaceDetails(tab?: string): void {
- this.$location.path('/workspace/' + this.workspace.namespace + '/' + this.workspace.config.name).search({tab: tab ? tab : 'Overview'});
+ this.$location.path('/workspace/' + this.workspace.namespace + '/' + this.workspaceName).search({tab: tab ? tab : 'Overview'});
}
getDefaultEnvironment(workspace: che.IWorkspace): che.IWorkspaceEnvironment {
@@ -68,6 +70,10 @@ export class WorkspaceItemCtrl {
}
getMemoryLimit(workspace: che.IWorkspace): string {
+ if (!workspace.config && workspace.devfile) {
+ return '-';
+ }
+
let environment = this.getDefaultEnvironment(workspace);
if (environment) {
let limits = this.lodash.pluck(environment.machines, 'attributes.memoryLimitBytes');
diff --git a/dashboard/src/app/workspaces/list-workspaces/workspace-item/workspace-item.html b/dashboard/src/app/workspaces/list-workspaces/workspace-item/workspace-item.html
index bb1632c28bc..64a581cd77c 100644
--- a/dashboard/src/app/workspaces/list-workspaces/workspace-item/workspace-item.html
+++ b/dashboard/src/app/workspaces/list-workspaces/workspace-item/workspace-item.html
@@ -13,7 +13,7 @@
-->