Files
start-os/web/projects/ui/src/app/util/get-package-info.ts
Matt Hill 86567e7fa5 rename frontend to web and update contributing guide (#2509)
* rename frontend to web and update contributing guide

* rename this time

* fix build

* restructure rust code

* update documentation

* update descriptions

* Update CONTRIBUTING.md

Co-authored-by: J H <2364004+Blu-J@users.noreply.github.com>

---------

Co-authored-by: Aiden McClelland <me@drbonez.dev>
Co-authored-by: Aiden McClelland <3732071+dr-bonez@users.noreply.github.com>
Co-authored-by: J H <2364004+Blu-J@users.noreply.github.com>
2023-11-13 21:22:23 +00:00

49 lines
1.4 KiB
TypeScript

import { PackageDataEntry } from '../services/patch-db/data-model'
import {
DependencyStatus,
HealthStatus,
PrimaryRendering,
PrimaryStatus,
renderPkgStatus,
StatusRendering,
} from '../services/pkg-status-rendering.service'
import { ProgressData } from 'src/app/types/progress-data'
import { Subscription } from 'rxjs'
import { packageLoadingProgress } from './package-loading-progress'
import { PkgDependencyErrors } from '../services/dep-error.service'
export function getPackageInfo(
entry: PackageDataEntry,
depErrors: PkgDependencyErrors,
): PkgInfo {
const statuses = renderPkgStatus(entry, depErrors)
const primaryRendering = PrimaryRendering[statuses.primary]
return {
entry,
primaryRendering,
primaryStatus: statuses.primary,
installProgress: packageLoadingProgress(entry['install-progress']),
error:
statuses.health === HealthStatus.Failure ||
statuses.dependency === DependencyStatus.Warning,
warning: statuses.primary === PrimaryStatus.NeedsConfig,
transitioning:
primaryRendering.showDots ||
statuses.health === HealthStatus.Waiting ||
statuses.health === HealthStatus.Loading ||
statuses.health === HealthStatus.Starting,
}
}
export interface PkgInfo {
entry: PackageDataEntry
primaryRendering: StatusRendering
primaryStatus: PrimaryStatus
installProgress: ProgressData | null
error: boolean
warning: boolean
transitioning: boolean
sub?: Subscription | null
}