diff --git a/dashboard/src/app/factories/create-factory/workspaces-tab/factory-from-workpsace.controller.ts b/dashboard/src/app/factories/create-factory/workspaces-tab/factory-from-workpsace.controller.ts index b3970edf2b5..78c93c84bde 100644 --- a/dashboard/src/app/factories/create-factory/workspaces-tab/factory-from-workpsace.controller.ts +++ b/dashboard/src/app/factories/create-factory/workspaces-tab/factory-from-workpsace.controller.ts @@ -12,6 +12,7 @@ 'use strict'; import {CheAPI} from '../../../../components/api/che-api.factory'; import {CheNotification} from '../../../../components/notification/che-notification.factory'; +import {WorkspacesService} from '../../../workspaces/workspaces.service'; /** * Controller for creating factory from a workspace. @@ -20,7 +21,7 @@ import {CheNotification} from '../../../../components/notification/che-notificat */ export class FactoryFromWorkspaceCtrl { - static $inject = ['$filter', 'cheAPI', 'cheNotification']; + static $inject = ['$filter', 'cheAPI', 'cheNotification', 'workspacesService']; private $filter: ng.IFilterService; private cheAPI: CheAPI; @@ -32,16 +33,20 @@ export class FactoryFromWorkspaceCtrl { private isLoading: boolean; private isImporting: boolean; private factoryContent: any; + private workspacesService: WorkspacesService; /** * Default constructor that is using resource injection */ - constructor($filter: ng.IFilterService, cheAPI: CheAPI, cheNotification: CheNotification) { + constructor($filter: ng.IFilterService, cheAPI: CheAPI, cheNotification: CheNotification, workspacesService: WorkspacesService) { this.$filter = $filter; this.cheAPI = cheAPI; this.cheNotification = cheNotification; + this.workspacesService = workspacesService; - this.workspaces = cheAPI.getWorkspace().getWorkspaces(); + this.workspaces = cheAPI.getWorkspace().getWorkspaces().filter((workspace: che.IWorkspace) => { + return this.workspacesService.isSupported(workspace); + }); this.workspacesById = cheAPI.getWorkspace().getWorkspacesById(); this.filtersWorkspaceSelected = {}; diff --git a/dashboard/src/app/factories/factory-details/factory-details.controller.ts b/dashboard/src/app/factories/factory-details/factory-details.controller.ts index 2815c474655..441deaa583b 100644 --- a/dashboard/src/app/factories/factory-details/factory-details.controller.ts +++ b/dashboard/src/app/factories/factory-details/factory-details.controller.ts @@ -12,6 +12,7 @@ 'use strict'; import {CheNotification} from '../../../components/notification/che-notification.factory'; import {CheFactory} from '../../../components/api/che-factory.factory'; +import {LoadFactoryService} from '../../factories/load-factory/load-factory.service'; /** * Controller for a factory details. @@ -19,19 +20,21 @@ import {CheFactory} from '../../../components/api/che-factory.factory'; */ export class FactoryDetailsController { - static $inject = ['$route', 'cheFactory', 'cheNotification']; + static $inject = ['$route', 'cheFactory', 'cheNotification', 'loadFactoryService']; private cheFactory: CheFactory; private factory: che.IFactory; + private loadFactoryService: LoadFactoryService; /** * Default constructor that is using resource injection */ - constructor($route: ng.route.IRouteService, cheFactory: CheFactory, cheNotification: CheNotification) { + constructor($route: ng.route.IRouteService, cheFactory: CheFactory, cheNotification: CheNotification, loadFactoryService: LoadFactoryService) { this.cheFactory = cheFactory; let factoryId = $route.current.params.id; this.factory = this.cheFactory.getFactoryById(factoryId); + this.loadFactoryService = loadFactoryService; cheFactory.fetchFactoryById(factoryId).then((factory: che.IFactory) => { this.factory = factory; @@ -40,6 +43,14 @@ export class FactoryDetailsController { }); } + /** + * Returns `true` if supported version of factory workspace. + * @returns {boolean} + */ + isSupportedVersion(): boolean { + return this.loadFactoryService.isSupportedVersion(this.factory); + } + /** * Returns the factory url based on id. * @returns {link.href|*} link value diff --git a/dashboard/src/app/factories/factory-details/factory-details.html b/dashboard/src/app/factories/factory-details/factory-details.html index 21991beb4f4..50309aae7bd 100644 --- a/dashboard/src/app/factories/factory-details/factory-details.html +++ b/dashboard/src/app/factories/factory-details/factory-details.html @@ -11,14 +11,20 @@ Red Hat, Inc. - initial API and implementation --> + + This factory is using old workspace definition format which is not compatible anymore. + Please follow the documentation to update the definition of the workspace and benefits from the latest capabilities. + + che-breadcrumb-href="#/factories" + che-button-disabled="{{factoryDetailsController.isSupportedVersion() === false}}"> diff --git a/dashboard/src/app/factories/list-factories/factory-item/factory-item.controller.ts b/dashboard/src/app/factories/list-factories/factory-item/factory-item.controller.ts index 2c456a0ee1d..f68ab8b8540 100644 --- a/dashboard/src/app/factories/list-factories/factory-item/factory-item.controller.ts +++ b/dashboard/src/app/factories/list-factories/factory-item/factory-item.controller.ts @@ -12,6 +12,7 @@ 'use strict'; import {CheFactory} from '../../../../components/api/che-factory.factory'; import {CheEnvironmentRegistry} from '../../../../components/api/environment/che-environment-registry.factory'; +import {LoadFactoryService} from '../../../factories/load-factory/load-factory.service'; /** * Controller for a factory item. @@ -19,13 +20,14 @@ import {CheEnvironmentRegistry} from '../../../../components/api/environment/che */ export class FactoryItemController { - static $inject = ['$location', 'cheFactory', 'cheEnvironmentRegistry', 'lodash']; + static $inject = ['$location', 'cheFactory', 'cheEnvironmentRegistry', 'lodash', 'loadFactoryService']; private $location: ng.ILocationService; private cheFactory: CheFactory; private cheEnvironmentRegistry: CheEnvironmentRegistry; private lodash: any; private factory: che.IFactory; + private loadFactoryService: LoadFactoryService; /** * Default constructor that is using resource injection @@ -33,11 +35,21 @@ export class FactoryItemController { constructor($location: ng.ILocationService, cheFactory: CheFactory, cheEnvironmentRegistry: CheEnvironmentRegistry, - lodash: any) { + lodash: any, + loadFactoryService: LoadFactoryService) { this.$location = $location; this.cheFactory = cheFactory; this.cheEnvironmentRegistry = cheEnvironmentRegistry; this.lodash = lodash; + this.loadFactoryService = loadFactoryService; + } + + /** + * Returns `true` if supported version of factory workspace. + * @returns {boolean} + */ + isSupportedVersion(): boolean { + return this.loadFactoryService.isSupportedVersion(this.factory); } /** diff --git a/dashboard/src/app/factories/list-factories/factory-item/factory-item.html b/dashboard/src/app/factories/list-factories/factory-item/factory-item.html index 9d0bef35662..ba90b0a3b66 100644 --- a/dashboard/src/app/factories/list-factories/factory-item/factory-item.html +++ b/dashboard/src/app/factories/list-factories/factory-item/factory-item.html @@ -43,11 +43,21 @@
Actions - + +
+
+ Not compatible + + + +
+
diff --git a/dashboard/src/app/factories/load-factory/load-factory.controller.ts b/dashboard/src/app/factories/load-factory/load-factory.controller.ts index bb1feddf82e..12eb3682e36 100644 --- a/dashboard/src/app/factories/load-factory/load-factory.controller.ts +++ b/dashboard/src/app/factories/load-factory/load-factory.controller.ts @@ -25,7 +25,7 @@ const WS_AGENT_STEP: number = 4; */ export class LoadFactoryController { - static $inject = ['cheAPI', 'cheJsonRpcApi', '$route', '$timeout', '$mdDialog', 'loadFactoryService', 'lodash', 'cheNotification', '$location', 'routeHistory', '$window']; + static $inject = ['cheAPI', 'cheJsonRpcApi', '$route', '$timeout', '$mdDialog', 'loadFactoryService', 'lodash', 'cheNotification', '$location', 'routeHistory', '$window', 'loadFactoryService']; private cheAPI: CheAPI; private $timeout: ng.ITimeoutService; @@ -116,14 +116,14 @@ export class LoadFactoryController { this.factory = factory; // check factory polices: - if (!this.checkPolicies(this.factory)) { + if (!this.factory || !this.checkPolicies(this.factory)) { return; } - // check factory contains workspace config: - if (!this.factory.workspace) { + // check factory contains compatible workspace config: + if (!this.factory.workspace || !this.isSupportedVersion()) { this.getLoadingSteps()[this.getCurrentProgressStep()].hasError = true; - this.getLoadingSteps()[this.getCurrentProgressStep()].logs = 'Factory has no workspace config.'; + this.getLoadingSteps()[this.getCurrentProgressStep()].logs = 'Factory has no compatible workspace config.'; } else { this.loadFactoryService.goToNextStep(); this.$timeout(() => { @@ -679,6 +679,21 @@ export class LoadFactoryController { this.$location.path('/'); } + /** + * Returns `true` if supported version of factory workspace. + * @returns {boolean} + */ + isSupportedVersion(): boolean { + return this.loadFactoryService.isSupportedVersion(this.factory); + } + + /** + * Redirects to create workspace flow. + */ + redirectToCreateWorkspace(): void { + this.$location.path('/create-workspace').search({}); + } + /** * Performs downloading of the logs. */ diff --git a/dashboard/src/app/factories/load-factory/load-factory.html b/dashboard/src/app/factories/load-factory/load-factory.html index 976a28572f0..537b1ecdae3 100644 --- a/dashboard/src/app/factories/load-factory/load-factory.html +++ b/dashboard/src/app/factories/load-factory/load-factory.html @@ -31,7 +31,12 @@ flex="auto"> + che-current-step="loadFactoryController.getCurrentProgressStep()"> + + This factory is using old workspace definition format which is not compatible anymore. + Please follow the documentation to update the definition of the workspace and benefits from the latest capabilities. + + @@ -44,9 +49,14 @@
- +
+ + +
diff --git a/dashboard/src/app/factories/load-factory/load-factory.service.ts b/dashboard/src/app/factories/load-factory/load-factory.service.ts index 98f2ae2d9d9..62566f8877f 100644 --- a/dashboard/src/app/factories/load-factory/load-factory.service.ts +++ b/dashboard/src/app/factories/load-factory/load-factory.service.ts @@ -10,6 +10,7 @@ * Red Hat, Inc. - initial API and implementation */ 'use strict'; +import {WorkspacesService} from '../../workspaces/workspaces.service'; export interface FactoryLoadingStep { text: string; @@ -23,14 +24,19 @@ export interface FactoryLoadingStep { * @author Ann Shumilova */ export class LoadFactoryService { + + static $inject = ['workspacesService']; + private loadFactoryInProgress: boolean; private currentProgressStep: number; private loadingSteps: Array; + private workspacesService: WorkspacesService; /** * Default constructor that is using resource */ - constructor () { + constructor (workspacesService: WorkspacesService) { + this.workspacesService = workspacesService; this.loadFactoryInProgress = false; this.currentProgressStep = 0; @@ -123,4 +129,19 @@ export class LoadFactoryService { setLoadFactoryInProgress(value: boolean): void { this.loadFactoryInProgress = value; } + + /** + * Returns `true` if supported version of factory workspace. + * @param factory {che.IFactory} + * @returns {boolean} + */ + isSupportedVersion(factory: che.IFactory): boolean { + if (!factory) { + return false; + } + return this.workspacesService.isSupportedVersion({ + config: factory.workspace, + devfile: factory.devfile + }); + } } diff --git a/dashboard/src/app/factories/load-factory/load-factory.styl b/dashboard/src/app/factories/load-factory/load-factory.styl index a010d4bdf27..b3138a70e4a 100644 --- a/dashboard/src/app/factories/load-factory/load-factory.styl +++ b/dashboard/src/app/factories/load-factory/load-factory.styl @@ -14,6 +14,14 @@ .load-factory-working-log margin 35px 0 +div.load-factory-warning-info + border none + color inherit + max-width 448px + padding-left 20px + margin-bottom 20px + background-color $warning-color + .load-factory-bottom-bar height 90px diff --git a/dashboard/src/app/workspaces/workspaces.service.ts b/dashboard/src/app/workspaces/workspaces.service.ts index 499d955bb6c..afae52fdda5 100644 --- a/dashboard/src/app/workspaces/workspaces.service.ts +++ b/dashboard/src/app/workspaces/workspaces.service.ts @@ -70,11 +70,13 @@ export class WorkspacesService { * @returns {boolean} */ isSupportedVersion(workspace: che.IWorkspace): boolean { + if (!workspace){ + return false; + } if (workspace.devfile) { return true; } - - if (!workspace || !workspace.config) { + if (!workspace.config) { return false; } const config = workspace.config; diff --git a/dashboard/src/components/api/factory-templates.ts b/dashboard/src/components/api/factory-templates.ts index 763111d2edb..802cded7486 100644 --- a/dashboard/src/components/api/factory-templates.ts +++ b/dashboard/src/components/api/factory-templates.ts @@ -20,6 +20,10 @@ export class CheFactoryTemplates { return JSON.stringify({ 'v': '4.0', 'workspace': { + 'attributes': { + 'editor': 'eclipse/che-theia/next', + 'plugins': 'eclipse/che-machine-exec-plugin/0.0.1' + }, 'projects': [ { 'name': 'Spring', @@ -54,10 +58,6 @@ export class CheFactoryTemplates { 'wss': { 'machines': { 'dev-machine': { - 'installers': [ - 'org.eclipse.che.terminal', - 'org.eclipse.che.ws-agent' - ], 'servers': {}, 'attributes': { 'memoryLimitBytes': '2147483648' @@ -78,6 +78,10 @@ export class CheFactoryTemplates { return JSON.stringify({ 'v': '4.0', 'workspace': { + 'attributes': { + 'editor': 'eclipse/che-theia/next', + 'plugins': 'eclipse/che-machine-exec-plugin/0.0.1' + }, 'commands': [], 'projects': [ { @@ -109,15 +113,10 @@ export class CheFactoryTemplates { ], 'defaultEnv': 'wss', 'name': 'wss', - 'attributes': {}, 'environments': { 'wss': { 'machines': { 'dev-machine': { - 'installers': [ - 'org.eclipse.che.terminal', - 'org.eclipse.che.ws-agent' - ], 'servers': {}, 'attributes': { 'memoryLimitBytes': '2147483648' @@ -143,6 +142,10 @@ export class CheFactoryTemplates { return JSON.stringify({ 'v': '4.0', 'workspace': { + 'attributes': { + 'editor': 'eclipse/che-theia/next', + 'plugins': 'eclipse/che-machine-exec-plugin/0.0.1' + }, 'commands': [], 'projects': [ { @@ -166,10 +169,6 @@ export class CheFactoryTemplates { 'wss': { 'machines': { 'dev-machine': { - 'installers': [ - 'org.eclipse.che.terminal', - 'org.eclipse.che.ws-agent' - ], 'servers': {}, 'attributes': { 'memoryLimitBytes': '2147483648' diff --git a/dashboard/src/components/steps-container/steps-container.directive.ts b/dashboard/src/components/steps-container/steps-container.directive.ts index 17e89a3918c..d47b0c9c62a 100644 --- a/dashboard/src/components/steps-container/steps-container.directive.ts +++ b/dashboard/src/components/steps-container/steps-container.directive.ts @@ -18,6 +18,7 @@ export class CheStepsContainer implements ng.IDirective { restrict = 'E'; + transclude = true; templateUrl = 'components/steps-container/steps-container.html'; scope = { diff --git a/dashboard/src/components/steps-container/steps-container.html b/dashboard/src/components/steps-container/steps-container.html index 3792a41c379..7f0633c7434 100644 --- a/dashboard/src/components/steps-container/steps-container.html +++ b/dashboard/src/components/steps-container/steps-container.html @@ -1,4 +1,5 @@
+