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
detail
(click)="button.action()"
[disabled]="button.disabled"
>
<ion-icon slot="start" [name]="button.icon"></ion-icon>
<ion-label>

View File

@@ -13,6 +13,7 @@ export interface Button {
description: string
icon: string
action: Function
disabled?: boolean
}
@Pipe({
@@ -86,13 +87,8 @@ export class ToButtonsPipe implements PipeTransform {
icon: 'receipt-outline',
},
// view in marketplace
{
action: () =>
this.navCtrl.navigateForward([`marketplace/${pkg.manifest.id}`]),
title: 'Marketplace',
description: 'View service in marketplace',
icon: 'storefront-outline',
},
this.viewInMarketplaceButton(pkg),
// donate
{
action: () => this.donate(pkg),
title: 'Donate',
@@ -116,6 +112,25 @@ export class ToButtonsPipe implements PipeTransform {
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> {
const url = manifest['donation-url']
if (url) {