Skip to content

Commit

Permalink
fix(core): fix NPE in getBaseOsDescription (#8099)
Browse files Browse the repository at this point in the history
  • Loading branch information
maggieneterval committed Mar 26, 2020
1 parent 43c8075 commit e948f29
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { IController, IComponentOptions, module } from 'angular';
import { isEmpty } from 'lodash';

export interface IBaseOsOption {
id: string;
Expand All @@ -21,8 +20,11 @@ export class BakeStageChooseOSController implements IController {
}

public getBaseOsDescription(baseOsOption: IBaseOsOption): string {
const baseOsName = isEmpty(baseOsOption.displayName) ? baseOsOption.id : baseOsOption.displayName;
return baseOsName + (baseOsOption.shortDescription ? ' (' + baseOsOption.shortDescription + ')' : '');
const baseOsName = baseOsOption?.displayName || baseOsOption?.id || '';
if (baseOsOption?.shortDescription) {
return `${baseOsName} (${baseOsOption.shortDescription})`;
}
return baseOsName;
}
public getBaseOsDetailedDescription(baseOsOption: IBaseOsOption): string {
return baseOsOption.detailedDescription + (baseOsOption.isImageFamily ? ' (family)' : '');
Expand Down

0 comments on commit e948f29

Please sign in to comment.