Skip to content

Commit 3047dae

Browse files
authored
Action Request updates + misc fixes (#2818)
* fix web manifest format error * fix setting optional dependencies * rework dependency actions to be nested * fix styling * fix styles * combine action requests into same component * only display actions header if they exist * fix storing polyfill dependencies * fix styling and button propagation * fixes for setting polyfill dependencies * revert to test * revert required deps setting logic * add logs and adjust logic * test * fix deps logic when changing config * remove logs; deps working as expected
1 parent 4e22f13 commit 3047dae

14 files changed

+326
-137
lines changed

container-runtime/package-lock.json

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

container-runtime/src/Adapters/Systems/SystemForEmbassy/index.ts

+29-29
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ function todo(): never {
5151
const MANIFEST_LOCATION = "/usr/lib/startos/package/embassyManifest.json"
5252
export const EMBASSY_JS_LOCATION = "/usr/lib/startos/package/embassy.js"
5353
const EMBASSY_POINTER_PATH_PREFIX = "/embassyConfig" as utils.StorePath
54+
const EMBASSY_DEPENDS_ON_PATH_PREFIX = "/embassyDependsOn" as utils.StorePath
5455

5556
const matchResult = object({
5657
result: any,
@@ -314,7 +315,7 @@ export class SystemForEmbassy implements System {
314315
)
315316
.catch(() => []),
316317
)
317-
await this.setDependencies(effects, oldDeps)
318+
await this.setDependencies(effects, oldDeps, false)
318319
}
319320

320321
async exit(): Promise<void> {
@@ -664,7 +665,7 @@ export class SystemForEmbassy implements System {
664665
),
665666
)
666667
const dependsOn = answer["depends-on"] ?? answer.dependsOn ?? {}
667-
await this.setDependencies(effects, dependsOn)
668+
await this.setDependencies(effects, dependsOn, true)
668669
return
669670
} else if (setConfigValue.type === "script") {
670671
const moduleCode = await this.moduleCode
@@ -687,48 +688,47 @@ export class SystemForEmbassy implements System {
687688
}),
688689
)
689690
const dependsOn = answer["depends-on"] ?? answer.dependsOn ?? {}
690-
await this.setDependencies(effects, dependsOn)
691+
await this.setDependencies(effects, dependsOn, true)
691692
return
692693
}
693694
}
694695
private async setDependencies(
695696
effects: Effects,
696697
rawDepends: { [x: string]: readonly string[] },
698+
configuring: boolean,
697699
) {
698-
const dependsOn: Record<string, readonly string[] | null> = {
700+
const storedDependsOn = (await effects.store.get({
701+
packageId: this.manifest.id,
702+
path: EMBASSY_DEPENDS_ON_PATH_PREFIX,
703+
})) as Record<string, readonly string[]>
704+
705+
const requiredDeps = {
699706
...Object.fromEntries(
700-
Object.entries(this.manifest.dependencies || {})?.map((x) => [
701-
x[0],
702-
null,
703-
]) || [],
707+
Object.entries(this.manifest.dependencies || {})
708+
?.filter((x) => x[1].requirement.type === "required")
709+
.map((x) => [x[0], []]) || [],
704710
),
705-
...rawDepends,
706711
}
712+
713+
const dependsOn: Record<string, readonly string[]> = configuring
714+
? {
715+
...requiredDeps,
716+
...rawDepends,
717+
}
718+
: storedDependsOn
719+
? storedDependsOn
720+
: requiredDeps
721+
722+
await effects.store.set({
723+
path: EMBASSY_DEPENDS_ON_PATH_PREFIX,
724+
value: dependsOn,
725+
})
726+
707727
await effects.setDependencies({
708728
dependencies: Object.entries(dependsOn).flatMap(
709729
([key, value]): T.Dependencies => {
710730
const dependency = this.manifest.dependencies?.[key]
711731
if (!dependency) return []
712-
if (value == null) {
713-
const versionRange = dependency.version
714-
if (dependency.requirement.type === "required") {
715-
return [
716-
{
717-
id: key,
718-
versionRange,
719-
kind: "running",
720-
healthChecks: [],
721-
},
722-
]
723-
}
724-
return [
725-
{
726-
kind: "exists",
727-
id: key,
728-
versionRange,
729-
},
730-
]
731-
}
732732
const versionRange = dependency.version
733733
const kind = "running"
734734
return [

container-runtime/src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ new RpcListener(getDependencies)
1111

1212
/**
1313
14-
So, this is going to be sent into a running comtainer along with any of the other node modules that are going to be needed and used.
14+
So, this is going to be sent into a running container along with any of the other node modules that are going to be needed and used.
1515
1616
Once the container is started, we will go into a loading/ await state.
1717
This is the init system, and it will always be running, and it will be waiting for a command to be sent to it.
@@ -38,5 +38,5 @@ There are
3838

3939
/**
4040
TODO:
41-
Should I seperate those adapter in/out?
41+
Should I separate those adapter in/out?
4242
*/

web/projects/ui/src/app/pages/apps-routes/app-show/app-show.page.html

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
<app-show-dependencies
3636
*ngIf="pkgPlus.dependencies.length"
3737
[dependencies]="pkgPlus.dependencies"
38+
[allPkgs]="pkgPlus.allPkgs"
39+
[pkg]="pkg"
40+
[manifest]="pkgPlus.manifest"
3841
></app-show-dependencies>
3942
<!-- ** menu ** -->
4043
<app-show-menu [buttons]="pkg | toButtons"></app-show-menu>

web/projects/ui/src/app/pages/apps-routes/app-show/app-show.page.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export class AppShowPage {
143143
fixText = 'Update'
144144
fixAction = () => this.installDep(pkg, manifest, depId)
145145
} else if (depError.type === 'actionRequired') {
146-
errorText = 'Action Required (see above)'
146+
errorText = 'Action Required (see below)'
147147
} else if (depError.type === 'notRunning') {
148148
errorText = 'Not running'
149149
fixText = 'Start'
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,42 @@
1-
<ng-container *ngIf="actionRequests.critical.length">
2-
<ion-item-divider>Required Actions</ion-item-divider>
3-
<ion-item
4-
*ngFor="let request of actionRequests.critical"
5-
button
6-
(click)="handleAction(request)"
1+
<ng-container *ngIf="actionRequests[pkgId]?.length">
2+
<ion-item-divider
3+
*ngIf="!dep"
4+
style="--background: unset; z-index: 11; position: relative"
75
>
8-
<ion-icon slot="start" name="warning-outline" color="warning"></ion-icon>
9-
<ion-label>
10-
<h2 class="highlighted">{{ request.actionName }}</h2>
11-
<p *ngIf="request.dependency" class="dependency">
12-
<span class="light">Service:</span>
13-
<img [src]="request.dependency.icon" alt="" />
14-
{{ request.dependency.title }}
15-
</p>
16-
<p>
17-
<span class="light">Reason:</span>
18-
{{ request.reason || 'no reason provided' }}
19-
</p>
20-
</ion-label>
21-
</ion-item>
22-
</ng-container>
23-
24-
<ng-container *ngIf="actionRequests.important.length">
25-
<ion-item-divider>Requested Actions</ion-item-divider>
26-
<ion-item
27-
*ngFor="let request of actionRequests.important"
28-
button
29-
(click)="handleAction(request)"
30-
>
31-
<ion-icon slot="start" name="play-outline" color="warning"></ion-icon>
32-
<ion-label>
33-
<h2 class="highlighted">{{ request.actionName }}</h2>
34-
<p *ngIf="request.dependency" class="dependency">
35-
<span class="light">Service:</span>
36-
<img [src]="request.dependency.icon" alt="" />
37-
{{ request.dependency.title }}
38-
</p>
39-
<p>
40-
<span class="light">Reason:</span>
41-
{{ request.reason || 'no reason provided' }}
42-
</p>
43-
</ion-label>
44-
</ion-item>
6+
Action Requests
7+
</ion-item-divider>
8+
<div class="indent">
9+
<ion-item
10+
class="line"
11+
lines="none"
12+
*ngFor="let request of actionRequests[pkgId]"
13+
button
14+
(click)="handleAction(request, $event)"
15+
>
16+
<ion-icon
17+
slot="start"
18+
[name]="
19+
request.severity === 'critical' ? 'warning-outline' : 'play-outline'
20+
"
21+
[color]="request.severity === 'critical' ? 'warning' : 'dark'"
22+
></ion-icon>
23+
<ion-label>
24+
<h2 class="highlighted">{{ request.actionName }}</h2>
25+
<p>
26+
{{ request.reason || 'no reason provided' }} |
27+
<span
28+
class="severity"
29+
[ngStyle]="{
30+
color:
31+
request.severity === 'critical'
32+
? 'var(--ion-color-warning)'
33+
: 'var(--ion-color-dark)'
34+
}"
35+
>
36+
{{ request.severity === 'critical' ? 'Required' : 'Requested' }}
37+
</span>
38+
</p>
39+
</ion-label>
40+
</ion-item>
41+
</div>
4542
</ng-container>
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,39 @@
1-
.light {
2-
color: var(--ion-color-dark);
1+
ion-icon {
2+
margin-right: 32px;
33
}
44

55
.highlighted {
66
color: var(--ion-color-dark);
77
font-weight: bold;
88
}
99

10-
.dependency {
11-
display: inline-flex;
12-
img {
13-
max-width: 16px;
14-
margin: 0 2px 0 5px;
10+
.severity {
11+
font-variant-caps: all-small-caps;
12+
font-weight: bold;
13+
letter-spacing: 0.2px;
14+
font-size: 16px;
15+
}
16+
17+
.line {
18+
19+
&:after {
20+
content: '';
21+
display: block;
22+
border-left: 1px solid var(--border-color);
23+
border-bottom: 1px solid var(--border-color);
24+
height: 100%;
25+
width: 24px;
26+
position: absolute;
27+
left: -20px;
28+
top: -33px;
1529
}
30+
}
31+
32+
.indent {
33+
margin-left: 41px
34+
}
35+
36+
:host ::ng-deep ion-item {
37+
display: table-row;
38+
width: fit-content;
1639
}

web/projects/ui/src/app/pages/apps-routes/app-show/components/app-show-action-requests/app-show-action-requests.component.ts

+21-24
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ChangeDetectionStrategy, Component, Input } from '@angular/core'
22
import { T } from '@start9labs/start-sdk'
33
import { ActionService } from 'src/app/services/action.service'
4+
import { DependencyInfo } from 'src/app/pages/apps-routes/app-show/app-show.page'
45
import { getDepDetails } from 'src/app/util/dep-info'
56

67
@Component({
@@ -19,22 +20,21 @@ export class AppShowActionRequestsComponent {
1920
@Input()
2021
manifest!: T.Manifest
2122

22-
get actionRequests() {
23-
const critical: (T.ActionRequest & {
24-
actionName: string
25-
dependency: {
26-
title: string
27-
icon: string
28-
} | null
29-
})[] = []
30-
const important: (T.ActionRequest & {
31-
actionName: string
32-
dependency: {
33-
title: string
34-
icon: string
35-
} | null
36-
})[] = []
23+
@Input()
24+
dep?: DependencyInfo
25+
26+
pkgId!: string
27+
28+
ngOnInit() {
29+
this.pkgId = this.dep ? this.dep?.id : this.manifest.id
30+
}
3731

32+
get actionRequests() {
33+
const reqs: {
34+
[key: string]: (T.ActionRequest & {
35+
actionName: string
36+
})[]
37+
} = {}
3838
Object.values(this.pkg.requestedActions)
3939
.filter(r => r.active)
4040
.forEach(r => {
@@ -49,20 +49,17 @@ export class AppShowActionRequestsComponent {
4949
? null
5050
: getDepDetails(this.pkg, this.allPkgs, r.request.packageId),
5151
}
52-
53-
if (r.request.severity === 'critical') {
54-
critical.push(toReturn)
55-
} else {
56-
important.push(toReturn)
52+
if (!reqs[r.request.packageId]) {
53+
reqs[r.request.packageId] = []
5754
}
55+
reqs[r.request.packageId].push(toReturn)
5856
})
59-
60-
return { critical, important }
57+
return reqs
6158
}
62-
6359
constructor(private readonly actionService: ActionService) {}
6460

65-
async handleAction(request: T.ActionRequest) {
61+
async handleAction(request: T.ActionRequest, e: Event) {
62+
e.stopPropagation()
6663
const self = request.packageId === this.manifest.id
6764
this.actionService.present({
6865
pkgInfo: {

0 commit comments

Comments
 (0)