Skip to content

Commit

Permalink
[release/v2.13] Add missing checks for AddonConfig existence (#1986)
Browse files Browse the repository at this point in the history
* Add missing checks for AddonConfig existence

* Add few more checks

Co-authored-by: Marcin Maciaszczyk <[email protected]>
  • Loading branch information
kubermatic-bot and Marcin Maciaszczyk authored Feb 6, 2020
1 parent fb8e728 commit 6d3140e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</div>
</div>
<form [formGroup]="form">
<div *ngFor="let control of addonConfig.spec.formSpec">
<div *ngFor="let control of addonConfig?.spec?.formSpec">
<mat-form-field *ngIf="['text', 'number'].includes(control.type)">
<mat-label>{{control.displayName}}{{control.required ? '*' : ''}}</mat-label>
<input matInput
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class InstallAddonDialogComponent implements OnInit {

ngOnInit(): void {
const group = {};
if (this.addonConfig.spec.formSpec) {
if (this.hasForm()) {
this.addonConfig.spec.formSpec.forEach(control => {
group[control.internalName] = new FormControl(
InstallAddonDialogComponent.getFormState(control),
Expand All @@ -40,6 +40,10 @@ export class InstallAddonDialogComponent implements OnInit {
this.form = new FormGroup(group);
}

hasForm(): boolean {
return !!this.addonConfig && !!this.addonConfig.spec && !!this.addonConfig.spec.formSpec;
}

hasLogo(): boolean {
return !!this.addonConfig && !!this.addonConfig.spec.logo && !!this.addonConfig.spec.logoFormat;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class SelectAddonDialogComponent {

hasLogo(name: string): boolean {
const addonConfig = this.addonConfigs.get(name);
return !!addonConfig && !!addonConfig.spec.logo && !!addonConfig.spec.logoFormat;
return !!addonConfig && !!addonConfig.spec && !!addonConfig.spec.logo && !!addonConfig.spec.logoFormat;
}

getAddonLogo(name: string): SafeUrl {
Expand All @@ -32,7 +32,7 @@ export class SelectAddonDialogComponent {

getAddonDescription(name: string): string {
const addonConfig = this.addonConfigs.get(name);
return addonConfig ? addonConfig.spec.description : '';
return addonConfig && addonConfig.spec && addonConfig.spec.description ? addonConfig.spec.description : '';
}

select(name: string): void {
Expand Down

0 comments on commit 6d3140e

Please sign in to comment.