diff --git a/addon/components/extension-card.js b/addon/components/extension-card.js index 01edb90..2a3a62c 100644 --- a/addon/components/extension-card.js +++ b/addon/components/extension-card.js @@ -41,9 +41,20 @@ 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 = !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); @@ -65,15 +76,10 @@ export default class ExtensionCardComponent extends Component { progress: 0, extension: this.extension, viewSelfManagesInstallInstructions: () => { - const done = async () => { - await this.modalsManager.done(); - this.onClick(); - }; - this.selfManagedInstallInstructions({ extension: this.extension, - confirm: done, - decline: done, + confirm: goBack, + decline: goBack, }); }, confirm: async (modal) => { @@ -84,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; diff --git a/addon/components/extension-form.js b/addon/components/extension-form.js index e610943..32f949f 100644 --- a/addon/components/extension-form.js +++ b/addon/components/extension-form.js @@ -3,6 +3,7 @@ import { tracked } from '@glimmer/tracking'; import { inject as service } from '@ember/service'; import { action } from '@ember/object'; import { task } from 'ember-concurrency'; +import { later } from '@ember/runloop'; import formatCurrency from '@fleetbase/ember-ui/utils/format-currency'; export default class ExtensionFormComponent extends Component { @@ -135,6 +136,16 @@ export default class ExtensionFormComponent extends Component { const isAlreadyPurchased = extension.is_purchased === true; const isAlreadyInstalled = extension.is_installed === true; const isPaymentRequired = extension.payment_required === true && isAlreadyPurchased === false; + const goBack = async (modal) => { + await modal.done(); + later( + this, + () => { + this.previewListing(); + }, + 100 + ); + }; this.modalsManager.show('modals/extension-details', { titleComponent: 'extension-modal-title', @@ -146,15 +157,10 @@ export default class ExtensionFormComponent extends Component { acceptButtonScheme: isPaymentRequired ? 'success' : 'primary', declineButtonText: 'Done', viewSelfManagesInstallInstructions: () => { - const done = async () => { - await this.modalsManager.done(); - this.previewListing(); - }; - this.selfManagedInstallInstructions({ extension, - confirm: done, - decline: done, + confirm: goBack, + decline: goBack, }); }, extension, diff --git a/addon/components/modals/self-managed-install-instructions.hbs b/addon/components/modals/self-managed-install-instructions.hbs index 5ba55c3..d606d7c 100644 --- a/addon/components/modals/self-managed-install-instructions.hbs +++ b/addon/components/modals/self-managed-install-instructions.hbs @@ -1,27 +1,38 @@