From b6e25cc6ff2f7655a42e977dd1525970cf1b3f8c Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 23 Sep 2021 20:34:11 -0600 Subject: [PATCH] make needs config a primary status --- .../apps-routes/app-list/app-list.page.ts | 2 +- .../services/pkg-status-rendering.service.ts | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/ui/src/app/pages/apps-routes/app-list/app-list.page.ts b/ui/src/app/pages/apps-routes/app-list/app-list.page.ts index 90d848537..daea2d6fe 100644 --- a/ui/src/app/pages/apps-routes/app-list/app-list.page.ts +++ b/ui/src/app/pages/apps-routes/app-list/app-list.page.ts @@ -71,7 +71,7 @@ export class AppListPage { this.pkgs[id].entry = pkg this.pkgs[id].installProgress = !isEmptyObject(pkg['install-progress']) ? this.installPackageService.transform(pkg['install-progress']) : undefined this.pkgs[id].primaryRendering = primaryRendering - this.pkgs[id].error = [HealthStatus.NeedsConfig, HealthStatus.Failure].includes(statuses.health) || [DependencyStatus.Issue, DependencyStatus.Critical].includes(statuses.dependency) + this.pkgs[id].error = statuses.health === HealthStatus.Failure || [DependencyStatus.Issue, DependencyStatus.Critical].includes(statuses.dependency) }) }) }), diff --git a/ui/src/app/services/pkg-status-rendering.service.ts b/ui/src/app/services/pkg-status-rendering.service.ts index 2be75cd36..ffc6cc307 100644 --- a/ui/src/app/services/pkg-status-rendering.service.ts +++ b/ui/src/app/services/pkg-status-rendering.service.ts @@ -11,7 +11,7 @@ export function renderPkgStatus (pkg: PackageDataEntry): { let health: HealthStatus | null = null if (pkg.state === PackageState.Installed) { - primary = pkg.installed.status.main.status as string as PrimaryStatus + primary = getPrimaryStatus(pkg.installed.status) dependency = getDependencyStatus(pkg) health = getHealthStatus(pkg.installed.status) } else { @@ -21,6 +21,14 @@ export function renderPkgStatus (pkg: PackageDataEntry): { return { primary, dependency, health } } +function getPrimaryStatus (status: Status): PrimaryStatus { + if (!status.configured) { + return PrimaryStatus.NeedsConfig + } else { + return status.main.status as any as PrimaryStatus + } +} + function getDependencyStatus (pkg: PackageDataEntry): DependencyStatus { const installed = pkg.installed if (isEmptyObject(installed['current-dependencies'])) return null @@ -37,10 +45,6 @@ function getDependencyStatus (pkg: PackageDataEntry): DependencyStatus { } function getHealthStatus (status: Status): HealthStatus { - if (!status.configured) { - return HealthStatus.NeedsConfig - } - if (status.main.status === PackageMainStatus.Running) { const values = Object.values(status.main.health) if (values.some(h => h.result === 'failure')) { @@ -72,6 +76,8 @@ export enum PrimaryStatus { Stopped = 'stopped', BackingUp = 'backing-up', Restoring = 'restoring', + // config + NeedsConfig = 'needs-config', } export enum DependencyStatus { @@ -81,7 +87,6 @@ export enum DependencyStatus { } export enum HealthStatus { - NeedsConfig = 'needs-config', Failure = 'failure', Starting = 'starting', Loading = 'loading', @@ -97,6 +102,7 @@ export const PrimaryRendering: { [key: string]: StatusRendering } = { [PrimaryStatus.BackingUp]: { display: 'Backing Up', color: 'primary', showDots: true }, [PrimaryStatus.Restoring]: { display: 'Restoring', color: 'primary', showDots: true }, [PrimaryStatus.Running]: { display: 'Running', color: 'success', showDots: false }, + [PrimaryStatus.NeedsConfig]: { display: 'Needs Config', color: 'warning' }, } export const DependencyRendering: { [key: string]: StatusRendering } = { @@ -106,7 +112,6 @@ export const DependencyRendering: { [key: string]: StatusRendering } = { } export const HealthRendering: { [key: string]: StatusRendering } = { - [HealthStatus.NeedsConfig]: { display: 'Needs Config', color: 'warning' }, [HealthStatus.Failure]: { display: 'Failure', color: 'danger' }, [HealthStatus.Starting]: { display: 'Starting', color: 'primary' }, [HealthStatus.Loading]: { display: 'Loading', color: 'primary' },