diff --git a/addon/components/extension-card.hbs b/addon/components/extension-card.hbs index 87f18af..234631f 100644 --- a/addon/components/extension-card.hbs +++ b/addon/components/extension-card.hbs @@ -6,6 +6,11 @@
{{@extension.name}}
{{n-a @extension.description}}
+ {{#if @extension.payment_required}} + {{format-currency @extension.price @extension.currency}} + {{else}} + Free + {{/if}}
{{yield @extension}} diff --git a/addon/components/extension-card.js b/addon/components/extension-card.js index 7ca0c49..2a3a62c 100644 --- a/addon/components/extension-card.js +++ b/addon/components/extension-card.js @@ -40,9 +40,21 @@ export default class ExtensionCardComponent extends Component { @action onClick(options = {}) { const installChannel = `install.${this.currentUser.companyId}.${this.extension.id}`; + const isAuthor = this.extension.is_author === true; + const isSelfManaged = this.extension.self_managed === true; const isAlreadyPurchased = this.extension.is_purchased === true; const isAlreadyInstalled = this.extension.is_installed === true; - const isPaymentRequired = this.extension.payment_required === true && isAlreadyPurchased === false; + const isPaymentRequired = !isAuthor && this.extension.payment_required === true && isAlreadyPurchased === false; + const goBack = async (modal) => { + await modal.done(); + later( + this, + () => { + this.onClick(); + }, + 100 + ); + }; if (typeof this.args.onClick === 'function') { this.args.onClick(this.extension); @@ -63,6 +75,13 @@ export default class ExtensionCardComponent extends Component { stepDescription: 'Awaiting install to begin...', progress: 0, extension: this.extension, + viewSelfManagesInstallInstructions: () => { + this.selfManagedInstallInstructions({ + extension: this.extension, + confirm: goBack, + decline: goBack, + }); + }, confirm: async (modal) => { modal.startLoading(); @@ -71,6 +90,22 @@ export default class ExtensionCardComponent extends Component { return this.startCheckoutSession(); } + // If self managed just prompt instructions + if (isSelfManaged) { + await modal.done(); + return later( + this, + () => { + return this.selfManagedInstallInstructions({ + extension: this.extension, + confirm: goBack, + decline: goBack, + }); + }, + 100 + ); + } + // Listen for install progress this.socket.listen(installChannel, ({ process, step, progress }) => { let stepDescription; @@ -121,6 +156,16 @@ export default class ExtensionCardComponent extends Component { }); } + async selfManagedInstallInstructions(options = {}) { + await this.modalsManager.done(); + this.modalsManager.show('modals/self-managed-install-instructions', { + title: 'Install a Self Managed Extension', + hideDeclineButton: true, + acceptButtonText: 'Done', + ...options, + }); + } + async startCheckoutSession() { const checkout = await this.stripe.initEmbeddedCheckout({ fetchClientSecret: this.fetchClientSecret.bind(this), diff --git a/addon/components/extension-form.hbs b/addon/components/extension-form.hbs index 3a368bf..a4be355 100644 --- a/addon/components/extension-form.hbs +++ b/addon/components/extension-form.hbs @@ -69,7 +69,6 @@ + + + + {{t "registry-bridge.developers.extensions.extension-form.self-managed"}} + +

+ {{t "registry-bridge.developers.extensions.extension-form.self-managed-help-text"}} +

+
@@ -101,7 +113,13 @@ {{/if}}
- + { + await modal.done(); + later( + this, + () => { + this.previewListing(); + }, + 100 + ); + }; + + this.modalsManager.show('modals/extension-details', { + titleComponent: 'extension-modal-title', + modalClass: 'flb--extension-modal modal-lg', + modalHeaderClass: 'flb--extension-modal-header', + acceptButtonText: isPaymentRequired ? `Purchase for ${formatCurrency(extension.price, extension.currency)}` : isAlreadyInstalled ? 'Installed' : 'Install', + acceptButtonIcon: isPaymentRequired ? 'credit-card' : isAlreadyInstalled ? 'check' : 'download', + acceptButtonDisabled: true, + acceptButtonScheme: isPaymentRequired ? 'success' : 'primary', + declineButtonText: 'Done', + viewSelfManagesInstallInstructions: () => { + this.selfManagedInstallInstructions({ + extension, + confirm: goBack, + decline: goBack, + }); + }, + extension, + ...options, + }); + } + + async selfManagedInstallInstructions(options = {}) { + await this.modalsManager.done(); + this.modalsManager.show('modals/self-managed-install-instructions', { + title: 'Install a Self Managed Extension', + hideDeclineButton: true, + acceptButtonText: 'Done', + ...options, + }); + } } diff --git a/addon/components/modals/extension-details.hbs b/addon/components/modals/extension-details.hbs index 3bcb813..6960473 100644 --- a/addon/components/modals/extension-details.hbs +++ b/addon/components/modals/extension-details.hbs @@ -2,7 +2,7 @@