Skip to content

Commit

Permalink
che-7154: Handle the workspace start/stop errors properly
Browse files Browse the repository at this point in the history
Signed-off-by: Anna Shumilova <ashumilo@redhat.com>
  • Loading branch information
ashumilova committed Dec 28, 2017
1 parent 907429e commit c400e3e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ export class WorkspaceStatusController {
this.updateRecentWorkspace(this.workspaceId);
}
this.isRequestPending = true;
this.cheWorkspace.fetchStatusChange(this.workspaceId, 'ERROR').then((data: any) => {
this.cheNotification.showError(data.error);
});

const promise = isRunButton ? this.cheWorkspace.startWorkspace(this.workspaceId, environment) : this.cheWorkspace.stopWorkspace(this.workspaceId);
promise.catch((error: any) => {
this.cheNotification.showError(`${isRunButton ? 'Run' : 'Stop'} workspace error.`, error);
Expand Down
5 changes: 5 additions & 0 deletions dashboard/src/app/workspaces/workspaces-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ import {UserItemController} from './share-workspace/user-item/user-item.controll
import {UserItem} from './share-workspace/user-item/user-item.directive';
import {WorkspaceConfigService} from './workspace-config.service';
import {WorkspaceDetailsConfig} from './workspace-details/workspace-details-config';
import {WorkspaceWarnings} from './workspace-details/warnings/workspace-warnings.directive';
import {WorkspaceWarningsController} from './workspace-details/warnings/workspace-warnings.controller';


/**
Expand Down Expand Up @@ -108,6 +110,8 @@ export class WorkspacesConfig {
register.directive('cheWorkspaceRamAllocationSlider', CheWorkspaceRamAllocationSlider);
register.directive('workspaceStatus', WorkspaceStatus);
register.directive('workspaceStatusIndicator', WorkspaceStatusIndicator);
register.directive('workspaceWarnings', WorkspaceWarnings);
register.controller('WorkspaceWarningsController', WorkspaceWarningsController);
register.controller('StackSelectorController', StackSelectorController);
register.service('stackSelectorSvc', StackSelectorSvc);
register.directive('stackSelector', StackSelector);
Expand Down Expand Up @@ -159,6 +163,7 @@ export class WorkspacesConfig {
register.controller('UserItemController', UserItemController);
register.directive('userItem', UserItem);
register.service('workspaceConfigService', WorkspaceConfigService);

// config routes
register.app.config(($routeProvider: che.route.IRouteProvider) => {
$routeProvider.accessWhen('/workspaces', {
Expand Down
12 changes: 7 additions & 5 deletions dashboard/src/components/api/workspace/che-workspace.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -668,19 +668,21 @@ export class CheWorkspace {
if (this.subscribedWorkspacesIds.indexOf(workspaceId) < 0) {
this.subscribedWorkspacesIds.push(workspaceId);
this.cheJsonRpcMasterApi.subscribeWorkspaceStatus(workspaceId, (message: any) => {
if (this.workspaceStatuses.indexOf(message.status) >= 0) {
this.getWorkspaceById(workspaceId).status = message.status;
let status = message.error ? 'ERROR' : message.status;

if (this.workspaceStatuses.indexOf(status) >= 0) {
this.getWorkspaceById(workspaceId).status = status;
}

if (!this.statusDefers[workspaceId] || !this.statusDefers[workspaceId][message.status]) {
if (!this.statusDefers[workspaceId] || !this.statusDefers[workspaceId][status]) {
return;
}

this.statusDefers[workspaceId][message.status].forEach((defer: any) => {
this.statusDefers[workspaceId][status].forEach((defer: any) => {
defer.resolve(message);
});

this.statusDefers[workspaceId][message.status].length = 0;
this.statusDefers[workspaceId][status].length = 0;
});
}
}
Expand Down
3 changes: 2 additions & 1 deletion dashboard/src/components/typings/che.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ declare namespace che {
updated?: number;
created?: number;
stackId?: string;
errorMessage?: string;
[propName: string]: string | number;
};
config: IWorkspaceConfig;
Expand Down Expand Up @@ -359,7 +360,7 @@ declare namespace che {
}

export interface IWorkspaceWarning {
code: number;
code?: number;
message: string;
}

Expand Down

0 comments on commit c400e3e

Please sign in to comment.