Skip to content

Commit

Permalink
Fix the editors list for UD (#14515)
Browse files Browse the repository at this point in the history
* Fix the editors list for UD

Signed-off-by: Oleksii Orel <oorel@redhat.com>
  • Loading branch information
olexii4 authored Sep 12, 2019
1 parent 2431795 commit b2ba4cb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
<div flex layout="row" layout-align="start center">
<!-- isEnabled -->
<div flex="10">
<md-switch ng-model="editor.isEnabled"
<md-switch ng-disabled="editor.isEnabled"
ng-model="editor.isEnabled"
ng-change="workspaceEditorsController.updateEditor(editor)"
aria-label="editor"
plugin-switch="{{editor.displayName}}">
Expand Down
28 changes: 23 additions & 5 deletions dashboard/src/components/api/workspace/workspace-data-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -161,8 +165,9 @@ 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 => {
if (component.type === PLUGIN_TYPE) {
const components = workspace.devfile.components || [];
components.forEach(component => {
if (component.type === PLUGIN_TYPE && component.id) {
plugins.push(component.id);
}
});
Expand All @@ -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);
Expand All @@ -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;
}
}
}

Expand All @@ -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;
}
Expand All @@ -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);
Expand All @@ -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;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion dashboard/src/components/widget/list/che-list.styl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b2ba4cb

Please sign in to comment.