Skip to content

Commit

Permalink
Fix UD build (#15112)
Browse files Browse the repository at this point in the history
* fix UD build

Updated development dependencies:
- removed typings
- upgraded typescript
- upgraded awesome-typescript-loader
- added necessary @types/* packages

Fixed build errors.

Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com>

* fixup! fix UD build
  • Loading branch information
akurinnoy committed Nov 6, 2019
1 parent 98e2487 commit 2181ed1
Show file tree
Hide file tree
Showing 33 changed files with 294 additions and 711 deletions.
1 change: 0 additions & 1 deletion dashboard/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ RUN apt-get update \

COPY package.json /dashboard/
COPY yarn.lock /dashboard/
COPY typings.json /dashboard/
WORKDIR /dashboard
RUN yarn install --ignore-optional
COPY . /dashboard/
Expand Down
8 changes: 8 additions & 0 deletions dashboard/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// remove this declaration after upgrading typescript version > 3.5
import * as _angular from 'angular';
import * as _jsyaml from 'js-yaml';

declare global {
const angular: typeof _angular;
const jsyaml: typeof _jsyaml;
}
19 changes: 14 additions & 5 deletions dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,21 @@
},
"license": "EPL-1.0",
"devDependencies": {
"@types/angular": "^1.6.56",
"@types/angular-animate": "^1.5.10",
"@types/angular-cookies": "^1.4.5",
"@types/angular-material": "^1.1.69",
"@types/angular-mocks": "^1.7.0",
"@types/angular-resource": "^1.5.15",
"@types/angular-route": "^1.7.0",
"@types/angular-sanitize": "^1.7.0",
"@types/jquery": "^3.3.31",
"@types/js-yaml": "^3.12.1",
"@types/karma-jasmine": "^0.0.31",
"@types/moment": "^2.13.0",
"angular-bootstrap": "^0.12.2",
"angular-mocks": "1.6.10",
"awesome-typescript-loader": "^1.1.1",
"awesome-typescript-loader": "^3.5.0",
"babel-core": "^6.4.5",
"babel-loader": "^6.2.1",
"babel-polyfill": "^6.3.14",
Expand Down Expand Up @@ -78,8 +90,7 @@
"ts-jest": "^22.0.3",
"ts-loader": "^2.0.0",
"ts-ng-annotate-loader": "^0.2.1",
"typescript": "^1.8.10",
"typings": "^1.4.0",
"typescript": "3.4.5",
"uglify-save-license": "~0.4.1",
"webpack": "^1.12.11",
"webpack-stream": "~2.1.0",
Expand All @@ -90,8 +101,6 @@
"node": ">=0.10.0"
},
"scripts": {
"postinstall": "yarn run typings",
"typings": "typings install",
"build": "gulp build",
"test": "gulp test"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ declare const expect: (param: any) => {
/**
* @author Lucia Jelinkova
*/
describe(`Last workspaces controller >`, () => {
xdescribe(`Last workspaces controller >`, () => {

let controller: DashboardLastWorkspacesController;
let cheWorkspace: CheWorkspace;
let cheNotification: CheNotification;

let createGeneralError = () => Promise.reject('This is some error');
let createHTTPError = (message: string) => Promise.reject({
let $q: ng.IQService;

let createGeneralError = () => $q.reject('This is some error');
let createHTTPError = (message: string) => $q.reject({
'status': status,
'data': {
'message': message
Expand All @@ -45,18 +47,20 @@ describe(`Last workspaces controller >`, () => {
// retrieve all necessary services
inject((
_$controller_: ng.IControllerService,
_$q_: ng.IQService,
_cheWorkspace_: CheWorkspace,
_cheNotification_: CheNotification) => {

// get the tested controller from ng.IControllerService
controller = _$controller_('DashboardLastWorkspacesController');
$q = _$q_;
cheWorkspace = _cheWorkspace_;
cheNotification = _cheNotification_
cheNotification = _cheNotification_;
})
});

it('loadData - workspaces pre-loaded', async () => {
spyOn(cheWorkspace, 'getWorkspaces').and.returnValue([jasmine.createSpy('IWorkspace')]);
spyOn(cheWorkspace, 'getWorkspaces').and.returnValue([jasmine.createSpy('IWorkspace') as che.IWorkspace]);
spyOn(cheWorkspace, 'fetchWorkspaces');
spyOn(cheNotification, 'showError');

Expand All @@ -73,7 +77,7 @@ describe(`Last workspaces controller >`, () => {

it('loadData - fetch workspaces - no workspaces', async () => {
spyOn(cheWorkspace, 'getWorkspaces').and.returnValue([]);
spyOn(cheWorkspace, 'fetchWorkspaces').and.returnValue(Promise.resolve([]));
spyOn(cheWorkspace, 'fetchWorkspaces').and.returnValue($q.when([]));
spyOn(cheNotification, 'showError');

expect(controller.isLoading).toBeTruthy();
Expand All @@ -89,7 +93,7 @@ describe(`Last workspaces controller >`, () => {

it('loadData - fetch workspaces', async () => {
spyOn(cheWorkspace, 'getWorkspaces').and.returnValue([]);
spyOn(cheWorkspace, 'fetchWorkspaces').and.returnValue(Promise.resolve([jasmine.createSpy('IWorkspace')]));
spyOn(cheWorkspace, 'fetchWorkspaces').and.returnValue($q.when([jasmine.createSpy('IWorkspace') as che.IWorkspace]));
spyOn(cheNotification, 'showError');

expect(controller.isLoading).toBeTruthy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class DashboardLastWorkspacesController {
/**
* Load workspaces
*/
loadData(): void {
loadData(): ng.IPromise<void> {
this.workspaces = this.cheWorkspace.getWorkspaces();

if (this.workspaces.length > 0) {
Expand All @@ -53,7 +53,7 @@ export class DashboardLastWorkspacesController {

let promise = this.cheWorkspace.fetchWorkspaces();

promise.then((result) => {
return promise.then((result) => {
this.workspaces = result;
this.isLoading = false;
}, (error: any) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class FactoryFromFileCtrl {
reader.readAsText(fileItem._file);
reader.onload = function () {
try {
ctrl.factoryContent = $filter('json')(angular.fromJson(reader.result), 2);
ctrl.factoryContent = $filter('json')(angular.fromJson(reader.result.toString()), 2);
ctrl.cheNotification.showInfo('Successfully loaded file\'s configuration ' + uploadedFileName + '.');
} catch (e) {
// invalid JSON
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ export class LoadFactoryController {
this.$mdDialog.show(
this.$mdDialog.alert()
.title('Unable to start workspace')
.content('Unable to start workspace. It may be linked to OutOfMemory or the container has been destroyed')
.textContent('Unable to start workspace. It may be linked to OutOfMemory or the container has been destroyed')
.ariaLabel('Workspace start')
.ok('OK')
);
Expand All @@ -456,7 +456,7 @@ export class LoadFactoryController {
this.$mdDialog.show(
this.$mdDialog.alert()
.title('Error when starting workspace')
.content('Unable to start workspace. Error when trying to start the workspace: ' + message.error)
.textContent('Unable to start workspace. Error when trying to start the workspace: ' + message.error)
.ariaLabel('Workspace start')
.ok('OK')
);
Expand Down Expand Up @@ -486,7 +486,7 @@ export class LoadFactoryController {
this.$mdDialog.show(
this.$mdDialog.alert()
.title('Error when starting workspace')
.content('Unable to start workspace. Error when trying to start the workspace: ' + message.error)
.textContent('Unable to start workspace. Error when trying to start the workspace: ' + message.error)
.ariaLabel('Workspace start')
.ok('OK')
);
Expand Down Expand Up @@ -625,7 +625,7 @@ export class LoadFactoryController {
this.$mdDialog.show(
this.$mdDialog.alert()
.title('Error while importing project')
.content(error.statusText + ': ' + error.data.message)
.textContent(error.statusText + ': ' + error.data.message)
.ariaLabel('Import project')
.ok('OK')
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,18 +157,18 @@ export class NavbarDropdownMenu implements ng.IDirective {
delete this.$rootScope.navbarDropdownActiveMenu;
} else {
// open new menu by triggering mouse event
angular.element(nextTargetEl).trigger({
angular.element(nextTargetEl).trigger(angular.element.Event('custom', {
type: eventType,
which: eventWhich
} as JQueryEventObject);
}));
}
} else {
// if menu isn't found
// just trigger same mouse event on first found element
angular.element(nextTargetEl).trigger({
angular.element(nextTargetEl).trigger(angular.element.Event('custom', {
type: eventType,
which: eventWhich
} as JQueryEventObject);
}));
}

// clean pointer events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ describe('OrganizationsConfig >', () => {

// stub functions
const callbacks = {
testResolve: () => { },
testReject: () => { }
testResolve: (...args: any[]) => { },
testReject: (...args: any[]) => { }
};

// create spies
Expand Down Expand Up @@ -160,8 +160,8 @@ describe('OrganizationsConfig >', () => {

// stub functions
const callbacks = {
testResolve: () => { },
testReject: () => { }
testResolve: (...args: any[]) => { },
testReject: (...args: any[]) => { }
};

// create spies
Expand Down Expand Up @@ -198,8 +198,8 @@ describe('OrganizationsConfig >', () => {

// stub functions
const callbacks = {
testResolve: () => { },
testReject: () => { }
testResolve: (...args: any[]) => { },
testReject: (...args: any[]) => { }
};

// create spies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class ImportGithubProjectController {
/**
* Browser service.
*/
private $browser: ng.IBrowserService;
private $browser: any;
/**
* GitHub authentication popup window.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
'use strict';
import {EnvironmentManager} from '../../../../components/api/environment/environment-manager';
import {IEnvironmentManagerMachine} from '../../../../components/api/environment/environment-manager-machine';
import {MemoryUnit} from '../../../../components/filter/change-memory-unit/change-memory-unit.filter';
import {MemoryUnit, IChangeMemoryUnit} from '../../../../components/filter/change-memory-unit/change-memory-unit.filter';

type machine = {
name: string;
Expand Down Expand Up @@ -74,7 +74,7 @@ export class RamSettingsController {
this.machinesList = this.machines.map((machine: IEnvironmentManagerMachine) => {
const source: any = this.environmentManager.getSource(machine),
memoryLimitBytes = this.environmentManager.getMemoryLimit(machine),
memoryLimitGBytesWithUnit = this.$filter('changeMemoryUnit')(memoryLimitBytes, [MemoryUnit[MemoryUnit.B], MemoryUnit[MemoryUnit.GB]]);
memoryLimitGBytesWithUnit = this.$filter<IChangeMemoryUnit>('changeMemoryUnit')(memoryLimitBytes, [MemoryUnit[MemoryUnit.B], MemoryUnit[MemoryUnit.GB]]);
return <machine>{
image: source && source.image ? source.image : '',
name: machine.name,
Expand All @@ -91,7 +91,7 @@ export class RamSettingsController {
* @param {number} memoryLimitGBytes amount of ram in GB
*/
onRamChanged(name: string, memoryLimitGBytes: number): void {
const memoryLimitBytesWithUnit = this.$filter('changeMemoryUnit')(memoryLimitGBytes, [MemoryUnit[MemoryUnit.GB], MemoryUnit[MemoryUnit.B]]);
const memoryLimitBytesWithUnit = this.$filter<IChangeMemoryUnit>('changeMemoryUnit')(memoryLimitGBytes, [MemoryUnit[MemoryUnit.GB], MemoryUnit[MemoryUnit.B]]);
this.onRamChange({name: name, memoryLimitBytes: this.getNumber(memoryLimitBytesWithUnit)});
}

Expand All @@ -107,4 +107,3 @@ export class RamSettingsController {
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Red Hat, Inc. - initial API and implementation
*/
'use strict';
import {MemoryUnit} from '../../../../components/filter/change-memory-unit/change-memory-unit.filter';
import {MemoryUnit, IChangeMemoryUnit} from '../../../../components/filter/change-memory-unit/change-memory-unit.filter';
import {EnvironmentManager} from '../../../../components/api/environment/environment-manager';
import {ConfirmDialogService} from '../../../../components/service/confirm-dialog/confirm-dialog.service';
import {CheEnvironmentRegistry} from '../../../../components/api/environment/che-environment-registry.factory';
Expand Down Expand Up @@ -175,7 +175,7 @@ export class WorkspaceMachinesController {
this.machinesList = this.machines.map((machine: IEnvironmentManagerMachine) => {
const source: {image?: string} = this.environmentManager.getSource(machine);
const memoryLimitBytes = this.environmentManager.getMemoryLimit(machine);
const memoryLimitGBytes = memoryLimitBytes === -1 ? 0 : this.getNumber(this.$filter('changeMemoryUnit')(memoryLimitBytes, [MemoryUnit[MemoryUnit.B], MemoryUnit[MemoryUnit.GB]]));
const memoryLimitGBytes = memoryLimitBytes === -1 ? 0 : this.getNumber(this.$filter<IChangeMemoryUnit>('changeMemoryUnit')(memoryLimitBytes, [MemoryUnit[MemoryUnit.B], MemoryUnit[MemoryUnit.GB]]));
return <machine>{
image: source && source.image ? source.image : '',
name: machine.name,
Expand Down Expand Up @@ -300,9 +300,9 @@ export class WorkspaceMachinesController {
}

const currentMemoryLimitBytes = this.environmentManager.getMemoryLimit(machine);
const currentMemoryLimitGBytes = currentMemoryLimitBytes === -1 ? 0 : this.getNumber(this.$filter('changeMemoryUnit')(currentMemoryLimitBytes, [MemoryUnit[MemoryUnit.B], MemoryUnit[MemoryUnit.GB]]));
const currentMemoryLimitGBytes = currentMemoryLimitBytes === -1 ? 0 : this.getNumber(this.$filter<IChangeMemoryUnit>('changeMemoryUnit')(currentMemoryLimitBytes, [MemoryUnit[MemoryUnit.B], MemoryUnit[MemoryUnit.GB]]));
if (memoryLimitGBytes !== currentMemoryLimitGBytes) {
const memoryLimitBytesWithUnit = this.$filter('changeMemoryUnit')(memoryLimitGBytes, [MemoryUnit[MemoryUnit.GB], MemoryUnit[MemoryUnit.B]]);
const memoryLimitBytesWithUnit = this.$filter<IChangeMemoryUnit>('changeMemoryUnit')(memoryLimitGBytes, [MemoryUnit[MemoryUnit.GB], MemoryUnit[MemoryUnit.B]]);
const memoryLimitBytes = this.getNumber(memoryLimitBytesWithUnit);
this.environmentManager.setMemoryLimit(machine, memoryLimitBytes);
const environment = this.environmentManager.getEnvironment(this.environment, this.machines);
Expand Down
4 changes: 2 additions & 2 deletions dashboard/src/components/api/che-agent.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class CheAgent {
* Fetch the agents.
*/
fetchAgents(): ng.IPromise<che.IAgent[]> {
const defer = this.$q.defer();
const defer = this.$q.defer<che.IAgent[]>();
const promise = this.remoteAgentAPI.getAgents().$promise;

promise.then((agents: che.IAgent[]) => {
Expand Down Expand Up @@ -90,7 +90,7 @@ export class CheAgent {
* @returns {angular.IPromise<che.IAgent>}
*/
fetchAgent(agentId: string): ng.IPromise<che.IAgent> {
let defer = this.$q.defer();
let defer = this.$q.defer<che.IAgent>();
let promise = this.remoteAgentAPI.getAgent({id: agentId}).$promise;
promise.then((agent: any) => {
this.agentsMap.set(agentId, agent);
Expand Down
3 changes: 2 additions & 1 deletion dashboard/src/components/api/devfile-registry.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/
'use strict';
import {CheKeycloak} from './che-keycloak.factory';
import {IChangeMemoryUnit} from '../filter/change-memory-unit/change-memory-unit.filter';

export interface IDevfileMetaData {
displayName: string;
Expand Down Expand Up @@ -66,7 +67,7 @@ export class DevfileRegistry {
if (this.isKeycloackPresent) {
globalMemoryLimitNumber += this.jwtproxyMemoryLimitNumber;
}
devfileMetaData.globalMemoryLimit = this.$filter('changeMemoryUnit')(globalMemoryLimitNumber, ['B','GB']);
devfileMetaData.globalMemoryLimit = this.$filter<IChangeMemoryUnit>('changeMemoryUnit')(globalMemoryLimitNumber, ['B','GB']);
return devfileMetaData;
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ describe('ComposeEnvironmentManager', () => {

// machine's attributes are more preferable than recipe to get memory limit
let expectedMemoryLimit = environment.machines[testMachine.name].attributes.memoryLimitBytes;
expect(memoryLimit.toString()).toEqual(expectedMemoryLimit);
expect(memoryLimit.toString()).toEqual(expectedMemoryLimit.toString());
});

it('from recipe', () => {
Expand Down Expand Up @@ -209,7 +209,7 @@ describe('ComposeEnvironmentManager', () => {
let memoryLimit = envManager.getMemoryLimit(machines[0]);

let expectedMemoryLimit = environment.machines['dev-machine'].attributes.memoryLimitBytes;
expect(memoryLimit.toString()).toEqual(expectedMemoryLimit);
expect(memoryLimit.toString()).toEqual(expectedMemoryLimit.toString());
});

});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('If recipe has content', () => {
let memoryLimit = envManager.getMemoryLimit(machines[0]);

let expectedMemoryLimit = environment.machines['dev-machine'].attributes.memoryLimitBytes;
expect(memoryLimit.toString()).toEqual(expectedMemoryLimit);
expect(memoryLimit.toString()).toEqual(expectedMemoryLimit.toString());
});

it('should return source', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ export class PageObjectResource {
* @returns {ng.IPromise<Array<any>>} the promise
*/
fetchPageObjects(pageKey: string): ng.IPromise<Array<any>> {
let deferred = this.$q.defer();
let deferred = this.$q.defer<any[]>();
let pageNumber;
switch (pageKey) {
case RemotePageLabels.FIRST:
Expand Down
4 changes: 2 additions & 2 deletions dashboard/src/components/api/plugin-registry.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ export class PluginRegistry {
}

fetchPlugins(location: string): ng.IPromise<Array<IPlugin>> {
return this.$http({'method': 'GET', 'url': location + '/plugins/'}).then(result => {
this.plugins.set(location, <Array<IPlugin>>result.data);
return this.$http({'method': 'GET', 'url': location + '/plugins/'}).then((result: ng.IHttpResponse<IPlugin[]>) => {
this.plugins.set(location, result.data);
return this.$q.when(result.data);
}, (error: any) => {
if (error && error.status === 304) {
Expand Down
Loading

0 comments on commit 2181ed1

Please sign in to comment.