Skip to content

Commit

Permalink
Merge branch 'refactor/properties' of github.com:Start9Labs/start-os …
Browse files Browse the repository at this point in the history
…into refactor/properties
  • Loading branch information
dr-bonez committed Oct 16, 2024
2 parents 8a7f8d5 + bb0eb8f commit 92d063a
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 65 deletions.
10 changes: 5 additions & 5 deletions web/projects/ui/src/app/modals/action-input.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ import * as json from 'fast-json-patch'
import { ActionService } from '../services/action.service'
import { ActionButton, FormComponent } from '../components/form.component'

export interface PackageActionData {
readonly pkgInfo: {
export type PackageActionData = {
pkgInfo: {
id: string
title: string
icon: string
mainStatus: T.MainStatus['main']
}
readonly actionInfo: {
actionInfo: {
id: string
metadata: T.ActionMetadata
}
readonly requestInfo?: {
requestInfo?: {
dependentId?: string
request: T.ActionRequest
}
Expand Down Expand Up @@ -151,7 +151,7 @@ export class ActionInputModal {
? compare(
JSON.parse(JSON.stringify(originalValue)),
utils.deepMerge(
originalValue,
JSON.parse(JSON.stringify(originalValue)),
this.requestInfo.request.input.value,
) as object,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
isUpdating,
} from 'src/app/util/get-package-data'
import { T } from '@start9labs/start-sdk'
import { getDepDetails } from 'src/app/util/dep-info'

export interface DependencyInfo {
id: string
Expand Down Expand Up @@ -93,32 +94,6 @@ export class AppShowPage {
)
}

private getDepDetails(
pkg: PackageDataEntry,
allPkgs: AllPackageData,
depId: string,
) {
const { title, icon, versionRange } = pkg.currentDependencies[depId]

if (
allPkgs[depId] &&
(allPkgs[depId].stateInfo.state === 'installed' ||
allPkgs[depId].stateInfo.state === 'updating')
) {
return {
title: allPkgs[depId].stateInfo.manifest!.title,
icon: allPkgs[depId].icon,
versionRange,
}
} else {
return {
title: title || depId,
icon: icon || 'assets/img/service-icons/fallback.png',
versionRange,
}
}
}

private getDepValues(
pkg: PackageDataEntry,
allPkgs: AllPackageData,
Expand All @@ -133,11 +108,7 @@ export class AppShowPage {
depErrors,
)

const { title, icon, versionRange } = this.getDepDetails(
pkg,
allPkgs,
depId,
)
const { title, icon, versionRange } = getDepDetails(pkg, allPkgs, depId)

return {
id: depId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
>
<ion-icon slot="start" name="warning-outline" color="warning"></ion-icon>
<ion-label>
<h2 class="highlighted">{{ request.name }}</h2>
<h2 class="highlighted">{{ request.actionName }}</h2>
<p *ngIf="request.dependency" class="dependency">
<span class="light">Service:</span>
<img [src]="request.dependency.icon" alt="" />
{{ request.dependency.name }}
{{ request.dependency.title }}
</p>
<p>
<span class="light">Reason:</span>
Expand All @@ -30,11 +30,11 @@ <h2 class="highlighted">{{ request.name }}</h2>
>
<ion-icon slot="start" name="play-outline" color="warning"></ion-icon>
<ion-label>
<h2 class="highlighted">{{ request.name }}</h2>
<h2 class="highlighted">{{ request.actionName }}</h2>
<p *ngIf="request.dependency" class="dependency">
<span class="light">Service:</span>
<img [src]="request.dependency.icon" alt="" />
{{ request.dependency.name }}
{{ request.dependency.title }}
</p>
<p>
<span class="light">Reason:</span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core'
import { T } from '@start9labs/start-sdk'
import { ActionService } from 'src/app/services/action.service'
import { getDepDetails } from 'src/app/util/dep-info'

@Component({
selector: 'app-show-action-requests',
Expand All @@ -20,16 +21,16 @@ export class AppShowActionRequestsComponent {

get actionRequests() {
const critical: (T.ActionRequest & {
name: string
actionName: string
dependency: {
name: string
title: string
icon: string
} | null
})[] = []
const important: (T.ActionRequest & {
name: string
actionName: string
dependency: {
name: string
title: string
icon: string
} | null
})[] = []
Expand All @@ -40,19 +41,13 @@ export class AppShowActionRequestsComponent {
const self = r.request.packageId === this.manifest.id
const toReturn = {
...r.request,
name: self
actionName: self
? this.pkg.actions[r.request.actionId].name
: this.allPkgs[r.request.packageId]?.actions[r.request.actionId]
.name,
.name || 'Unknown Action',
dependency: self
? null
: {
name:
this.pkg.currentDependencies[r.request.packageId]?.title ||
r.request.packageId,
icon:
this.pkg.currentDependencies[r.request.packageId]?.icon || '',
},
: getDepDetails(this.pkg, this.allPkgs, r.request.packageId),
}

if (r.request.severity === 'critical') {
Expand All @@ -74,14 +69,13 @@ export class AppShowActionRequestsComponent {
id: request.packageId,
title: self
? this.manifest.title
: this.pkg.currentDependencies[request.packageId].title ||
request.packageId,
: getDepDetails(this.pkg, this.allPkgs, request.packageId).title,
mainStatus: self
? this.pkg.status.main
: this.allPkgs[request.packageId].status.main,
icon: self
? this.pkg.icon
: this.pkg.currentDependencies[request.packageId].icon || '',
: getDepDetails(this.pkg, this.allPkgs, request.packageId).icon,
},
actionInfo: {
id: request.actionId,
Expand Down
8 changes: 2 additions & 6 deletions web/projects/ui/src/app/services/api/api.fixures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ import { configBuilderToSpec } from 'src/app/util/configBuilderToSpec'
import { T, ISB, IST } from '@start9labs/start-sdk'
import { GetPackagesRes } from '@start9labs/marketplace'

const mockBlake3Commitment: T.Blake3Commitment = {
hash: 'fakehash',
size: 0,
}

const mockMerkleArchiveCommitment: T.MerkleArchiveCommitment = {
rootSighash: 'fakehash',
rootMaxsize: 0,
Expand Down Expand Up @@ -2023,7 +2018,7 @@ export module Mock {
registry: 'https://registry.start9.com/',
developerKey: 'developer-key',
requestedActions: {
'bitcoind-config': {
'bitcoind/config': {
active: true,
request: {
packageId: 'bitcoind',
Expand All @@ -2037,6 +2032,7 @@ export module Mock {
rpcsettings: {
rpcuser: 'lnd',
},
testnet: false,
},
},
},
Expand Down
6 changes: 3 additions & 3 deletions web/projects/ui/src/app/services/api/mock-patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const mockPatchData: DataModel = {
// password is asdfasdf
passwordHash:
'$argon2d$v=19$m=1024,t=1,p=1$YXNkZmFzZGZhc2RmYXNkZg$Ceev1I901G6UwU+hY0sHrFZ56D+o+LNJ',
versionCompat: '>=0.3.0 <=0.3.6',
eosVersionCompat: '>=0.3.0 <=0.3.6',
statusInfo: {
backupProgress: null,
updated: false,
Expand All @@ -82,7 +82,6 @@ export const mockPatchData: DataModel = {
selected: null,
lastRegion: null,
},
postInitMigrationTodos: [],
},
packageData: {
bitcoind: {
Expand Down Expand Up @@ -404,7 +403,7 @@ export const mockPatchData: DataModel = {
registry: 'https://registry.start9.com/',
developerKey: 'developer-key',
requestedActions: {
'bitcoind-config': {
'bitcoind/config': {
active: true,
request: {
packageId: 'bitcoind',
Expand All @@ -418,6 +417,7 @@ export const mockPatchData: DataModel = {
rpcsettings: {
rpcuser: 'lnd',
},
testnet: false,
},
},
},
Expand Down
30 changes: 30 additions & 0 deletions web/projects/ui/src/app/util/dep-info.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {
AllPackageData,
PackageDataEntry,
} from 'src/app/services/patch-db/data-model'

export function getDepDetails(
pkg: PackageDataEntry,
allPkgs: AllPackageData,
depId: string,
) {
const { title, icon, versionRange } = pkg.currentDependencies[depId]

if (
allPkgs[depId] &&
(allPkgs[depId].stateInfo.state === 'installed' ||
allPkgs[depId].stateInfo.state === 'updating')
) {
return {
title: allPkgs[depId].stateInfo.manifest!.title,
icon: allPkgs[depId].icon,
versionRange,
}
} else {
return {
title: title || depId,
icon: icon || 'assets/img/service-icons/fallback.png',
versionRange,
}
}
}

0 comments on commit 92d063a

Please sign in to comment.