CHE-12917 add the unsupported workspace version error mark

Signed-off-by: Oleksii Orel <oorel@redhat.com>
7.20.x
Oleksii Orel 2019-05-06 19:10:54 +03:00
parent 10ae0c8432
commit b59b3bbacb
24 changed files with 298 additions and 97 deletions

View File

@ -27,7 +27,6 @@ exports.listStacksTheeEntries = function () {
'machines': {
'dev-machine': {
'servers': {},
'installers': ['org.eclipse.che.exec', 'org.eclipse.che.terminal', 'org.eclipse.che.ws-agent', 'org.eclipse.che.ssh'],
'attributes': {'memoryLimitBytes': '2147483648'}
}
}, 'recipe': {'content': 'codenvy/node', 'type': 'dockerimage'}

View File

@ -24,7 +24,6 @@ exports.dockerimageStack = function () {
'machines': {
'dev-machine': {
'servers': {},
'installers': ['org.eclipse.che.exec', 'org.eclipse.che.terminal', 'org.eclipse.che.ws-agent', 'org.eclipse.che.ssh'],
'attributes': {'memoryLimitBytes': '2147483648'}
}
}, 'recipe': {'content': 'eclipse/node', 'type': 'dockerimage'}
@ -61,7 +60,6 @@ exports.dockerfileStack = function () {
'machines': {
'dev-machine': {
'servers': {},
'installers': ['org.eclipse.che.ws-agent', 'org.eclipse.che.ssh', 'org.eclipse.che.exec', 'org.eclipse.che.terminal'],
'attributes': {'memoryLimitBytes': '2147483648'}
}
}

View File

@ -175,7 +175,6 @@ export class DiagnosticsWorkspaceStartCheck {
'diagnostics': {
'machines': {
'dev-machine': {
'installers': ['org.eclipse.che.ws-agent'],
'servers': {},
'attributes': {'memoryLimitBytes': '1147483648'}
}

View File

@ -135,7 +135,7 @@
<div class="che-list-item-secondary workspace-item-not-supported"
ng-if="listOrganizationWorkspacesController.isSupported(workspace) === false">
<div>
<span>Not supported</span>
<span>Not compatible</span>
<span class="che-list-actions"><i class="fa fa-question-circle"
uib-tooltip="Current infrastructure doesn't support this workspace recipe type."></i></span>
</div>

View File

@ -147,7 +147,6 @@ function getTestStack(): che.IStack {
'dev-machine': {
'env': { 'CHE_MACHINE_NAME': 'dev-machine' },
'volumes': {},
'installers': ['org.eclipse.che.ws-agent'],
'servers': {
'tomcat8-debug': {
'protocol': 'http',

View File

@ -30,6 +30,7 @@ export class WorkspaceItemCtrl {
workspace: che.IWorkspace;
workspaceName: string;
workspaceSupportIssues = '';
/**
* Default constructor that is using resource
@ -42,16 +43,31 @@ export class WorkspaceItemCtrl {
this.lodash = lodash;
this.cheWorkspace = cheWorkspace;
this.workspacesService = workspacesService;
this.workspaceName = this.cheWorkspace.getWorkspaceDataManager().getName(this.workspace);
this.workspaceName = this.cheWorkspace.getWorkspaceDataManager().getName(this.workspace);
}
/**
* Returns `true` if default environment of workspace contains supported recipe type.
* Returns `true` if supported.
*
* @returns {boolean}
*/
get isSupported(): boolean {
return this.workspacesService.isSupported(this.workspace);
if (!this.workspacesService.isSupportedRecipeType(this.workspace)) {
this.workspaceSupportIssues = 'Current infrastructure doesn\'t support this workspace recipe type.';
return false;
}
if (!this.workspacesService.isSupportedVersion(this.workspace)) {
this.workspaceSupportIssues = `This workspace is using old definition format which is not compatible anymore.
Please follow the documentation to update the definition of the workspace and benefits from the latest capabilities.`;
return false;
}
if (!this.workspaceSupportIssues) {
this.workspaceSupportIssues = '';
}
return true;
}
/**

View File

@ -98,8 +98,8 @@
<div class="che-list-item-secondary workspace-item-not-supported"
ng-if="workspaceItemCtrl.isSupported === false">
<div>
<span>Not supported</span>
<span class="che-list-actions"><i class="fa fa-question-circle" uib-tooltip="Current infrastructure doesn't support this workspace recipe type."></i></span>
<span>Not compatible</span>
<span class="che-list-actions"><i class="fa fa-question-circle" uib-tooltip="{{workspaceItemCtrl.workspaceSupportIssues}}"></i></span>
</div>
</div>

View File

@ -75,7 +75,6 @@ describe('WorkspaceStatus >', () => {
[defaultEnvironment]: {
'machines': {
'dev-machine': {
'installers': ['org.eclipse.che.ws-agent']
}
},
'recipe': {

View File

@ -19,5 +19,5 @@
</div>
</div>
<div class="che-list-empty" ng-show="machineSelectorController.machinesList.length === 0">
<span>There are no machines to display.</span>
<span>There are no containers to display.</span>
</div>

View File

@ -16,7 +16,6 @@ import {WorkspaceDetailsService} from './workspace-details.service';
import IdeSvc from '../../ide/ide.service';
import {WorkspacesService} from '../workspaces.service';
import {ICheEditModeOverlayConfig} from '../../../components/widget/edit-mode-overlay/che-edit-mode-overlay.directive';
import {IEnvironmentManagerMachine} from '../../../components/api/environment/environment-manager-machine';
export interface IInitData {
namespaceId: string;
@ -169,7 +168,7 @@ export class WorkspaceDetailsController {
}
/**
* Returns `true` if the recipe of default environment of the workspace has supported recipe type
* Returns `true` if supported.
*
* @returns {boolean}
*/
@ -177,6 +176,14 @@ export class WorkspaceDetailsController {
return this.workspacesService.isSupported(this.workspaceDetails);
}
isSupportedVersion(): boolean {
return this.workspacesService.isSupportedVersion(this.workspaceDetails);
}
isSupportedRecipeType(): boolean {
return this.workspacesService.isSupportedRecipeType(this.workspaceDetails);
}
/**
* Update tabs.
*/
@ -282,7 +289,7 @@ export class WorkspaceDetailsController {
}
this.workspaceDetails.config = config;
if (!this.originWorkspaceDetails || !this.workspaceDetails) {
return;
@ -292,7 +299,7 @@ export class WorkspaceDetailsController {
const failedTabs = this.checkForFailedTabs();
// publish changes
this.workspaceDetailsService.publishWorkspaceChange(this.workspaceDetails);
if (!failedTabs || failedTabs.length === 0) {
let runningWorkspace = this.getWorkspaceStatus() === WorkspaceStatus[WorkspaceStatus.STARTING] || this.getWorkspaceStatus() === WorkspaceStatus[WorkspaceStatus.RUNNING];
this.saveConfigChanges(false, runningWorkspace);
@ -315,16 +322,16 @@ export class WorkspaceDetailsController {
if (this.newName !== devfile.name) {
this.newName = devfile.name;
}
this.workspaceDetails.devfile = devfile;
if (!this.originWorkspaceDetails || !this.workspaceDetails) {
return;
}
this.workspaceDetailsService.publishWorkspaceChange(this.workspaceDetails);
let runningWorkspace = this.getWorkspaceStatus() === WorkspaceStatus[WorkspaceStatus.STARTING] || this.getWorkspaceStatus() === WorkspaceStatus[WorkspaceStatus.RUNNING];
this.saveConfigChanges(false, runningWorkspace);
}
@ -356,10 +363,14 @@ export class WorkspaceDetailsController {
* @returns {string}
*/
getOverlayMessage(failedTabs?: string[]): string {
if (this.isSupported === false) {
if (!this.isSupportedRecipeType()) {
return `Current infrastructure doesn't support this workspace recipe type.`;
}
if (!this.isSupportedVersion()) {
return `This workspace is using old definition format which is not compatible anymore.`;
}
if (failedTabs && failedTabs.length > 0) {
const url = this.$location.absUrl().split('?')[0];
let message = `<i class="error fa fa-exclamation-circle"
@ -471,7 +482,7 @@ export class WorkspaceDetailsController {
/**
* Updates workspace with new config.
*
*
*/
saveConfigChanges(refreshPage: boolean, notifyRestart?: boolean): void {
this.editOverlayConfig.disabled = true;

View File

@ -57,7 +57,6 @@ describe(`WorkspaceDetailsController >`, () => {
'dev-machine': {
'env': {},
'volumes': {},
'installers': ['org.eclipse.che.exec', 'org.eclipse.che.terminal', 'org.eclipse.che.ws-agent'],
'servers': {
'tomcat8-debug': {'protocol': 'http', 'port': '8000'},
'codeserver': {'protocol': 'http', 'port': '9876'},
@ -109,6 +108,8 @@ describe(`WorkspaceDetailsController >`, () => {
})
.service('workspacesService', function() {
this.isSupported = () => { return true; };
this.isSupportedVersion = () => { return true; };
this.isSupportedRecipeType = () => { return true; };
})
.service('$route', function() {
this.current = {
@ -585,6 +586,11 @@ describe(`WorkspaceDetailsController >`, () => {
compileDirective();
controller.workspacesService.isSupported = jasmine.createSpy('workspaceDetailsController.isSupported')
.and
.callFake(() => {
return false;
});
controller.workspacesService.isSupportedRecipeType = jasmine.createSpy('workspaceDetailsController.isSupportedRecipeType')
.and
.callFake(() => {
return false;

View File

@ -1,6 +1,9 @@
<che-row-toolbar
che-title="{{workspaceDetailsController.workspaceName}}"
link-href="#/workspaces" link-title="Workspaces" class="workspace-details-toolbar">
<che-description ng-hide="workspaceDetailsController.isSupportedVersion()" class="workspace-details-warning-info">
This workspace is using old 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-row-toolbar che-title="{{workspaceDetailsController.workspaceName}}" link-href="#/workspaces"
link-title="Workspaces" class="workspace-details-toolbar">
<div layout="row" layout-align="start center" class="toolbar-info">
<!-- is environment supported -->
<workspace-status che-status="workspaceDetailsController.getWorkspaceStatus()"

View File

@ -20,6 +20,12 @@
.toolbar-info
display flex
div.workspace-details-warning-info
border none
padding-left 20px
color inherit
background-color $warning-color
.workspace-details-content
md-tab-content
padding 0

View File

@ -163,7 +163,7 @@ export class WorkspaceMachinesController {
}
this.environmentManager = this.cheEnvironmentRegistry.getEnvironmentManager(this.environment.recipe.type);
this.machines = this.environmentManager.getMachines(this.environment);
this.machines = this.environmentManager.getMachines(this.environment, workspaceDetails.runtime);
this.environment = this.environmentManager.getEnvironment(this.environment, this.machines);
if (!angular.isArray(this.machines)) {
@ -295,7 +295,7 @@ export class WorkspaceMachinesController {
if (!machine) {
return;
}
}
const currentMemoryLimitBytes = this.environmentManager.getMemoryLimit(machine);
const currentMemoryLimitGBytes = currentMemoryLimitBytes === -1 ? 0 : this.getNumber(this.$filter('changeMemoryUnit')(currentMemoryLimitBytes, [MemoryUnit[MemoryUnit.B], MemoryUnit[MemoryUnit.GB]]));

View File

@ -13,7 +13,7 @@
-->
<md-content flex layout="column" md-theme="maincontent-theme" class="workspace-machines">
<div class="che-list-empty" ng-if="workspaceMachinesController.machines.length === 0">
<span>There are no machines to display.</span>
<span>There are no containers to display.</span>
</div>
<div class="warning-message" ng-hide="workspaceMachinesController.isScalable() || workspaceMachinesController.machines.length === 0">
<span>Add another machine by changing the environment type to <b>compose</b>, <b>kubernetes</b> or <b>openshift</b></span>

View File

@ -16,7 +16,7 @@
ng-show="workspaceDetailsSshCtrl.isLoading"></md-progress-linear>
</div>
<div class="che-list-empty" ng-if="!workspaceDetailsSshCtrl.workspace.config.defaultEnv">
<span>There are no machines to display.</span>
<span>There are no containers to display.</span>
</div>
<md-content flex class="workspace-ssh-content" ng-if="workspaceDetailsSshCtrl.workspace.config.defaultEnv">
<div layout="row" flex class="workspace-ssh-content-invalid-notification" ng-if="workspaceDetailsSshCtrl.workspace.status !== 'RUNNING'">

View File

@ -0,0 +1,167 @@
/*
* 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 {CheWorkspace} from '../../components/api/workspace/che-workspace.factory';
import {WorkspacesService} from './workspaces.service';
/**
* WorkspacesService tests.
*
* @author Oleksii Orel
*/
describe(`WorkspacesService >`, () => {
/**
* Service to test.
*/
let workspacesService: WorkspacesService;
let cheWorkspace: CheWorkspace;
function getCHE6Workspace(recipeType?: string): che.IWorkspace {
return {
'namespace': 'che',
'status': 'RUNNING',
'config': {
'attributes': {},
'environments': {
'default': {
'recipe': {
'type': recipeType ? recipeType : 'dockerimage',
'content': 'eclipse/ubuntu_jdk8'
},
'machines': {
'dev-machine': {
'env': {},
'volumes': {},
'installers': [
'org.eclipse.che.exec',
'org.eclipse.che.terminal'
],
'servers': {
'tomcat8-debug': {'protocol': 'http', 'port': '8000'},
'codeserver': {'protocol': 'http', 'port': '9876'},
'tomcat8': {'protocol': 'http', 'port': '8080'}
},
'attributes': {'memoryLimitBytes': '2147483648'}
}
}
}
}, 'projects': [], 'commands': [], 'defaultEnv': 'default', 'name': 'wksp-98cs'
},
'temporary': false,
'links': {
'self': '...Fake self link...',
'ide': '...Fake ide link...'
},
'id': 'workspacezbkov1e8qcm00dli',
'attributes': {
'created': 1516282666658,
'stackId': '...Fake stack id...'
}
};
}
function getCHE7Workspace(recipeType?: string): che.IWorkspace {
return {
'namespace': 'che',
'status': 'RUNNING',
'config': {
'defaultEnv': 'default',
'environments': {
'default': {
'machines': {},
'recipe': {
'type': recipeType ? recipeType : 'kubernetes',
'content': '...Fake recipe content...',
'contentType': '...Fake recipe contentType...'
}
}
},
'attributes': {
'editor': 'eclipse/che-theia/0.0.1',
'plugins': 'eclipse/che-machine-exec-plugin/0.0.1'
},
'projects': [],
'name': 'wksp-7znm',
'commands': []
},
'temporary': false,
'links': {
'self': '...Fake self link...',
'ide': '...Fake ide link...'
},
'id': 'workspacezbkov1e8qcm00dli',
'attributes': {
'created': 1516282666658,
'stackId': '...Fake stack id...'
}
};
}
/**
* Setup module
*/
beforeEach(() => {
angular.mock.module('userDashboard');
});
beforeEach(() => {
angular.module('workspacesServiceMock', [])
.service('cheWorkspace', function () {
this.getSupportedRecipeTypes = (): string[] => {
return ['kubernetes','dockerimage','no-environment'];
}
});
angular.mock.module('workspacesServiceMock');
});
beforeEach(inject((_workspacesService_: WorkspacesService,
_cheWorkspace_: CheWorkspace) => {
cheWorkspace = _cheWorkspace_;
workspacesService = _workspacesService_;
}));
describe(`supported workspace version >`, () => {
it(`should support a CHE7 workspace >`, () => {
const newCHE7Workspace = getCHE7Workspace();
expect(workspacesService.isSupported(newCHE7Workspace)).toBeTruthy();
expect(workspacesService.isSupportedVersion(newCHE7Workspace)).toBeTruthy();
});
it(`shouldn't support a CHE6 workspace >`, () => {
const oldCHE6Workspace = getCHE6Workspace();
expect(workspacesService.isSupported(oldCHE6Workspace)).toBeFalsy();
expect(workspacesService.isSupportedVersion(oldCHE6Workspace)).toBeFalsy();
});
});
describe(`supported recipe type >`, () => {
it(`should support a default recipe type >`, () => {
const newCHE7Workspace = getCHE7Workspace();
expect(workspacesService.isSupported(newCHE7Workspace)).toBeTruthy();
expect(workspacesService.isSupportedRecipeType(newCHE7Workspace)).toBeTruthy();
});
it(`shouldn't support a fake recipe type >`, () => {
const recipeType = '...Fake recipeType...';
const newCHE7Workspace = getCHE7Workspace(recipeType);
expect(workspacesService.isSupported(newCHE7Workspace)).toBeFalsy();
expect(workspacesService.isSupportedRecipeType(newCHE7Workspace)).toBeFalsy();
});
});
});

View File

@ -13,6 +13,8 @@
import {CheWorkspace} from '../../components/api/workspace/che-workspace.factory';
const MINIMAL_SUPORTED_VERSION = 7;
/**
* This is a helper class for workspaces.
*
@ -42,7 +44,7 @@ export class WorkspacesService {
* @param {string=} envName environment name
* @returns {boolean}
*/
isSupported(workspace: che.IWorkspace, envName?: string): boolean {
isSupportedRecipeType(workspace: che.IWorkspace, envName?: string): boolean {
if (workspace.config) {
envName = envName || workspace.config.defaultEnv;
const supportedRecipeTypes = this.cheWorkspace.getSupportedRecipeTypes(),
@ -52,4 +54,45 @@ export class WorkspacesService {
return true;
}
}
/**
* Returns `true` if supported.
* @param {che.IWorkspace} workspace
* @param {string=} envName environment name
* @returns {boolean}
*/
isSupported(workspace: che.IWorkspace, envName?: string): boolean {
envName = envName || workspace.config.defaultEnv;
return this.isSupportedRecipeType(workspace, envName) && this.isSupportedVersion(workspace);
}
/**
* Returns `true` if supported in the current version of the product.
* @param {che.IWorkspace} workspace
* @returns {boolean}
*/
isSupportedVersion(workspace: che.IWorkspace): boolean {
if (!workspace || !workspace.config) {
return false;
}
const config = workspace.config;
const machines = config.environments[config.defaultEnv];
let version: number;
if (!Object.keys(machines).length || config.attributes.editor || config.attributes.plugins) {
version = 7;
} else {
for (const key in machines) {
const installers = machines[key].installers;
if (installers && installers.length !== 0) {
version = 6;
break;
}
}
}
return version && version >= MINIMAL_SUPORTED_VERSION;
}
}

View File

@ -51,7 +51,6 @@ describe('ComposeEnvironmentManager', () => {
'volumes': {
'volume1': {'path': '/some/path'}
},
'installers': ['org.eclipse.che.ws-agent', 'org.eclipse.che.terminal', 'org.eclipse.che.ssh']
}
},
'recipe': {
@ -78,15 +77,6 @@ describe('ComposeEnvironmentManager', () => {
expect(servers).toEqual(expectedServers);
});
it('at least one machine should contain \'ws-agent\'', () => {
let devMachinesList = machines.filter((machine: IEnvironmentManagerMachine) => {
return envManager.isDev(machine);
});
expect(devMachinesList.length).toBeGreaterThan(0);
});
});
describe('for recipe from content', () => {
@ -113,8 +103,7 @@ describe('ComposeEnvironmentManager', () => {
'volumes': {
'vol1': {'path': '/some/path'},
'm22': {'path': '/home/user/.m2/repository'}
},
'installers': ['org.eclipse.che.ws-agent', 'org.eclipse.che.terminal', 'org.eclipse.che.ssh']
}
}
},
'recipe': {
@ -197,7 +186,6 @@ describe('ComposeEnvironmentManager', () => {
'dev-machine': {
'servers': {},
'volumes': {},
'installers': ['org.eclipse.che.ws-agent', 'org.eclipse.che.terminal', 'org.eclipse.che.ssh'],
'attributes': {'memoryLimitBytes': '2147483648'}
}
},

View File

@ -31,7 +31,6 @@ describe('If recipe has content', () => {
'attributes': {'memoryLimitBytes': '2147483648'},
'servers': {},
'volumes': {},
'installers': ['org.eclipse.che.ws-agent', 'org.eclipse.che.terminal', 'org.eclipse.che.ssh']
}
},
'recipe': {
@ -73,12 +72,6 @@ describe('If recipe has content', () => {
expect(source).toEqual(expectedSource);
});
it('the machine should be a dev machine', () => {
let isDev = envManager.isDev(machines[0]);
expect(isDev).toBe(true);
});
it('should update environment\'s recipe via machine\'s source', () => {
let oldMachines = envManager.getMachines(environment),
oldSource = envManager.getSource(oldMachines[0]),
@ -109,7 +102,6 @@ describe('If recipe has location', () => {
'dev-machine': {
'servers': {},
'volumes': {},
'installers': ['org.eclipse.che.ws-agent', 'org.eclipse.che.terminal', 'org.eclipse.che.ssh'],
'attributes': {'memoryLimitBytes': '2147483648'}
}
},
@ -151,12 +143,6 @@ describe('If recipe has location', () => {
expect(source).toEqual(null);
});
it('the machine should be a dev machine', () => {
let isDev = envManager.isDev(machines[0]);
expect(isDev).toBe(true);
});
});
});

View File

@ -40,7 +40,7 @@ describe('DockerImageEnvironmentManager', () => {
'volume1': {
'path': '/123'
}
}, 'installers': ['ws-agent', 'org.eclipse.che.ws-agent'], 'attributes': {'memoryLimitBytes': '16642998272'}
}, 'attributes': {'memoryLimitBytes': '16642998272'}
}
}, 'recipe': {'content': 'codenvy/ubuntu_jdk8', 'type': 'dockerimage'}
};
@ -73,12 +73,6 @@ describe('DockerImageEnvironmentManager', () => {
expect(memoryLimit.toString()).toEqual(expectedMemoryLimit.toString());
});
it('the machine should be a dev machine', () => {
let isDev = envManager.isDev(machines[0]);
expect(isDev).toBe(true);
});
it('should update environment\'s recipe via machine\'s source', () => {
let machines = envManager.getMachines(environment),
newSource = 'eclipse/node';

View File

@ -56,7 +56,7 @@ describe('KubernetesEnvironmentManager', () => {
'volume1': {
'path': '/123'
}
}, 'installers': ['org.eclipse.che.ws-agent'], 'attributes': {'memoryLimitBytes': '16642998272'}
}, 'attributes': {'memoryLimitBytes': '16642998272'}
}
}, 'recipe': {
'contentType': 'application/x-yaml',
@ -92,12 +92,6 @@ describe('KubernetesEnvironmentManager', () => {
expect(memoryLimit.toString()).toEqual(expectedMemoryLimit.toString());
});
it(`the machine should be a dev machine`, () => {
let isDev = envManager.isDev(machines[0]);
expect(isDev).toBe(true);
});
it(`should update environment's recipe via machine's source`, () => {
const machines = envManager.getMachines(environment);
const newSource = 'eclipse/node';
@ -142,7 +136,7 @@ describe('KubernetesEnvironmentManager', () => {
'volume1': {
'path': '/123'
}
}, 'installers': ['org.eclipse.che.ws-agent'], 'attributes': {'memoryLimitBytes': '16642998272'}
}, 'attributes': {'memoryLimitBytes': '16642998272'}
}
}, 'recipe': {
'contentType': 'application/x-yaml',
@ -178,12 +172,6 @@ describe('KubernetesEnvironmentManager', () => {
expect(memoryLimit.toString()).toEqual(expectedMemoryLimit.toString());
});
it(`the machine should be a dev machine`, () => {
let isDev = envManager.isDev(machines[0]);
expect(isDev).toBe(true);
});
it(`should update environment's recipe via machine's source`, () => {
const machines = envManager.getMachines(environment);
const newSource = 'eclipse/node';

View File

@ -25,11 +25,6 @@ import {WorkspaceDataManager} from './workspace-data-manager';
const WS_AGENT_HTTP_LINK: string = 'wsagent/http';
const WS_AGENT_WS_LINK: string = 'wsagent/ws';
interface IWorkspaceSettings {
supportedRecipeTypes: string;
cheWorkspacePluginRegistryUrl: string;
}
interface ICHELicenseResource<T> extends ng.resource.IResourceClass<T> {
create: any;
createWithNamespace: any;
@ -42,7 +37,7 @@ interface ICHELicenseResource<T> extends ng.resource.IResourceClass<T> {
startWorkspaceWithNoEnvironment: any;
startTemporaryWorkspace: any;
addCommand: any;
getSettings: () => ng.resource.IResource<IWorkspaceSettings>;
getSettings: () => ng.resource.IResource<che.IWorkspaceSettings>;
}
export enum WorkspaceStatus {
@ -79,7 +74,7 @@ export class CheWorkspace {
private remoteWorkspaceAPI: ICHELicenseResource<any>;
private lodash: any;
private statusDefers: Object;
private workspaceSettings: any;
private workspaceSettings: che.IWorkspaceSettings;
private jsonRpcApiLocation: string;
private workspaceLoaderUrl: string;
/**
@ -89,9 +84,9 @@ export class CheWorkspace {
/**
* Map with promises.
*/
private workspacePromises: Map<string, ng.IHttpPromise<any>> = new Map();
private workspacePromises: Map<string, ng.IPromise<any>> = new Map();
/**
*
*
*/
private workspaceDataManager: WorkspaceDataManager;
@ -392,7 +387,7 @@ export class CheWorkspace {
}
const defer = this.$q.defer();
const promise: ng.IHttpPromise<any> = this.$http.get('/api/workspace/' + workspaceKey);
this.workspacePromises.set(workspacePromisesKey, promise);
this.workspacePromises.set(workspacePromisesKey, defer.promise);
promise.then((response: ng.IHttpPromiseCallbackArg<che.IWorkspace>) => {
const workspace = response.data;
@ -461,8 +456,7 @@ export class CheWorkspace {
'recipe': null,
'machines': {
'dev-machine': {
'attributes': {'memoryLimitBytes': ram},
'installers': ['org.eclipse.che.ws-agent', 'org.eclipse.che.exec', 'org.eclipse.che.terminal', 'org.eclipse.che.ssh']
'attributes': {'memoryLimitBytes': ram}
}
}
};
@ -494,8 +488,7 @@ export class CheWorkspace {
devMachine = {
'name': 'ws-machine',
'attributes': {'memoryLimitBytes': ram},
'type': 'docker',
'installers': ['org.eclipse.che.ws-agent', 'org.eclipse.che.exec', 'org.eclipse.che.terminal', 'org.eclipse.che.ssh']
'type': 'docker'
};
defaultEnvironment.machines[devMachine.name] = devMachine;
} else {
@ -583,8 +576,8 @@ export class CheWorkspace {
/**
* Notify user if workspace is ephemeral.
*
* @param workspaceId
*
* @param workspaceId
*/
notifyIfEphemeral(workspaceId: string): void {
let workspace = this.workspacesById.get(workspaceId);
@ -762,7 +755,7 @@ export class CheWorkspace {
*/
fetchWorkspaceSettings(): ng.IPromise<any> {
const promise = this.remoteWorkspaceAPI.getSettings().$promise;
return promise.then((settings: IWorkspaceSettings) => {
return promise.then((settings: che.IWorkspaceSettings) => {
this.workspaceSettings = settings;
return this.workspaceSettings;
}, (error: any) => {
@ -791,7 +784,7 @@ export class CheWorkspace {
*
* @returns {any} the system settings for workspaces
*/
getWorkspaceSettings(): IWorkspaceSettings {
getWorkspaceSettings(): che.IWorkspaceSettings {
return this.workspaceSettings;
}

View File

@ -301,6 +301,12 @@ declare namespace che {
usedResources?: string;
}
export interface IWorkspaceSettings {
supportedRecipeTypes: string;
cheWorkspacePluginRegistryUrl: string;
[propName: string]: string | boolean;
}
export interface IWorkspaceAttributes {
created: number;
updated?: number;