CHE-12918 add checks for incompatible factories
Signed-off-by: Oleksii Orel <oorel@redhat.com>7.20.x
parent
ee4461b2fd
commit
1c543a1005
|
|
@ -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 = {};
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -11,14 +11,20 @@
|
|||
Red Hat, Inc. - initial API and implementation
|
||||
|
||||
-->
|
||||
<che-description ng-hide="factoryDetailsController.isSupportedVersion()" class="workspace-details-warning-info">
|
||||
This factory is using old workspace definition format which is not compatible anymore.
|
||||
Please follow the <a ng-href="{{branding.docs.workspace}}" target="_blank">documentation</a> to update the definition of the workspace and benefits from the latest capabilities.
|
||||
</che-description>
|
||||
<che-toolbar
|
||||
ng-if="factoryDetailsController.factory !== undefined"
|
||||
che-title="{{factoryDetailsController.factory.name ? factoryDetailsController.factory.name : factoryDetailsController.factory.id}}"
|
||||
che-title-icons-controller="factoryDetailsController"
|
||||
che-button-name="Open"
|
||||
che-button-href="{{factoryDetailsController.getFactoryIdUrl()}}"
|
||||
che-button-href-target="_blank"
|
||||
che-breadcrumb-title="All factories"
|
||||
che-breadcrumb-href="#/factories">
|
||||
che-breadcrumb-href="#/factories"
|
||||
che-button-disabled="{{factoryDetailsController.isSupportedVersion() === false}}">
|
||||
</che-toolbar>
|
||||
<md-content md-scroll-y flex class="factory-details factory-details-content">
|
||||
<cdvy-factory-information cdvy-factory="factoryDetailsController.factory"></cdvy-factory-information>
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -43,11 +43,21 @@
|
|||
</div>
|
||||
<div flex-gt-xs="15">
|
||||
<span class="che-xs-header noselect" name="open-factory" hide-gt-xs>Actions</span>
|
||||
<span class="che-list-actions">
|
||||
<span class="che-list-actions" ng-if="factoryItemController.isSupportedVersion() === true">
|
||||
<a uib-tooltip="Open in IDE" ng-href="#/load-factory/{{factoryItemController.factory.id}}">
|
||||
<span class="fa fa-chevron-circle-right factory-action"></span>
|
||||
</a>
|
||||
</span>
|
||||
<div class="che-list-item-secondary workspace-item-not-supported" ng-if="factoryItemController.isSupportedVersion() === false">
|
||||
<div>
|
||||
<span>Not compatible</span>
|
||||
<span class="che-list-actions">
|
||||
<i class="fa fa-question-circle"
|
||||
uib-tooltip="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."></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -31,7 +31,12 @@
|
|||
flex="auto">
|
||||
<che-steps-container class="load-factory-working-log"
|
||||
che-all-steps="loadFactoryController.getLoadingSteps()"
|
||||
che-current-step="loadFactoryController.getCurrentProgressStep()"></che-steps-container>
|
||||
che-current-step="loadFactoryController.getCurrentProgressStep()">
|
||||
<che-description ng-hide="loadFactoryController.isSupportedVersion()" class="load-factory-warning-info">
|
||||
This factory is using old workspace definition format which is not compatible anymore.
|
||||
Please follow the <a ng-href="{{branding.docs.workspace}}" target="_blank">documentation</a> to update the definition of the workspace and benefits from the latest capabilities.
|
||||
</che-description>
|
||||
</che-steps-container>
|
||||
</div>
|
||||
</div>
|
||||
<!--bottom bar-->
|
||||
|
|
@ -44,9 +49,14 @@
|
|||
<div flex="50" layout="column" layout-align="end end" class="load-factory-bottom-bar-right">
|
||||
<div class="load-factory-retry-block"
|
||||
layout="column" layout-align="start end">
|
||||
<che-button-danger che-button-title="{{loadFactoryController.isResourceProblem() ? 'Stop running workspaces' : 'Retry'}}"
|
||||
ng-click="loadFactoryController.resetLoadFactoryInProgress()"
|
||||
ng-show="loadFactoryController.getLoadingSteps()[loadFactoryController.getCurrentProgressStep()].hasError"></che-button-danger>
|
||||
<div layout="row" layout-align="center stretch">
|
||||
<che-button-primary che-button-title="Continue the process manually"
|
||||
ng-hide="loadFactoryController.isSupportedVersion()"
|
||||
ng-click="loadFactoryController.redirectToCreateWorkspace()"></che-button-primary>
|
||||
<che-button-danger che-button-title="{{loadFactoryController.isResourceProblem() ? 'Stop running workspaces' : 'Retry'}}"
|
||||
ng-click="loadFactoryController.resetLoadFactoryInProgress()"
|
||||
ng-show="loadFactoryController.getLoadingSteps()[loadFactoryController.getCurrentProgressStep()].hasError"></che-button-danger>
|
||||
</div>
|
||||
<che-link class="load-factory-download-link"
|
||||
ng-click="loadFactoryController.downloadLogs()"
|
||||
che-link-text="Problem? download logs"></che-link>
|
||||
|
|
|
|||
|
|
@ -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<FactoryLoadingStep>;
|
||||
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
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
export class CheStepsContainer implements ng.IDirective {
|
||||
|
||||
restrict = 'E';
|
||||
transclude = true;
|
||||
templateUrl = 'components/steps-container/steps-container.html';
|
||||
|
||||
scope = {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<div class="che-steps-container">
|
||||
<ng-transclude></ng-transclude>
|
||||
<che-accordion ng-repeat="step in allSteps"
|
||||
ng-hide="$index === allSteps.length-1"
|
||||
che-open-condition="($index === currentStep)"
|
||||
|
|
|
|||
|
|
@ -519,6 +519,7 @@ declare namespace che {
|
|||
name?: string;
|
||||
v: string;
|
||||
workspace: IWorkspaceConfig;
|
||||
devfile?: IWorkspaceDevfile;
|
||||
creator: any;
|
||||
ide?: any;
|
||||
button?: any;
|
||||
|
|
|
|||
Loading…
Reference in New Issue