From 8d850fa256dd57dd3972710512b060d3012c09b0 Mon Sep 17 00:00:00 2001 From: Oleksii Orel Date: Wed, 11 Sep 2019 21:04:09 +0300 Subject: [PATCH 1/2] Fix the editors list for UD Signed-off-by: Oleksii Orel --- .../api/workspace/workspace-data-manager.ts | 26 ++++++++++++++++--- .../src/components/widget/list/che-list.styl | 2 +- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/dashboard/src/components/api/workspace/workspace-data-manager.ts b/dashboard/src/components/api/workspace/workspace-data-manager.ts index 0acaa6ad545..1900a2f7db9 100644 --- a/dashboard/src/components/api/workspace/workspace-data-manager.ts +++ b/dashboard/src/components/api/workspace/workspace-data-manager.ts @@ -23,6 +23,10 @@ const PLUGIN_TYPE = 'chePlugin'; */ export class WorkspaceDataManager { + static get DEFAULT_EDITOR(): string { + return 'eclipse/che-theia/latest'; + } + /** * Returns the name of the pointed workspace. * @@ -161,7 +165,8 @@ export class WorkspaceDataManager { return workspace.config.attributes && workspace.config.attributes.plugins ? workspace.config.attributes.plugins.split(',') : []; } else if (workspace.devfile) { - workspace.devfile.components.forEach(component => { + const components = workspace.devfile.components || []; + components.forEach(component => { if (component.type === PLUGIN_TYPE) { plugins.push(component.id); } @@ -182,6 +187,7 @@ export class WorkspaceDataManager { workspace.config.attributes.plugins = plugins.join(','); } else if (workspace.devfile) { let pluginComponents = []; + workspace.devfile.components = workspace.devfile.components || []; workspace.devfile.components.forEach(component => { if (component.type === PLUGIN_TYPE) { pluginComponents.push(component); @@ -200,6 +206,10 @@ export class WorkspaceDataManager { plugins.forEach((plugin: string) => { workspace.devfile.components.push({id: plugin, type: PLUGIN_TYPE}); }); + + if(workspace.devfile.components && workspace.devfile.components.length === 0) { + delete workspace.devfile.components; + } } } @@ -213,8 +223,9 @@ export class WorkspaceDataManager { return workspace.config.attributes && workspace.config.attributes.editor ? workspace.config.attributes.editor : null; } else if (workspace.devfile) { - let editor = null; - workspace.devfile.components.forEach(component => { + let editor = WorkspaceDataManager.DEFAULT_EDITOR; + const components = workspace.devfile.components || []; + components.forEach(component => { if (component.type === EDITOR_TYPE) { editor = component.id; } @@ -235,6 +246,7 @@ export class WorkspaceDataManager { workspace.config.attributes.editor = editor; } else if (workspace.devfile) { let editorComponents = []; + workspace.devfile.components = workspace.devfile.components || []; workspace.devfile.components.forEach(component => { if (component.type === EDITOR_TYPE) { editorComponents.push(component); @@ -245,7 +257,13 @@ export class WorkspaceDataManager { workspace.devfile.components.splice(workspace.devfile.components.indexOf(editor), 1); }); - workspace.devfile.components.push({id: editor, type: EDITOR_TYPE}); + if (editor) { + workspace.devfile.components.push({id: editor, type: EDITOR_TYPE}); + } + + if(workspace.devfile.components && workspace.devfile.components.length === 0) { + delete workspace.devfile.components; + } } } diff --git a/dashboard/src/components/widget/list/che-list.styl b/dashboard/src/components/widget/list/che-list.styl index 76f871d01ca..a0827ee42cb 100644 --- a/dashboard/src/components/widget/list/che-list.styl +++ b/dashboard/src/components/widget/list/che-list.styl @@ -20,7 +20,7 @@ che-box-shadow() & > div overflow-y auto - max-height 672px + max-height 624px .che-list-item height 47px .che-list-header From 3ee5a9f99b1ee57767efa5b8e6ffeb1941b934d3 Mon Sep 17 00:00:00 2001 From: Oleksii Orel Date: Thu, 12 Sep 2019 12:53:48 +0300 Subject: [PATCH 2/2] fixup! Fix the editors list for UD --- .../workspace-details/workspace-editors/workspace-editors.html | 3 ++- .../src/components/api/workspace/workspace-data-manager.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dashboard/src/app/workspaces/workspace-details/workspace-editors/workspace-editors.html b/dashboard/src/app/workspaces/workspace-details/workspace-editors/workspace-editors.html index d616d9b81c6..201625cf6ad 100644 --- a/dashboard/src/app/workspaces/workspace-details/workspace-editors/workspace-editors.html +++ b/dashboard/src/app/workspaces/workspace-details/workspace-editors/workspace-editors.html @@ -41,7 +41,8 @@
- diff --git a/dashboard/src/components/api/workspace/workspace-data-manager.ts b/dashboard/src/components/api/workspace/workspace-data-manager.ts index 1900a2f7db9..b95ef9108ba 100644 --- a/dashboard/src/components/api/workspace/workspace-data-manager.ts +++ b/dashboard/src/components/api/workspace/workspace-data-manager.ts @@ -167,7 +167,7 @@ export class WorkspaceDataManager { } else if (workspace.devfile) { const components = workspace.devfile.components || []; components.forEach(component => { - if (component.type === PLUGIN_TYPE) { + if (component.type === PLUGIN_TYPE && component.id) { plugins.push(component.id); } });