From eaafc764f577c12dc5b7ac3a64fa8b6666592588 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 30 Sep 2021 22:01:16 -0600 Subject: [PATCH] handle possible null case for dep error --- ui/src/app/pages/apps-routes/app-show/app-show.page.ts | 2 +- ui/src/app/services/patch-db/data-model.ts | 2 +- ui/src/app/services/pkg-status-rendering.service.ts | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ui/src/app/pages/apps-routes/app-show/app-show.page.ts b/ui/src/app/pages/apps-routes/app-show/app-show.page.ts index 07b1fdc58..df9435403 100644 --- a/ui/src/app/pages/apps-routes/app-show/app-show.page.ts +++ b/ui/src/app/pages/apps-routes/app-show/app-show.page.ts @@ -207,7 +207,7 @@ export class AppShowPage { let actionText = 'View' let action: () => any = () => this.navCtrl.navigateForward(`/services/${id}`) - const error = this.pkg.installed.status['dependency-errors'][id] || null + const error = this.pkg.installed.status['dependency-errors'][id] if (error) { // health checks failed diff --git a/ui/src/app/services/patch-db/data-model.ts b/ui/src/app/services/patch-db/data-model.ts index 6f352799e..6bda21bc6 100644 --- a/ui/src/app/services/patch-db/data-model.ts +++ b/ui/src/app/services/patch-db/data-model.ts @@ -224,7 +224,7 @@ export interface Action { export interface Status { configured: boolean main: MainStatus - 'dependency-errors': { [id: string]: DependencyError } + 'dependency-errors': { [id: string]: DependencyError | null } } export type MainStatus = MainStatusStopped | MainStatusStopping | MainStatusRunning | MainStatusBackingUp | MainStatusRestoring diff --git a/ui/src/app/services/pkg-status-rendering.service.ts b/ui/src/app/services/pkg-status-rendering.service.ts index ffc6cc307..7267dd439 100644 --- a/ui/src/app/services/pkg-status-rendering.service.ts +++ b/ui/src/app/services/pkg-status-rendering.service.ts @@ -33,15 +33,16 @@ function getDependencyStatus (pkg: PackageDataEntry): DependencyStatus { const installed = pkg.installed if (isEmptyObject(installed['current-dependencies'])) return null - const pkgIds = Object.keys(installed.status['dependency-errors']) + const depErrors = installed.status['dependency-errors'] + const depIds = Object.keys(depErrors).filter(key => !!depErrors[key]) - for (let pkgId of pkgIds) { + for (let pkgId of depIds) { if (pkg.manifest.dependencies[pkgId].critical) { return DependencyStatus.Critical } } - return pkgIds.length ? DependencyStatus.Issue : DependencyStatus.Satisfied + return depIds.length ? DependencyStatus.Issue : DependencyStatus.Satisfied } function getHealthStatus (status: Status): HealthStatus {