severity enum

This commit is contained in:
Drew Ansbacher
2021-11-26 10:52:07 -07:00
committed by Aiden McClelland
parent 5bda871e00
commit 557c81f41c
5 changed files with 31 additions and 13 deletions

View File

@@ -222,7 +222,7 @@ export class AppListPage {
pkgInfo.entry = update
pkgInfo.installProgress = !isEmptyObject(update['install-progress']) ? this.pkgLoading.transform(update['install-progress']) : undefined
pkgInfo.primaryRendering = primaryRendering
pkgInfo.error = statuses.health === HealthStatus.Failure || [DependencyStatus.Issue, DependencyStatus.Critical].includes(statuses.dependency)
pkgInfo.error = statuses.health === HealthStatus.Failure || [DependencyStatus.Warning, DependencyStatus.Critical].includes(statuses.dependency)
})
return pkgInfo
}

View File

@@ -8,7 +8,7 @@ import { wizardModal } from 'src/app/components/install-wizard/install-wizard.co
import { WizardBaker } from 'src/app/components/install-wizard/prebaked-wizards'
import { ConfigService } from 'src/app/services/config.service'
import { PatchDbService } from 'src/app/services/patch-db/patch-db.service'
import { DependencyError, DependencyErrorType, HealthCheckResult, HealthResult, PackageDataEntry, PackageMainStatus, PackageState } from 'src/app/services/patch-db/data-model'
import { DependencyError, DependencyErrorType, DependencySeverity, HealthCheckResult, HealthResult, PackageDataEntry, PackageMainStatus, PackageState } from 'src/app/services/patch-db/data-model'
import { DependencyStatus, HealthStatus, PrimaryRendering, PrimaryStatus, renderPkgStatus } from 'src/app/services/pkg-status-rendering.service'
import { ConnectionFailure, ConnectionService } from 'src/app/services/connection.service'
import { ErrorToastService } from 'src/app/services/error-toast.service'
@@ -266,6 +266,14 @@ export class AppShowPage {
}
}
if (errorText) {
if (this.pkg.manifest.dependencies[id].severity === DependencySeverity.Critical) {
errorText = `Critical: ${errorText}. Running ${this.pkg.manifest.title} will cause harm to your system.`
} else if (this.pkg.manifest.dependencies[id].severity === DependencySeverity.Warning) {
errorText = `${errorText}. ${this.pkg.manifest.title} will not work as expected.`
}
}
const depInfo = this.pkg.installed['dependency-info'][id]
return {

View File

@@ -1,4 +1,4 @@
import { DependencyErrorType, DockerIoFormat, Manifest, PackageDataEntry, PackageMainStatus, PackageState } from 'src/app/services/patch-db/data-model'
import { DependencyErrorType, DependencySeverity, DockerIoFormat, Manifest, PackageDataEntry, PackageMainStatus, PackageState } from 'src/app/services/patch-db/data-model'
import { Log, MarketplacePkg, Metric, NotificationLevel, RR, ServerNotifications } from './api.types'
import { Operation } from 'fast-json-patch'
@@ -458,7 +458,7 @@ export module Mock {
'how': 'You can use an external node from your Embassy if you prefer.',
},
'config': null,
'critical': true,
'severity': DependencySeverity.Critical,
},
'btc-rpc-proxy': {
'version': '>=0.2.2',
@@ -468,7 +468,7 @@ export module Mock {
'how': 'To use Proxy\'s user management system, go to LND config and select Bitcoin Proxy under Bitcoin config.',
},
'config': null,
'critical': true,
'severity': DependencySeverity.Critical,
},
},
}
@@ -561,7 +561,7 @@ export module Mock {
requirement: {
type: 'required',
},
critical: false,
severity: DependencySeverity.Warning,
config: {
check: {
type: 'docker',

View File

@@ -121,7 +121,7 @@ export interface Manifest {
stop: string | null
}
main: ActionImpl
'health-checks': { [id: string]: ActionImpl & { critical: boolean } }
'health-checks': { [id: string]: ActionImpl & { severity: HealthCheckSeverity } }
config: ConfigActions | null
volumes: { [id: string]: Volume }
'min-os-version': string
@@ -366,11 +366,21 @@ export interface DependencyEntry {
type: 'required'
}
description: string | null
critical: boolean,
severity: DependencySeverity,
config: {
check: ActionImpl,
'auto-configure': ActionImpl
}
}
export enum HealthCheckSeverity {
Critical = 'critical',
Warning = 'warning',
}
export enum DependencySeverity {
Critical = 'critical',
Warning = 'warning',
}
export type URL = string

View File

@@ -1,5 +1,5 @@
import { isEmptyObject } from '../util/misc.util'
import { PackageDataEntry, PackageMainStatus, PackageState, Status } from './patch-db/data-model'
import { DependencySeverity, PackageDataEntry, PackageMainStatus, PackageState, Status } from './patch-db/data-model'
export function renderPkgStatus (pkg: PackageDataEntry): {
primary: PrimaryStatus,
@@ -37,12 +37,12 @@ function getDependencyStatus (pkg: PackageDataEntry): DependencyStatus {
const depIds = Object.keys(depErrors).filter(key => !!depErrors[key])
for (let pkgId of depIds) {
if (pkg.manifest.dependencies[pkgId].critical) {
if (pkg.manifest.dependencies[pkgId].severity === DependencySeverity.Critical) {
return DependencyStatus.Critical
}
}
return depIds.length ? DependencyStatus.Issue : DependencyStatus.Satisfied
return depIds.length ? DependencyStatus.Warning : DependencyStatus.Satisfied
}
function getHealthStatus (status: Status): HealthStatus {
@@ -83,7 +83,7 @@ export enum PrimaryStatus {
}
export enum DependencyStatus {
Issue = 'issue',
Warning = 'warning',
Critical = 'critical',
Satisfied = 'satisfied',
}
@@ -109,7 +109,7 @@ export const PrimaryRendering: { [key: string]: StatusRendering } = {
}
export const DependencyRendering: { [key: string]: StatusRendering } = {
[DependencyStatus.Issue]: { display: 'Issue', color: 'warning' },
[DependencyStatus.Warning]: { display: 'Issue', color: 'warning' },
[DependencyStatus.Critical]: { display: 'Critical Issue', color: 'danger' },
[DependencyStatus.Satisfied]: { display: 'Satisfied', color: 'success' },
}