Disable view in marketplace button when side-loaded (#1471)

Disble view in marketplace button when side-loaded
This commit is contained in:
Benjamin B
2022-06-02 07:20:45 +10:00
committed by GitHub
parent cceef054ac
commit e11729013f
2 changed files with 23 additions and 7 deletions

View File

@@ -4,6 +4,7 @@
button button
detail detail
(click)="button.action()" (click)="button.action()"
[disabled]="button.disabled"
> >
<ion-icon slot="start" [name]="button.icon"></ion-icon> <ion-icon slot="start" [name]="button.icon"></ion-icon>
<ion-label> <ion-label>

View File

@@ -13,6 +13,7 @@ export interface Button {
description: string description: string
icon: string icon: string
action: Function action: Function
disabled?: boolean
} }
@Pipe({ @Pipe({
@@ -86,13 +87,8 @@ export class ToButtonsPipe implements PipeTransform {
icon: 'receipt-outline', icon: 'receipt-outline',
}, },
// view in marketplace // view in marketplace
{ this.viewInMarketplaceButton(pkg),
action: () => // donate
this.navCtrl.navigateForward([`marketplace/${pkg.manifest.id}`]),
title: 'Marketplace',
description: 'View service in marketplace',
icon: 'storefront-outline',
},
{ {
action: () => this.donate(pkg), action: () => this.donate(pkg),
title: 'Donate', title: 'Donate',
@@ -116,6 +112,25 @@ export class ToButtonsPipe implements PipeTransform {
await modal.present() await modal.present()
} }
private viewInMarketplaceButton(pkg: PackageDataEntry): Button {
return pkg.installed?.['marketplace-url']
? {
action: () =>
this.navCtrl.navigateForward([`marketplace/${pkg.manifest.id}`]),
title: 'Marketplace',
description: 'View service in marketplace',
icon: 'storefront-outline',
}
: {
disabled: true,
action: () => {},
title: 'Marketplace',
description:
'This package has been side-loaded and is not available in the Start9 Marketplace',
icon: 'storefront-outline',
}
}
private async donate({ manifest }: PackageDataEntry): Promise<void> { private async donate({ manifest }: PackageDataEntry): Promise<void> {
const url = manifest['donation-url'] const url = manifest['donation-url']
if (url) { if (url) {