Fixed tier archive not updating portal preview

The tier visibility is now handled by visibility property on object, this change ensures portal preview is updated on a tier archive to show the correct Portal UI.
This commit is contained in:
Rishabh 2022-03-09 13:05:07 +05:30 committed by Rishabh Garg
parent f65437b14c
commit 82d6d38b3f
8 changed files with 27 additions and 3 deletions

View File

@ -30,6 +30,7 @@
@product={{product}}
@openEditProduct={{this.openEditProduct}}
@onUnarchive={{this.onUnarchive}}
@onArchive={{this.onArchive}}
/>
{{/each}}
{{#if (eq this.type "active" )}}

View File

@ -60,6 +60,12 @@ export default class extends Component {
@action
async onUnarchive() {
this.type = 'active';
this.args.updatePortalPreview();
}
@action
async onArchive() {
this.args.updatePortalPreview();
}
@action

View File

@ -84,6 +84,7 @@
<Settings::Members::ArchiveTier
@product={{@product}}
@onUnarchive={{@onUnarchive}}
@onArchive={{@onArchive}}
/>
</li>
{{/if}}

View File

@ -52,7 +52,9 @@ export default ModalComponent.extend({
portalPreviewUrl: computed('page', 'model.products.[]', 'changedProducts.[]', 'membersUtils.{isFreeChecked,isMonthlyChecked,isYearlyChecked}', 'settings.{portalName,portalButton,portalButtonIcon,portalButtonSignupText,portalButtonStyle,accentColor,portalPlans.[]}', function () {
const options = this.getProperties(['page']);
options.portalProducts = this.model.products?.filter((product) => {
return product.get('visibility') === 'public' && product.get('type') === 'paid';
return product.get('visibility') === 'public'
&& product.get('active') === true
&& product.get('type') === 'paid';
}).map((product) => {
return product.id;
});

View File

@ -13,11 +13,13 @@ export default class ArchiveTierModalComponent extends Component {
@task({drop: true})
*archiveTierTask() {
const {product} = this.args.data;
const {product, onArchive} = this.args.data;
product.active = false;
product.visibility = 'none';
try {
yield product.save();
onArchive?.();
return product;
} catch (error) {
if (error) {

View File

@ -20,7 +20,8 @@ export default class ArchiveTierComponent extends Component {
handleArchiveTier() {
if (!this.product.isNew) {
this.modals.open('modals/tiers/archive', {
product: this.product
product: this.product,
onArchive: this.args.onArchive
}, {
className: 'fullscreen-modal fullscreen-modal-action fullscreen-modal-wide'
});

View File

@ -266,10 +266,20 @@ export default class MembersAccessController extends Controller {
let isMonthlyChecked = portalPlans.includes('monthly');
let isYearlyChecked = portalPlans.includes('yearly');
const products = this.store.peekAll('product');
const portalProducts = products?.filter((product) => {
return product.get('visibility') === 'public'
&& product.get('active') === true
&& product.get('type') === 'paid';
}).map((product) => {
return product.id;
});
const newUrl = new URL(this.membersUtils.getPortalPreviewUrl({
button: false,
monthlyPrice,
yearlyPrice,
portalProducts,
currency: this.currency,
isMonthlyChecked,
isYearlyChecked,

View File

@ -169,6 +169,7 @@
{{else}}
{{#if (feature "multipleProducts")}}
<GhMembershipProductsAlpha
@updatePortalPreview={{this.updatePortalPreview}}
@products={{this.paidProducts}}
@confirmProductSave={{this.confirmProductSave}}
/>