From 291ef68114a9ae5a2749b11cf660fda44a470c4f Mon Sep 17 00:00:00 2001 From: Ann Shumilova Date: Tue, 27 Sep 2016 14:06:31 +0300 Subject: [PATCH 1/2] CHE-2551: fix workspace learn more link Signed-off-by: Ann Shumilova --- .../src/app/workspaces/list-workspaces/list-workspaces.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dashboard/src/app/workspaces/list-workspaces/list-workspaces.html b/dashboard/src/app/workspaces/list-workspaces/list-workspaces.html index 359d928f89..f669e0acff 100644 --- a/dashboard/src/app/workspaces/list-workspaces/list-workspaces.html +++ b/dashboard/src/app/workspaces/list-workspaces/list-workspaces.html @@ -11,7 +11,7 @@ --> -A workspace is where your projects live and run. Create workspaces from stacks that define projects, runtimes, and commands. +A workspace is where your projects live and run. Create workspaces from stacks that define projects, runtimes, and commands. From f35e6220dc8cdf553d34ac4de24bef0a49347c6d Mon Sep 17 00:00:00 2001 From: Ann Shumilova Date: Tue, 27 Sep 2016 14:07:53 +0300 Subject: [PATCH 2/2] CHE-2477: respect the content of provided workspace config Signed-off-by: Ann Shumilova --- .../create-workspace.controller.ts | 50 +++++++++++++++++-- .../create-workspace/create-workspace.html | 8 +-- 2 files changed, 49 insertions(+), 9 deletions(-) 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 7bef3c94f1..df30099012 100644 --- a/dashboard/src/app/workspaces/create-workspace/create-workspace.controller.ts +++ b/dashboard/src/app/workspaces/create-workspace/create-workspace.controller.ts @@ -154,9 +154,9 @@ export class CreateWorkspaceController { this.submitWorkspace(source); } } else if (this.selectSourceOption === 'select-source-import') { - let workspaceConfig = this.importWorkspace.length > 0 ? angular.fromJson(this.importWorkspace) : {}; - workspaceConfig.name = this.workspaceName; - let creationPromise = this.cheAPI.getWorkspace().createWorkspaceFromConfig(null, workspaceConfig); + this.importWorkspaceConfig.name = this.workspaceName; + this.setEnvironment(this.importWorkspaceConfig); + let creationPromise = this.cheAPI.getWorkspace().createWorkspaceFromConfig(null, this.importWorkspaceConfig); this.redirectAfterSubmitWorkspace(creationPromise); } else { //check predefined recipe location @@ -171,6 +171,41 @@ export class CreateWorkspaceController { } } + /** + * Perform actions when content of workspace config is changed. + */ + onWorkspaceSourceChange() { + this.importWorkspaceConfig = null; + this.importWorkspaceMachines = null; + + if (this.importWorkspace && this.importWorkspace.length > 0) { + try { + this.importWorkspaceConfig = angular.fromJson(this.importWorkspace); + this.workspaceName = this.importWorkspaceConfig.name; + let environment = this.importWorkspaceConfig.environments[this.importWorkspaceConfig.defaultEnv]; + let recipeType = environment.recipe.type; + let environmentManager = this.cheEnvironmentRegistry.getEnvironmentManager(recipeType); + this.importWorkspaceMachines = environmentManager.getMachines(environment); + } catch (error) { + + } + } + } + + /** + * Returns the list of environments to be displayed. + * + * @returns {*} list of environments + */ + getEnvironments() { + if (this.selectSourceOption === 'select-source-import') { + return (this.importWorkspaceConfig && this.importWorkspaceConfig.environments) ? this.importWorkspaceConfig.environments : []; + } else if (this.stack) { + return this.stack.workspaceConfig.environments; + } + return []; + } + /** * Detects machine source from pointed stack. * @@ -242,9 +277,14 @@ export class CreateWorkspaceController { this.$rootScope.$broadcast('recent-workspace:set', workspaceId); } - getStackMachines(environment) { + getMachines(environment) { let recipeType = environment.recipe.type; let environmentManager = this.cheEnvironmentRegistry.getEnvironmentManager(recipeType); + + if (this.selectSourceOption === 'select-source-import') { + return this.importWorkspaceMachines; + } + if (!this.stackMachines[this.stack.id]) { this.stackMachines[this.stack.id] = environmentManager.getMachines(environment); } @@ -269,6 +309,6 @@ export class CreateWorkspaceController { let recipeType = environment.recipe.type; let environmentManager = this.cheEnvironmentRegistry.getEnvironmentManager(recipeType); - workspace.environments[workspace.defaultEnv] = environmentManager.getEnvironment(environment, this.getStackMachines(environment)); + workspace.environments[workspace.defaultEnv] = environmentManager.getEnvironment(environment, this.getMachines(environment)); } } diff --git a/dashboard/src/app/workspaces/create-workspace/create-workspace.html b/dashboard/src/app/workspaces/create-workspace/create-workspace.html index 13234be1d4..8345fdcdc1 100644 --- a/dashboard/src/app/workspaces/create-workspace/create-workspace.html +++ b/dashboard/src/app/workspaces/create-workspace/create-workspace.html @@ -27,7 +27,7 @@ + ng-model="createWorkspaceCtrl.importWorkspace" ng-change="createWorkspaceCtrl.onWorkspaceSourceChange()">
- + ENVIRONMENT: {{environmentKey}}
-
+
MACHINE: {{machine.name}}