* fix html displaying in marketplace banner description

* always bold install risk copy

* display correct pkg in marketplace when diff registry, copy changes

Co-authored-by: Matt Hill <matthewonthemoon@gmail.com>
Co-authored-by: Matt Hill <MattDHill@users.noreply.github.com>
This commit is contained in:
Lucy C
2022-12-02 23:20:01 -07:00
committed by GitHub
parent 1d6c61cc5b
commit bd5668d15d
9 changed files with 78 additions and 76 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "@start9labs/marketplace", "name": "@start9labs/marketplace",
"version": "0.3.7", "version": "0.3.8",
"peerDependencies": { "peerDependencies": {
"@angular/common": ">=13.2.0", "@angular/common": ">=13.2.0",
"@angular/core": ">=13.2.0", "@angular/core": ">=13.2.0",

View File

@@ -8,13 +8,13 @@ export abstract class AbstractMarketplaceService {
abstract getMarketplace$(): Observable<Marketplace> abstract getMarketplace$(): Observable<Marketplace>
abstract getSelectedStore$(): Observable<StoreData | null> abstract getSelectedStore$(): Observable<StoreData>
abstract getPackage$( abstract getPackage$(
id: string, id: string,
version: string, version: string,
url?: string, url?: string,
): Observable<MarketplacePkg | undefined> ): Observable<MarketplacePkg> // could be {} so need to check in show page
abstract fetchReleaseNotes$( abstract fetchReleaseNotes$(
id: string, id: string,

View File

@@ -36,28 +36,16 @@ export class ToMessagePipe implements PipeTransform {
constructor(private readonly stateService: StateService) {} constructor(private readonly stateService: StateService) {}
transform(progress: number | null): string { transform(progress: number | null): string {
switch (this.stateService.setupType) { if (['fresh', 'attach'].includes(this.stateService.setupType || '')) {
case 'fresh': return 'Setting up your Embassy'
case 'attach': }
return 'Setting up your Embassy'
case 'restore': if (!progress) {
if (!progress) { return 'Preparing data. This can take a while'
return 'Initializing' } else if (progress < 1) {
} else if (progress < 1) { return 'Copying data'
return 'Restoring data. This can take a while' } else {
} else { return 'Finalizing'
return 'Finalizing data restore'
}
case 'transfer':
if (!progress) {
return 'Preparing data. Depending on how much data you have, this could take up to 1 hour'
} else if (progress < 1) {
return 'Transferring data'
} else {
return 'Finalizing data transfer'
}
default:
return ''
} }
} }
} }

View File

@@ -59,7 +59,7 @@ export class SuccessPage {
const ret = await this.api.complete() const ret = await this.api.complete()
if (!this.isKiosk) { if (!this.isKiosk) {
this.torAddress = ret['tor-address'] this.torAddress = ret['tor-address']
this.lanAddress = ret['lan-address'] this.lanAddress = ret['lan-address'].replace('https', 'http')
this.cert = ret['root-ca'] this.cert = ret['root-ca']
await this.api.exit() await this.api.exit()

View File

@@ -15,7 +15,7 @@
<ion-item [color]="details.color"> <ion-item [color]="details.color">
<ion-icon slot="start" name="information-circle-outline"></ion-icon> <ion-icon slot="start" name="information-circle-outline"></ion-icon>
<ion-label> <ion-label>
<h2 style="font-weight: 600">{{ details.description }}</h2> <h2 style="font-weight: 600" [innerHTML]="details.description"></h2>
</ion-label> </ion-label>
</ion-item> </ion-item>

View File

@@ -19,7 +19,6 @@ export class MarketplaceListPage {
readonly back = !!this.route.snapshot.queryParamMap.get('back') readonly back = !!this.route.snapshot.queryParamMap.get('back')
readonly store$ = this.marketplaceService.getSelectedStore$().pipe( readonly store$ = this.marketplaceService.getSelectedStore$().pipe(
filter(Boolean),
map(({ info, packages }) => { map(({ info, packages }) => {
const categories = new Set<string>() const categories = new Set<string>()
if (info.categories.includes('featured')) categories.add('featured') if (info.categories.includes('featured')) categories.add('featured')
@@ -57,7 +56,7 @@ export class MarketplaceListPage {
// alt marketplace // alt marketplace
color = 'warning' color = 'warning'
description = description =
'This is a Custom Registry. Start9 cannot verify the integrity or functionality of services from this registry, and they may cause harm to your system. Install at your own risk.' 'This is a Custom Registry. Start9 cannot verify the integrity or functionality of services from this registry, and they may cause harm to your system. <b>Install at your own risk</b>.'
} }
return { return {

View File

@@ -2,7 +2,16 @@
<ion-content class="ion-padding"> <ion-content class="ion-padding">
<ng-container *ngIf="pkg$ | async as pkg else loading"> <ng-container *ngIf="pkg$ | async as pkg else loading">
<ng-container *ngIf="!(pkg | empty)"> <ng-container *ngIf="pkg | empty; else show">
<ng-container *ngIf="loadVersion$ | async as version">
<h2>
{{ pkgId }} version {{ version === '*' ? 'latest' : version }} not
found in this registry
</h2>
</ng-container>
</ng-container>
<ng-template #show>
<marketplace-package [pkg]="pkg"></marketplace-package> <marketplace-package [pkg]="pkg"></marketplace-package>
<marketplace-show-controls <marketplace-show-controls
[url]="url" [url]="url"
@@ -24,7 +33,7 @@
[pkg]="pkg" [pkg]="pkg"
(version)="loadVersion$.next($event)" (version)="loadVersion$.next($event)"
></marketplace-additional> ></marketplace-additional>
</ng-container> </ng-template>
</ng-container> </ng-container>
<ng-template #loading> <ng-template #loading>

View File

@@ -14,7 +14,7 @@ import { DataModel } from 'src/app/services/patch-db/data-model'
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
}) })
export class MarketplaceShowPage { export class MarketplaceShowPage {
private readonly pkgId = getPkgId(this.route) readonly pkgId = getPkgId(this.route)
readonly url = this.route.snapshot.queryParamMap.get('url') || undefined readonly url = this.route.snapshot.queryParamMap.get('url') || undefined
readonly loadVersion$ = new BehaviorSubject<string>('*') readonly loadVersion$ = new BehaviorSubject<string>('*')

View File

@@ -92,13 +92,13 @@ export class MarketplaceService implements AbstractMarketplaceService {
shareReplay(1), shareReplay(1),
) )
private readonly selectedStore$: Observable<StoreData | null> = private readonly selectedStore$: Observable<StoreData> =
this.selectedHost$.pipe( this.selectedHost$.pipe(
switchMap(({ url }) => switchMap(({ url }) =>
this.marketplace$.pipe( this.marketplace$.pipe(
filter(m => !!m[url]),
take(1),
map(m => m[url]), map(m => m[url]),
filter(Boolean),
take(1),
), ),
), ),
) )
@@ -123,7 +123,7 @@ export class MarketplaceService implements AbstractMarketplaceService {
return this.marketplace$ return this.marketplace$
} }
getSelectedStore$(): Observable<StoreData | null> { getSelectedStore$(): Observable<StoreData> {
return this.selectedStore$ return this.selectedStore$
} }
@@ -131,18 +131,24 @@ export class MarketplaceService implements AbstractMarketplaceService {
id: string, id: string,
version: string, version: string,
optionalUrl?: string, optionalUrl?: string,
): Observable<MarketplacePkg | undefined> { ): Observable<MarketplacePkg> {
return this.patch.watch$('ui', 'marketplace').pipe( return this.patch.watch$('ui', 'marketplace').pipe(
switchMap(marketplace => { switchMap(uiMarketplace => {
const url = optionalUrl || marketplace['selected-url'] const url = optionalUrl || uiMarketplace['selected-url']
if (version !== '*' || !marketplace['known-hosts'][url]) { if (version !== '*' || !uiMarketplace['known-hosts'][url]) {
return this.fetchPackage$(id, version, url) return this.fetchPackage$(id, version, url)
} }
return this.selectedStore$.pipe( return this.marketplace$.pipe(
map(m => m[url]),
filter(Boolean), filter(Boolean),
map(s => s.packages.find(p => p.manifest.id === id)), take(1),
map(
store =>
store.packages.find(p => p.manifest.id === id) ||
({} as MarketplacePkg),
),
) )
}), }),
) )
@@ -184,6 +190,37 @@ export class MarketplaceService implements AbstractMarketplaceService {
) )
} }
fetchReleaseNotes$(
id: string,
url?: string,
): Observable<Record<string, string>> {
return this.selectedHost$.pipe(
switchMap(m => {
return from(
this.api.marketplaceProxy<Record<string, string>>(
`/package/v0/release-notes/${id}`,
{},
url || m.url,
),
)
}),
)
}
fetchStatic$(id: string, type: string, url?: string): Observable<string> {
return this.selectedHost$.pipe(
switchMap(m => {
return from(
this.api.marketplaceProxy<string>(
`/package/v0/${type}/${id}`,
{},
url || m.url,
),
)
}),
)
}
private fetchStore$(url: string): Observable<StoreData | null> { private fetchStore$(url: string): Observable<StoreData | null> {
return combineLatest([this.fetchInfo$(url), this.fetchPackages$(url)]).pipe( return combineLatest([this.fetchInfo$(url), this.fetchPackages$(url)]).pipe(
map(([info, packages]) => ({ info, packages })), map(([info, packages]) => ({ info, packages })),
@@ -221,44 +258,13 @@ export class MarketplaceService implements AbstractMarketplaceService {
) )
} }
fetchPackage$( private fetchPackage$(
id: string, id: string,
version: string, version: string,
url: string, url: string,
): Observable<MarketplacePkg | undefined> { ): Observable<MarketplacePkg> {
return this.fetchPackages$(url, { ids: [{ id, version }] }).pipe( return this.fetchPackages$(url, { ids: [{ id, version }] }).pipe(
map(pkgs => pkgs[0]), map(pkgs => pkgs[0] || {}),
)
}
fetchReleaseNotes$(
id: string,
url?: string,
): Observable<Record<string, string>> {
return this.selectedHost$.pipe(
switchMap(m => {
return from(
this.api.marketplaceProxy<Record<string, string>>(
`/package/v0/release-notes/${id}`,
{},
url || m.url,
),
)
}),
)
}
fetchStatic$(id: string, type: string, url?: string): Observable<string> {
return this.selectedHost$.pipe(
switchMap(m => {
return from(
this.api.marketplaceProxy<string>(
`/package/v0/${type}/${id}`,
{},
url || m.url,
),
)
}),
) )
} }