mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 22:43:30 +03:00
28e4eb60ae
refs https://github.com/TryGhost/Team/issues/2233 **Problem** When a user clicks an offer link that has an archived tier, the site blocks and you are no longer able to scroll. This is because the product for that offer can't be found. This has been fixed by updating the `isActiveOffer` helper to also check for the existence of the corresponding tier. **Solution** - You no longer are able to create new offers if there are no active tiers - A custom message is shown that instructs the user to create a new tier if there are not active tiers on the offers page - Improved detection of changes in tiers by correctly reloading the members utils service after tier changes - Portal redirects to the homepage for offers with an archived tier (same behaviour as invalid offers) - Offers of an archived tier are no longer visible in the dashboard
98 lines
2.0 KiB
JavaScript
98 lines
2.0 KiB
JavaScript
import Component from '@glimmer/component';
|
|
import {action} from '@ember/object';
|
|
import {inject} from 'ghost-admin/decorators/inject';
|
|
import {inject as service} from '@ember/service';
|
|
import {tracked} from '@glimmer/tracking';
|
|
|
|
const TYPES = [{
|
|
name: 'Active',
|
|
value: 'active'
|
|
},{
|
|
name: 'Archived',
|
|
value: 'archived'
|
|
}];
|
|
|
|
export default class extends Component {
|
|
@service membersUtils;
|
|
@service ghostPaths;
|
|
@service ajax;
|
|
@service store;
|
|
|
|
@inject config;
|
|
|
|
@tracked showTierModal = false;
|
|
@tracked tierModel = null;
|
|
@tracked type = 'active';
|
|
|
|
get tiers() {
|
|
return this.args.tiers.filter((tier) => {
|
|
if (this.type === 'active') {
|
|
return !!tier.active;
|
|
} else if (this.type === 'archived') {
|
|
return !tier.active;
|
|
}
|
|
|
|
return true;
|
|
});
|
|
}
|
|
|
|
get availableTypes() {
|
|
return TYPES;
|
|
}
|
|
|
|
get selectedType() {
|
|
return this.type ? TYPES.find((d) => {
|
|
return this.type === d.value;
|
|
}) : TYPES[0];
|
|
}
|
|
|
|
get isEmptyList() {
|
|
return this.tiers.length === 0;
|
|
}
|
|
|
|
@action
|
|
onTypeChange(type) {
|
|
this.type = type.value;
|
|
}
|
|
|
|
@action
|
|
async openEditTier(tier) {
|
|
this.tierModel = tier;
|
|
this.showTierModal = true;
|
|
}
|
|
|
|
@action
|
|
async onUnarchive() {
|
|
this.type = 'active';
|
|
this.args.updatePortalPreview();
|
|
this.reloadTiers();
|
|
}
|
|
|
|
@action
|
|
async onArchive() {
|
|
this.args.updatePortalPreview();
|
|
this.reloadTiers();
|
|
}
|
|
|
|
reloadTiers() {
|
|
// Reload the cached tiers in membersutils
|
|
this.membersUtils.reload();
|
|
}
|
|
|
|
@action
|
|
async openNewTier() {
|
|
this.tierModel = this.store.createRecord('tier');
|
|
this.showTierModal = true;
|
|
}
|
|
|
|
@action
|
|
closeTierModal() {
|
|
this.showTierModal = false;
|
|
}
|
|
|
|
@action
|
|
confirmTierSave() {
|
|
this.args.confirmTierSave();
|
|
}
|
|
}
|