diff --git a/dashboard/src/app/stacks/stack-details/select-template/select-template.controller.ts b/dashboard/src/app/stacks/stack-details/select-template/select-template.controller.ts index 51ea9c2ca1..e0ea7fdf2d 100644 --- a/dashboard/src/app/stacks/stack-details/select-template/select-template.controller.ts +++ b/dashboard/src/app/stacks/stack-details/select-template/select-template.controller.ts @@ -28,7 +28,6 @@ export class SelectTemplateController { projectsOrderBy: string; private $mdDialog: ng.material.IDialogService; - private templates: Array; private callbackController: StackController; /** @@ -37,11 +36,6 @@ export class SelectTemplateController { constructor(cheAPI: CheAPI, $mdDialog: ng.material.IDialogService) { this.$mdDialog = $mdDialog; - this.templates = cheAPI.getProjectTemplate().getAllProjectTemplates(); - if (!this.templates.length) { - cheAPI.getProjectTemplate().fetchTemplates(); - } - this.projectsOrderBy = 'displayName'; this.selectedTemplates = []; } 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 780408937d..e36c851a60 100644 --- a/dashboard/src/app/workspaces/create-workspace/create-workspace.controller.ts +++ b/dashboard/src/app/workspaces/create-workspace/create-workspace.controller.ts @@ -16,7 +16,6 @@ import {EnvironmentManager} from '../../../components/api/environment/environmen import {IEnvironmentManagerMachine} from '../../../components/api/environment/environment-manager-machine'; import {CreateWorkspaceSvc} from './create-workspace.service'; import {NamespaceSelectorSvc} from './namespace-selector/namespace-selector.service'; -import {StackSelectorSvc} from './stack-selector/stack-selector.service'; import {RandomSvc} from '../../../components/utils/random.service'; import {CheNotification} from '../../../components/notification/che-notification.factory'; import { @@ -174,7 +173,7 @@ export class CreateWorkspaceController { this.$timeout(() => { this.hideLoader = true; }, 10); - this.selectedDevfile = devfile + this.selectedDevfile = devfile; } /** @@ -298,8 +297,9 @@ export class CreateWorkspaceController { */ createWorkspace(): ng.IPromise { // update workspace name - this.selectedDevfile.metadata.name = this.workspaceName; - return this.createWorkspaceSvc.createWorkspaceFromDevfile(this.selectedDevfile, null); + let devfileSource = angular.copy(this.selectedDevfile); + devfileSource.metadata.name = this.workspaceName; + return this.createWorkspaceSvc.createWorkspaceFromDevfile(devfileSource, null); } /** diff --git a/dashboard/src/app/workspaces/create-workspace/create-workspace.html b/dashboard/src/app/workspaces/create-workspace/create-workspace.html index a451d78285..1af842e838 100644 --- a/dashboard/src/app/workspaces/create-workspace/create-workspace.html +++ b/dashboard/src/app/workspaces/create-workspace/create-workspace.html @@ -56,12 +56,10 @@ - - + - { + createWorkspaceFromDevfile(sourceDevfile: che.IWorkspaceDevfile, attributes: any): ng.IPromise { const namespaceId = this.namespaceSelectorSvc.getNamespaceId(), projectTemplates = this.projectSourceSelectorService.getProjectTemplates(); let projects = []; + let noProjectsFromDevfile = true; projectTemplates.forEach((template: che.IProjectTemplate) => { let project = { - name: template.displayName, + name: template.name, source: { type: template.source.type, location: template.source.location } }; - projects.push(project); - }); + + sourceDevfile.projects.forEach((project) => { + if (project.name === template.name) { + noProjectsFromDevfile = false; + } + }); + projects.push(project); + }); + return this.checkEditingProgress().then(() => { - workspaceDevfile.projects = projects; - //TODO waits for fix https://github.com/eclipse/che/issues/13514 - //this.addProjectCommands({devfile: workspaceDevfile}, projectTemplates); - return this.cheWorkspace.createWorkspaceFromDevfile(namespaceId, workspaceDevfile, attributes).then((workspace: che.IWorkspace) => { + sourceDevfile.projects = projects; + + // If no projects defined in devfile were added - remove the commands from devfile as well: + if (noProjectsFromDevfile) { + sourceDevfile.commands = []; + } + + return this.cheWorkspace.createWorkspaceFromDevfile(namespaceId, sourceDevfile, attributes).then((workspace: che.IWorkspace) => { return this.cheWorkspace.fetchWorkspaces().then(() => this.cheWorkspace.getWorkspaceById(workspace.id)); }) .then((workspace: che.IWorkspace) => { diff --git a/dashboard/src/app/workspaces/create-workspace/project-source-selector/add-import-project/add-import-project.controller.ts b/dashboard/src/app/workspaces/create-workspace/project-source-selector/add-import-project/add-import-project.controller.ts index f66b227333..6d7c49588d 100644 --- a/dashboard/src/app/workspaces/create-workspace/project-source-selector/add-import-project/add-import-project.controller.ts +++ b/dashboard/src/app/workspaces/create-workspace/project-source-selector/add-import-project/add-import-project.controller.ts @@ -27,6 +27,7 @@ export class AddImportProjectController { * Project selector service. */ private addImportProjectService: AddImportProjectService; + /** * Project source selector service. */ @@ -46,6 +47,7 @@ export class AddImportProjectController { /* tslint:disable */ private isProjectNameUnique: (data: {name: string}) => boolean; /* tslint:enable */ + private devfile: che.IWorkspaceDevfile; /** * Callback provided by parent controller. */ @@ -60,7 +62,7 @@ export class AddImportProjectController { this.projectSource = ProjectSource; - this.activeProjectSource = ProjectSource.SAMPLES; + this.activeProjectSource = this.devfile ? ProjectSource.SAMPLES : ProjectSource.GIT; this.sourceChanged(); $scope.$on('$destroy', () => { diff --git a/dashboard/src/app/workspaces/create-workspace/project-source-selector/add-import-project/add-import-project.directive.ts b/dashboard/src/app/workspaces/create-workspace/project-source-selector/add-import-project/add-import-project.directive.ts index 2b915c8c19..4a737c4ce2 100644 --- a/dashboard/src/app/workspaces/create-workspace/project-source-selector/add-import-project/add-import-project.directive.ts +++ b/dashboard/src/app/workspaces/create-workspace/project-source-selector/add-import-project/add-import-project.directive.ts @@ -28,6 +28,7 @@ export class AddImportProject implements ng.IDirective { [propName: string]: string; } = { isProjectNameUnique: '&', - projectOnAdd: '&' + projectOnAdd: '&', + devfile: '=' }; } diff --git a/dashboard/src/app/workspaces/create-workspace/project-source-selector/add-import-project/add-import-project.html b/dashboard/src/app/workspaces/create-workspace/project-source-selector/add-import-project/add-import-project.html index a57177b625..32ad2bcdac 100644 --- a/dashboard/src/app/workspaces/create-workspace/project-source-selector/add-import-project/add-import-project.html +++ b/dashboard/src/app/workspaces/create-workspace/project-source-selector/add-import-project/add-import-project.html @@ -8,34 +8,24 @@ flex-order="2" flex-order-gt-md="1"> - -
- + ng-if="addImportProjectController.activeProjectSource === addImportProjectController.projectSource.SAMPLES && addImportProjectController.devfile" devfile="addImportProjectController.devfile"> -
diff --git a/dashboard/src/app/workspaces/create-workspace/project-source-selector/add-import-project/add-import-project.service.ts b/dashboard/src/app/workspaces/create-workspace/project-source-selector/add-import-project/add-import-project.service.ts index 5f8bbdae97..7934adb756 100644 --- a/dashboard/src/app/workspaces/create-workspace/project-source-selector/add-import-project/add-import-project.service.ts +++ b/dashboard/src/app/workspaces/create-workspace/project-source-selector/add-import-project/add-import-project.service.ts @@ -53,6 +53,7 @@ export class AddImportProjectService { * Project source. */ private activeProjectSource: ProjectSource; + /** * Instance of Observable. */ @@ -105,7 +106,7 @@ export class AddImportProjectService { * @return {che.IProjectTemplate} */ buildProjectTemplate(props: any): che.IProjectTemplate { - const blankProjectTemplate = this.templateSelectorSvc.getTemplateByName('blank-project'); + const blankProjectTemplate = {name: 'blank-project'}; return angular.merge({}, blankProjectTemplate, props); } @@ -201,5 +202,4 @@ export class AddImportProjectService { return null; } - } diff --git a/dashboard/src/app/workspaces/create-workspace/project-source-selector/add-import-project/template-selector/template-selector.controller.ts b/dashboard/src/app/workspaces/create-workspace/project-source-selector/add-import-project/template-selector/template-selector.controller.ts index 78bc2a51b9..64ff14a796 100644 --- a/dashboard/src/app/workspaces/create-workspace/project-source-selector/add-import-project/template-selector/template-selector.controller.ts +++ b/dashboard/src/app/workspaces/create-workspace/project-source-selector/add-import-project/template-selector/template-selector.controller.ts @@ -12,7 +12,6 @@ 'use strict'; import {TemplateSelectorSvc} from './template-selector.service'; -import {StackSelectorSvc} from '../../../stack-selector/stack-selector.service'; import {ProjectSource} from '../../project-source.enum'; import {AddImportProjectService} from '../add-import-project.service'; @@ -23,7 +22,7 @@ import {AddImportProjectService} from '../add-import-project.service'; */ export class TemplateSelectorController { - static $inject = ['$filter', '$scope', 'addImportProjectService', 'templateSelectorSvc', 'stackSelectorSvc', 'cheListHelperFactory']; + static $inject = ['$filter', '$scope', 'addImportProjectService', 'templateSelectorSvc', 'cheListHelperFactory']; /** * Filter service. @@ -33,10 +32,6 @@ export class TemplateSelectorController { * Template selector service. */ private templateSelectorSvc: TemplateSelectorSvc; - /** - * Stack selector service. - */ - private stackSelectorSvc: StackSelectorSvc; /** * Service for project adding and importing. */ @@ -45,10 +40,8 @@ export class TemplateSelectorController { * Helper for lists. */ private cheListHelper: che.widget.ICheListHelper; - /** - * The list of tags of selected stack. - */ - private stackTags: string[]; + + private devfile: che.IWorkspaceDevfile; /** * Sorted list of all templates. */ @@ -66,31 +59,32 @@ export class TemplateSelectorController { * Default constructor that is using resource injection */ constructor($filter: ng.IFilterService, $scope: ng.IScope, addImportProjectService: AddImportProjectService, templateSelectorSvc: TemplateSelectorSvc, - stackSelectorSvc: StackSelectorSvc, cheListHelperFactory: che.widget.ICheListHelperFactory) { + cheListHelperFactory: che.widget.ICheListHelperFactory) { this.$filter = $filter; this.templateSelectorSvc = templateSelectorSvc; - this.stackSelectorSvc = stackSelectorSvc; this.addImportProjectService = addImportProjectService; const helperId = 'template-selector'; this.cheListHelper = cheListHelperFactory.getHelper(helperId); + + $scope.$watch(() => { + return this.devfile; + }, () => { + if (!this.devfile) { + return; + } + let projects = this.devfile.projects ? this.devfile.projects : []; + this.allTemplates = this.$filter('orderBy')(projects, ['name']); + this.filterAndSortTemplates(); + }, true); + $scope.$on('$destroy', () => { cheListHelperFactory.removeHelper(helperId); }); - this.filteredTemplates = []; this.selectedTemplates = this.templateSelectorSvc.getTemplates(); - this.allTemplates = this.$filter('orderBy')(this.templateSelectorSvc.getAllTemplates(), ['projectType', 'displayName']); - this.filterAndSortTemplates(); - - const actionOnStackChanged = () => { - this.onStackChanged(); - }; - this.stackSelectorSvc.subscribe(actionOnStackChanged); - this.onStackChanged(); - const actionOnPublish = (source: ProjectSource) => { this.onAddImportProjectServicePublish(source); }; @@ -98,25 +92,9 @@ export class TemplateSelectorController { $scope.$on('$destroy', () => { this.addImportProjectService.unsubscribe(actionOnPublish); - this.stackSelectorSvc.unsubscribe(actionOnStackChanged); }); } - /** - * Callback which is called when stack is selected. - */ - onStackChanged(): void { - const stackId = this.stackSelectorSvc.getStackId(); - if (!stackId) { - return; - } - - const stack = this.stackSelectorSvc.getStackById(stackId); - this.stackTags = stack ? stack.tags : []; - - this.filterAndSortTemplates(); - } - /** * Callback which is called when project template is added to the list of ready-to-import projects. * Make samples not checked. @@ -138,17 +116,7 @@ export class TemplateSelectorController { * Filters templates by tags and sort them by project type and template name. */ filterAndSortTemplates(): void { - const stackTags = !this.stackTags ? [] : this.stackTags.map((tag: string) => tag.toLowerCase()); - - if (stackTags.length === 0) { - this.filteredTemplates = angular.copy(this.allTemplates); - } else { - this.filteredTemplates = this.allTemplates.filter((template: che.IProjectTemplate) => { - const templateTags = template.tags.map((tag: string) => tag.toLowerCase()); - return stackTags.some((tag: string) => templateTags.indexOf(tag) > -1); - }); - } - + this.filteredTemplates = angular.copy(this.allTemplates); this.cheListHelper.setList(this.filteredTemplates, 'name'); this.selectedTemplates.forEach((template: che.IProjectTemplate) => { this.cheListHelper.itemsSelectionStatus[template.name] = true; diff --git a/dashboard/src/app/workspaces/create-workspace/project-source-selector/add-import-project/template-selector/template-selector.directive.ts b/dashboard/src/app/workspaces/create-workspace/project-source-selector/add-import-project/template-selector/template-selector.directive.ts index 16d27b82e0..a6e6f1ec1f 100644 --- a/dashboard/src/app/workspaces/create-workspace/project-source-selector/add-import-project/template-selector/template-selector.directive.ts +++ b/dashboard/src/app/workspaces/create-workspace/project-source-selector/add-import-project/template-selector/template-selector.directive.ts @@ -35,7 +35,7 @@ export class TemplateSelector implements ng.IDirective { */ constructor() { this.scope = { - stackTags: '=' + devfile: '=' }; } diff --git a/dashboard/src/app/workspaces/create-workspace/project-source-selector/add-import-project/template-selector/template-selector.service.ts b/dashboard/src/app/workspaces/create-workspace/project-source-selector/add-import-project/template-selector/template-selector.service.ts index 4555b689d9..7640df1c8f 100644 --- a/dashboard/src/app/workspaces/create-workspace/project-source-selector/add-import-project/template-selector/template-selector.service.ts +++ b/dashboard/src/app/workspaces/create-workspace/project-source-selector/add-import-project/template-selector/template-selector.service.ts @@ -11,7 +11,6 @@ */ 'use strict'; -import {CheProjectTemplate} from '../../../../../../components/api/che-project-template.factory'; import {editingProgress, IEditingProgress} from '../../project-source-selector-editing-progress'; /** @@ -21,7 +20,7 @@ import {editingProgress, IEditingProgress} from '../../project-source-selector-e */ export class TemplateSelectorSvc implements IEditingProgress { - static $inject = ['$filter', '$q', 'cheProjectTemplate']; + static $inject = ['$filter', '$q']; /** * Filter service. @@ -31,10 +30,6 @@ export class TemplateSelectorSvc implements IEditingProgress { * Promises service. */ $q: ng.IQService; - /** - * Project template API interactions. - */ - cheProjectTemplate: CheProjectTemplate; /** * The list of selected templates. */ @@ -43,10 +38,9 @@ export class TemplateSelectorSvc implements IEditingProgress { /** * Default constructor that is using resource injection */ - constructor($filter: ng.IFilterService, $q: ng.IQService, cheProjectTemplate: CheProjectTemplate) { + constructor($filter: ng.IFilterService, $q: ng.IQService) { this.$filter = $filter; this.$q = $q; - this.cheProjectTemplate = cheProjectTemplate; this.templates = []; } @@ -68,45 +62,6 @@ export class TemplateSelectorSvc implements IEditingProgress { }; } - /** - * Fetches list of templates. - */ - getOrFetchTemplates(): ng.IPromise { - const defer = this.$q.defer(); - - const templates = this.cheProjectTemplate.getAllProjectTemplates(); - if (templates.length) { - defer.resolve(); - } else { - this.cheProjectTemplate.fetchTemplates().finally(() => { - defer.resolve(); - }); - } - - return defer.promise; - } - - /** - * Returns list of fetched project templates. - * - * @return {Array} - */ - getAllTemplates(): Array { - return this.cheProjectTemplate.getAllProjectTemplates(); - } - - /** - * Returns project template by name. - * - * @param {string} name the project template name - * @return {undefined|che.IProjectTemplate} - */ - getTemplateByName(name: string): che.IProjectTemplate { - return this.getAllTemplates().find((template: che.IProjectTemplate) => { - return template.name === name; - }); - } - /** * Callback which is called when template is checked or unchecked. * diff --git a/dashboard/src/app/workspaces/create-workspace/project-source-selector/edit-project/project-metadata/project-metadata.controller.ts b/dashboard/src/app/workspaces/create-workspace/project-source-selector/edit-project/project-metadata/project-metadata.controller.ts index d7d89ae854..e928171593 100644 --- a/dashboard/src/app/workspaces/create-workspace/project-source-selector/edit-project/project-metadata/project-metadata.controller.ts +++ b/dashboard/src/app/workspaces/create-workspace/project-source-selector/edit-project/project-metadata/project-metadata.controller.ts @@ -87,7 +87,7 @@ export class ProjectMetadataController { } /** - * Restores project's name, description and source location from original state. + * Restores project's name and source location from original state. */ onEditProjectServicePublish(): void { this.template = angular.copy(this.origTemplate); @@ -104,16 +104,6 @@ export class ProjectMetadataController { this.projectMetadataService.onMetadataChanged(this.template); } - /** - * Callback which is called when description is changed. - * - * @param {string} description the project's description - */ - onDescriptionChanged(description: string): void { - this.template.description = description; - this.projectMetadataService.onMetadataChanged(this.template); - } - /** * Callback which is called when metadata is changed. * diff --git a/dashboard/src/app/workspaces/create-workspace/project-source-selector/edit-project/project-metadata/project-metadata.html b/dashboard/src/app/workspaces/create-workspace/project-source-selector/edit-project/project-metadata/project-metadata.html index 0d271ccc80..a55918adbd 100644 --- a/dashboard/src/app/workspaces/create-workspace/project-source-selector/edit-project/project-metadata/project-metadata.html +++ b/dashboard/src/app/workspaces/create-workspace/project-source-selector/edit-project/project-metadata/project-metadata.html @@ -19,20 +19,6 @@
The name has to be less than 128 characters long.
- - -
The name has to be less than 128 characters long.
-
The name has to be less than 128 characters long.
-
-
; + private devfileProjects: Array; + private devfile: che.IWorkspaceDevfile; /** * Project selector service. */ @@ -68,8 +71,37 @@ export class ProjectSourceSelectorController { constructor($scope: IProjectSourceSelectorScope, projectSourceSelectorService: ProjectSourceSelectorService) { this.$scope = $scope; this.projectSourceSelectorService = projectSourceSelectorService; - this.actionType = ActionType; + this.devfileProjectsCopy = null; + + + $scope.$watch(() => { + return this.devfile; + }, () => { + if (!this.devfile) { + return; + } + this.devfileProjects = angular.copy(this.devfile.projects); + if (this.devfileProjectsCopy && this.devfileProjectsCopy !== this.devfileProjects) { + this.devfileProjectsCopy.forEach((project: any) => { + this.projectSourceSelectorService.removeProjectTemplate(project.name); + }); + this.projectTemplates = this.projectSourceSelectorService.getProjectTemplates(); + this.updateData({buttonState: true, actionType: ActionType.ADD_PROJECT}); + } + + if (this.devfileProjects && this.devfileProjects.length > 0) { + this.devfileProjects.forEach((project: any) => { + this.projectSourceSelectorService.addProjectTemplate(project); + }); + + // update list of templates to redraw the projects section + this.projectTemplates = this.projectSourceSelectorService.getProjectTemplates(); + this.updateData({buttonState: true, actionType: ActionType.EDIT_PROJECT, template: this.devfileProjects[0]}); + } + + this.devfileProjectsCopy = angular.copy(this.devfileProjects); + }, true); $scope.$watch('$destroy', () => { this.projectSourceSelectorService.clearTemplatesList(); @@ -94,7 +126,6 @@ export class ProjectSourceSelectorController { // update list of templates to redraw the projects section this.projectTemplates = this.projectSourceSelectorService.getProjectTemplates(); - this.updateData({buttonState: true, actionType: ActionType.EDIT_PROJECT, template: projectTemplate}); } @@ -106,7 +137,6 @@ export class ProjectSourceSelectorController { // update list of templates to redraw the projects section this.projectTemplates = this.projectSourceSelectorService.getProjectTemplates(); - this.updateData({buttonState: true, actionType: ActionType.ADD_PROJECT}); } @@ -149,7 +179,7 @@ export class ProjectSourceSelectorController { this.activeActionType = actionType; this.selectedProjectTemplate = angular.copy(template); - + this.$scope.updateWidget(this.activeButtonId, this.scrollToBottom); this.scrollToBottom = false; } diff --git a/dashboard/src/app/workspaces/create-workspace/project-source-selector/project-source-selector.directive.ts b/dashboard/src/app/workspaces/create-workspace/project-source-selector/project-source-selector.directive.ts index 3acc8a1242..71842831c6 100644 --- a/dashboard/src/app/workspaces/create-workspace/project-source-selector/project-source-selector.directive.ts +++ b/dashboard/src/app/workspaces/create-workspace/project-source-selector/project-source-selector.directive.ts @@ -34,7 +34,9 @@ export class ProjectSourceSelector implements ng.IDirective { bindToController: boolean = true; - scope = {}; + scope = { + devfile: '=' + }; private $timeout: ng.ITimeoutService; @@ -47,43 +49,56 @@ export class ProjectSourceSelector implements ng.IDirective { link($scope: IProjectSourceSelectorScope, $element: ng.IAugmentedJQuery): void { $scope.updateWidget = (activeButtonId: string, scrollToBottom: boolean) => { - this.$timeout(() => { - const popover = $element.find('.project-source-selector-popover'), - arrow = popover.find('.arrow'), - selectButton = $element.find(`#${activeButtonId} button`); - if (!selectButton || !selectButton.length) { - popover.removeAttr('style'); - arrow.removeAttr('style'); - return; - } - const widgetHeight = $element.height(); - const top = selectButton.position().top + (selectButton.height() / 2); - - const popoverHeight = popover.height(); - if (popoverHeight < top) { - if ((top + popoverHeight / 2) < widgetHeight) { - popover.attr('style', `top: ${top - (popoverHeight / 2 + 8)}px;`); - arrow.attr('style', 'top: 50%;'); - } else { - popover.attr('style', `top: ${top - popoverHeight}px;`); - arrow.attr('style', `top: ${popoverHeight}px;`); - } - } else { - popover.attr('style', 'top: 0px;'); - arrow.attr('style', `top: ${top}px;`); - } - - if (scrollToBottom === false) { - return; - } - - // scroll to bottom of the page - // to make 'Create' button visible - const mdContent = $element.closest('md-content'), - mdContentHeight = mdContent.height(); - mdContent.scrollTop(mdContentHeight); - }); + let timeoutPeriod = 0; + this.updateWidget($element, activeButtonId, scrollToBottom, timeoutPeriod); + }; } + private updateWidget($element: ng.IAugmentedJQuery, activeButtonId: string, scrollToBottom: boolean, timeoutPeriod: number): void { + this.$timeout(() => { + const popover = $element.find('.project-source-selector-popover'), + arrow = popover.find('.arrow'), + selectButton = $element.find(`#${activeButtonId} button`); + if (!selectButton || !selectButton.length) { + popover.removeAttr('style'); + arrow.removeAttr('style'); + return; + } + const widgetHeight = $element.height(); + const top = selectButton.position().top + (selectButton.height() / 2); + const popoverHeight = popover.height(); + + // With popover height lower than zero - wait to be drawn: + if (popoverHeight <= 0) { + timeoutPeriod = 500; + this.updateWidget($element, activeButtonId, scrollToBottom, timeoutPeriod); + return; + } + + if (popoverHeight < top) { + if ((top + popoverHeight / 2) < widgetHeight) { + popover.attr('style', `top: ${top - (popoverHeight / 2 + 8)}px;`); + arrow.attr('style', 'top: 50%;'); + } else { + popover.attr('style', `top: ${top - popoverHeight}px;`); + arrow.attr('style', `top: ${popoverHeight}px;`); + } + } else { + popover.attr('style', 'top: 0px;'); + arrow.attr('style', `top: ${top}px;`); + } + + if (scrollToBottom === false) { + return; + } + + // scroll to bottom of the page + // to make 'Create' button visible + const mdContent = $element.closest('md-content'), + mdContentHeight = mdContent.height(); + mdContent.scrollTop(mdContentHeight); + }, timeoutPeriod); + } + } diff --git a/dashboard/src/app/workspaces/create-workspace/project-source-selector/project-source-selector.html b/dashboard/src/app/workspaces/create-workspace/project-source-selector/project-source-selector.html index 28e999251e..6e54130977 100644 --- a/dashboard/src/app/workspaces/create-workspace/project-source-selector/project-source-selector.html +++ b/dashboard/src/app/workspaces/create-workspace/project-source-selector/project-source-selector.html @@ -18,7 +18,6 @@ che-state="projectSourceSelectorController.buttonState[projectTemplate.name]" uib-tooltip="{{projectTemplate.name}}">
-
@@ -26,7 +25,9 @@
+ project-on-add="projectSourceSelectorController.projectTemplateOnAdd(templates)" + devfile="projectSourceSelectorController.devfile"> +
diff --git a/dashboard/src/app/workspaces/create-workspace/project-source-selector/project-source-selector.service.ts b/dashboard/src/app/workspaces/create-workspace/project-source-selector/project-source-selector.service.ts index 9298662e0e..cd42bd4903 100644 --- a/dashboard/src/app/workspaces/create-workspace/project-source-selector/project-source-selector.service.ts +++ b/dashboard/src/app/workspaces/create-workspace/project-source-selector/project-source-selector.service.ts @@ -89,17 +89,12 @@ export class ProjectSourceSelectorService { const origName = projectTemplate.name; if (this.isProjectTemplateNameUnique(origName) === false) { - // update name, displayName and path + // update name and path const newName = this.getUniqueName(origName); projectTemplate.name = newName; - projectTemplate.displayName = newName; projectTemplate.path = '/' + newName.replace(/[^\w-_]/g, '_'); } - if (!projectTemplate.type && projectTemplate.projectType) { - projectTemplate.type = projectTemplate.projectType; - } - this.projectTemplates.push(projectTemplate); } diff --git a/dashboard/src/app/workspaces/workspace-config.service.ts b/dashboard/src/app/workspaces/workspace-config.service.ts index ec7ec44de9..e474fcebc8 100644 --- a/dashboard/src/app/workspaces/workspace-config.service.ts +++ b/dashboard/src/app/workspaces/workspace-config.service.ts @@ -108,7 +108,6 @@ export class WorkspaceConfigService { namespaceIdDefer.promise, workspacesDefer.promise, this.stackSelectorSvc.getOrFetchStacks(), - this.templateSelectorSvc.getOrFetchTemplates(), githubRepositoriesPromise ]); } diff --git a/dashboard/src/app/workspaces/workspace-details/workspace-projects/project-item/project-item.html b/dashboard/src/app/workspaces/workspace-details/workspace-projects/project-item/project-item.html index f873dcb4e9..7ff074c852 100644 --- a/dashboard/src/app/workspaces/workspace-details/workspace-projects/project-item/project-item.html +++ b/dashboard/src/app/workspaces/workspace-details/workspace-projects/project-item/project-item.html @@ -39,7 +39,7 @@ aria-label="project-item" class="che-list-item-name"> Description - {{projectItemCtrl.project.description}} + {{projectItemCtrl.project.source.location}}
Actions diff --git a/dashboard/src/app/workspaces/workspace-details/workspace-projects/workspace-details-projects.controller.ts b/dashboard/src/app/workspaces/workspace-details/workspace-projects/workspace-details-projects.controller.ts index 1f725990fb..88f2b003b7 100644 --- a/dashboard/src/app/workspaces/workspace-details/workspace-projects/workspace-details-projects.controller.ts +++ b/dashboard/src/app/workspaces/workspace-details/workspace-projects/workspace-details-projects.controller.ts @@ -12,7 +12,6 @@ 'use strict'; import {ConfirmDialogService} from '../../../../components/service/confirm-dialog/confirm-dialog.service'; import {CheAPI} from '../../../../components/api/che-api.factory'; -import {StackSelectorSvc} from '../../create-workspace/stack-selector/stack-selector.service'; import {RandomSvc} from '../../../../components/utils/random.service'; import {WorkspaceDetailsProjectsService} from './workspace-details-projects.service'; import {WorkspaceDetailsService} from '../workspace-details.service'; @@ -30,7 +29,7 @@ import {WorkspaceDataManager} from '../../../../components/api/workspace/workspa */ export class WorkspaceDetailsProjectsCtrl { - static $inject = ['cheAPI', '$mdDialog', 'confirmDialogService', '$scope', 'cheListHelperFactory', 'stackSelectorSvc', 'randomSvc', 'createWorkspaceSvc', 'workspaceDetailsService', 'workspaceDetailsProjectsService']; + static $inject = ['cheAPI', '$mdDialog', 'confirmDialogService', '$scope', 'cheListHelperFactory', 'randomSvc', 'createWorkspaceSvc', 'workspaceDetailsService', 'workspaceDetailsProjectsService']; /** * Material design Dialog service. @@ -44,10 +43,6 @@ export class WorkspaceDetailsProjectsCtrl { * List helper. */ private cheListHelper: che.widget.ICheListHelper; - /** - * Stack selector service. - */ - private stackSelectorSvc: StackSelectorSvc; /** * Generator for random strings. */ @@ -86,14 +81,12 @@ export class WorkspaceDetailsProjectsCtrl { confirmDialogService: ConfirmDialogService, $scope: ng.IScope, cheListHelperFactory: che.widget.ICheListHelperFactory, - stackSelectorSvc: StackSelectorSvc, randomSvc: RandomSvc, createWorkspaceSvc: CreateWorkspaceSvc, workspaceDetailsService: WorkspaceDetailsService, workspaceDetailsProjectsService: WorkspaceDetailsProjectsService) { this.$mdDialog = $mdDialog; this.confirmDialogService = confirmDialogService; - this.stackSelectorSvc = stackSelectorSvc; this.randomSvc = randomSvc; this.workspaceDetailsProjectsService = workspaceDetailsProjectsService; this.createWorkspaceSvc = createWorkspaceSvc; @@ -151,7 +144,6 @@ export class WorkspaceDetailsProjectsCtrl { return; } this.workspaceDetails = workspaceDetails; - this.stackSelectorSvc.setStackId(this.workspaceDetails.attributes.stackId); this.projects = this.workspaceDataManager.getProjects(this.workspaceDetails); this.cheListHelper.setList(this.projects, 'name'); } @@ -183,7 +175,6 @@ export class WorkspaceDetailsProjectsCtrl { // update name, displayName and path const newName = this.getUniqueName(origName); projectTemplate.name = newName; - projectTemplate.displayName = newName; projectTemplate.path = '/' + newName.replace(/[^\w-_]/g, '_'); } diff --git a/dashboard/src/components/api/builder/che-api-builder.factory.ts b/dashboard/src/components/api/builder/che-api-builder.factory.ts index cd2581a0ad..207449b4c3 100644 --- a/dashboard/src/components/api/builder/che-api-builder.factory.ts +++ b/dashboard/src/components/api/builder/che-api-builder.factory.ts @@ -65,14 +65,6 @@ export class CheAPIBuilder { return new CheProjectDetailsBuilder(); } - /*** - * The Che Project Template builder - * @returns {CheProjectTemplateBuilder} - */ - getProjectTemplateBuilder() { - return new CheProjectTemplateBuilder(); - } - /*** * The Che Project Type builder * @returns {CheProjectTypeBuilder} diff --git a/dashboard/src/components/api/che-api-config.ts b/dashboard/src/components/api/che-api-config.ts index 47f4b78acb..5aed8c8a7e 100644 --- a/dashboard/src/components/api/che-api-config.ts +++ b/dashboard/src/components/api/che-api-config.ts @@ -13,7 +13,6 @@ import {CheAPI} from './che-api.factory'; import {CheWorkspace} from './workspace/che-workspace.factory'; -import {CheProjectTemplate} from './che-project-template.factory'; import {CheFactory} from './che-factory.factory'; import {CheStack} from './che-stack.factory'; import {CheWebsocket} from './che-websocket.factory'; @@ -49,7 +48,6 @@ export class ApiConfig { constructor(register: che.IRegisterService) { register.factory('cheWorkspace', CheWorkspace); - register.factory('cheProjectTemplate', CheProjectTemplate); register.factory('cheFactory', CheFactory); register.factory('cheProfile', CheProfile); register.factory('chePreferences', ChePreferences); diff --git a/dashboard/src/components/api/che-api.factory.ts b/dashboard/src/components/api/che-api.factory.ts index 262ea16e00..43aae1ae73 100644 --- a/dashboard/src/components/api/che-api.factory.ts +++ b/dashboard/src/components/api/che-api.factory.ts @@ -16,7 +16,6 @@ import {CheProfile} from './che-profile.factory'; import {CheFactory} from './che-factory.factory'; import {CheFactoryTemplate} from './che-factory-template.factory'; import {ChePreferences} from './che-preferences.factory'; -import {CheProjectTemplate} from './che-project-template.factory'; import {CheService} from './che-service.factory'; import {CheStack} from './che-stack.factory'; import {CheOAuthProvider} from './che-o-auth-provider.factory'; @@ -32,14 +31,12 @@ import {CheUser} from './che-user.factory'; export class CheAPI { static $inject = ['cheWorkspace', 'cheFactory', 'cheFactoryTemplate', - 'cheProfile', 'chePreferences', 'cheProjectTemplate', - 'cheService', 'cheStack', 'cheOAuthProvider', 'cheAgent', + 'cheProfile', 'chePreferences', 'cheService', 'cheStack', 'cheOAuthProvider', 'cheAgent', 'cheSsh', 'cheUser', 'chePermissions', 'cheOrganization']; private cheWorkspace: CheWorkspace; private cheProfile: CheProfile; private chePreferences: ChePreferences; - private cheProjectTemplate: CheProjectTemplate; private cheFactory: CheFactory; private cheFactoryTemplate: CheFactoryTemplate; private cheService: CheService; @@ -55,15 +52,13 @@ export class CheAPI { * Default constructor that is using resource */ constructor(cheWorkspace: CheWorkspace, cheFactory: CheFactory, cheFactoryTemplate: CheFactoryTemplate, - cheProfile: CheProfile, chePreferences: ChePreferences, cheProjectTemplate: CheProjectTemplate, - cheService: CheService, cheStack: CheStack, cheOAuthProvider: CheOAuthProvider, cheAgent: CheAgent, + cheProfile: CheProfile, chePreferences: ChePreferences, cheService: CheService, cheStack: CheStack, cheOAuthProvider: CheOAuthProvider, cheAgent: CheAgent, cheSsh: CheSsh, cheUser: CheUser, chePermissions: che.api.IChePermissions, cheOrganization: che.api.ICheOrganization) { this.cheWorkspace = cheWorkspace; this.cheProfile = cheProfile; this.cheFactory = cheFactory; this.cheFactoryTemplate = cheFactoryTemplate; this.chePreferences = chePreferences; - this.cheProjectTemplate = cheProjectTemplate; this.cheService = cheService; this.cheStack = cheStack; this.cheOAuthProvider = cheOAuthProvider; @@ -106,14 +101,6 @@ export class CheAPI { return this.chePreferences; } - /** - * The Che Project Template API - * @returns {CheProjectTemplate} - */ - getProjectTemplate(): CheProjectTemplate { - return this.cheProjectTemplate; - } - /** * The Che Services API * @returns {CheService} diff --git a/dashboard/src/components/api/che-project-template.factory.ts b/dashboard/src/components/api/che-project-template.factory.ts deleted file mode 100644 index b45ab652d7..0000000000 --- a/dashboard/src/components/api/che-project-template.factory.ts +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2015-2018 Red Hat, Inc. - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - */ -'use strict'; - -/** - * This class is handling the projects template retrieval - * It sets to the array project templates - * @author Florent Benoit - */ -export class CheProjectTemplate { - - static $inject = ['$resource']; - - $resource: ng.resource.IResourceService; - templatesPerCategory: { - [category: string]: Array; - }; - templates: Array; - - remoteProjectTemplateAPI: ng.resource.IResourceClass; - - /** - * Default constructor that is using resource - */ - constructor ($resource: ng.resource.IResourceService) { - - // keep resource - this.$resource = $resource; - - // types per category - this.templatesPerCategory = {}; - - // project templates - this.templates = []; - - // remote call - this.remoteProjectTemplateAPI = > this.$resource('/api/project-template/all'); - } - - - - /** - * Fetch the project templates - * - * @return {IPromise} - */ - fetchTemplates(): ng.IPromise { - - const promise = this.remoteProjectTemplateAPI.query().$promise; - const updatedPromise = promise.then((projectTemplates: Array) => { - - // reset global list - this.templates.length = 0; - for (const member in this.templatesPerCategory) { - if (this.templatesPerCategory.hasOwnProperty(member)) { - delete this.templatesPerCategory[member]; - } - } - - projectTemplates.forEach((projectTemplate: che.IProjectTemplate) => { - // get attributes - const category = projectTemplate.category; - - // get list - if (!this.templatesPerCategory[category]) { - this.templatesPerCategory[category] = []; - } - - // add element on the list - this.templatesPerCategory[category].push(projectTemplate); - - this.templates.push(projectTemplate); - }); - - }); - - return updatedPromise; - } - - /** - * Gets all project templates - * - * @return {Array} - */ - getAllProjectTemplates(): Array { - return this.templates; - } - - /** - * The templates per category - * - * @return {{[p: string]: Array}} - */ - getTemplatesByCategory(): {[category: string]: Array} { - return this.templatesPerCategory; - } - - -} diff --git a/dashboard/src/components/api/che-project-template.spec.ts b/dashboard/src/components/api/che-project-template.spec.ts deleted file mode 100644 index eeaa25eceb..0000000000 --- a/dashboard/src/components/api/che-project-template.spec.ts +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (c) 2015-2018 Red Hat, Inc. - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - */ -'use strict'; -import {CheProjectTemplate} from './che-project-template.factory'; -import {CheAPIBuilder} from './builder/che-api-builder.factory'; -import {CheHttpBackend} from './test/che-http-backend'; - -/** - * Test of the CheProjectTemplate - */ -describe('CheProjectTemplate', function(){ - - /** - * Project Template Factory for the test - */ - let factory; - - /** - * API builder. - */ - let apiBuilder; - - /** - * Backend for handling http operations - */ - let httpBackend; - - /** - * Che backend - */ - let cheBackend; - - /** - * setup module - */ - beforeEach(angular.mock.module('userDashboard')); - - /** - * Inject factory and http backend - */ - beforeEach(inject(function(cheProjectTemplate: CheProjectTemplate, - cheAPIBuilder: CheAPIBuilder, - cheHttpBackend: CheHttpBackend) { - factory = cheProjectTemplate; - apiBuilder = cheAPIBuilder; - cheBackend = cheHttpBackend; - httpBackend = cheHttpBackend.getHttpBackend(); - })); - - /** - * Check assertion after the test - */ - afterEach(function () { - httpBackend.verifyNoOutstandingExpectation(); - httpBackend.verifyNoOutstandingRequest(); - }); - - - /** - * Check that we're able to fetch project types - */ - it('Fetch project types', function() { - - // setup tests objects - var templateHelloWorldCli = apiBuilder.getProjectTemplateBuilder() - .withProjectType('maven') - .withCategory('Samples - Hello World') - .withSourceLocation('https://github.com/eclipse/dummy-che-templates/desktop-console-java.git') - .withSourceType('git') - .withSourceParameters({branch: '3.1.0', keepVcs: 'false'}) - .withDescription('A simple JAR project based on Maven.') - .withDisplayname('Maven Java Console') - .build(); - - var templateSwing = apiBuilder.getProjectTemplateBuilder() - .withProjectType('maven') - .withCategory('Samples - Hello World') - .withSourceLocation('https://github.com/eclipse/dummy-che-templates/desktop-swing-java-basic.git') - .withSourceType('git') - .withSourceParameters({branch: '3.1.0', keepVcs: 'false'}) - .withDescription('A simple Java Swing application.') - .withDisplayname('Swing') - .build(); - - var templateUD = apiBuilder.getProjectTemplateBuilder() - .withProjectType('AngularJS') - .withCategory('Samples - Che') - .withSourceLocation('https://github.com/eclipse/che-dashboard.git') - .withSourceType('git') - .withSourceParameters({branch: '3.1.0', keepVcs: 'false'}) - .withDescription('Che Dashboard example..') - .withDisplayname('Che Dashboard') - .build(); - - // providing request - // add workspaces on Http backend - cheBackend.addProjectTemplates([templateHelloWorldCli, templateSwing, templateUD]); - - // setup backend - cheBackend.setup(); - - // no templates now on factory - expect(factory.getAllProjectTemplates().length).toEqual(0); - - // fetch types - factory.fetchTemplates(); - - // expecting a GET - httpBackend.expectGET('/api/project-template/all'); - - // flush command - httpBackend.flush(); - - - // now, check types - var projectTemplates = factory.getAllProjectTemplates(); - var templatesByCategory = factory.getTemplatesByCategory(); - - - // check we have 3 types - expect(projectTemplates.length).toEqual(3); - - // check category hello world - var helloWorldCategory = templatesByCategory['Samples - Hello World']; - expect(helloWorldCategory).not.toBeNull(); - - expect(helloWorldCategory.length).toEqual(2); - - var firstType = helloWorldCategory[0]; - expect(firstType.projectType).toEqual(templateHelloWorldCli.projectType); - expect(firstType.displayName).toEqual(templateHelloWorldCli.displayName); - - var secondType = helloWorldCategory[1]; - expect(secondType.projectType).toEqual(templateSwing.projectType); - expect(secondType.displayName).toEqual(templateSwing.displayName); - - - // check category samples - var sampleCategory = templatesByCategory['Samples - Che']; - expect(sampleCategory).not.toBeNull(); - expect(sampleCategory.length).toEqual(1); - var anotherType = sampleCategory[0]; - expect(anotherType.projectType).toEqual(templateUD.projectType); - expect(anotherType.displayName).toEqual(templateUD.displayName); - - - } - ); - - - -}); diff --git a/dashboard/src/components/api/devfile-registry.factory.ts b/dashboard/src/components/api/devfile-registry.factory.ts index a8cc65c938..73939db95b 100644 --- a/dashboard/src/components/api/devfile-registry.factory.ts +++ b/dashboard/src/components/api/devfile-registry.factory.ts @@ -17,6 +17,7 @@ export interface IDevfileMetaData { globalMemoryLimit: string; icon: string; links: any; + tags: Array; }