Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the editors list for UD #14515

Merged
merged 2 commits into from
Sep 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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