mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-26 12:21:36 +03:00
Switched membership unsaved changes modal to new modal pattern
refs https://github.com/TryGhost/Team/issues/1734 refs https://github.com/TryGhost/Team/issues/559 refs https://github.com/TryGhost/Ghost/issues/14101 - switches to newer modal patterns ready for later Ember upgrades
This commit is contained in:
parent
c85690fb12
commit
416932e118
@ -23,7 +23,6 @@ export default class MembersAccessController extends Controller {
|
|||||||
@service session;
|
@service session;
|
||||||
|
|
||||||
@tracked showLeavePortalModal = false;
|
@tracked showLeavePortalModal = false;
|
||||||
@tracked showLeaveRouteModal = false;
|
|
||||||
@tracked showPortalSettings = false;
|
@tracked showPortalSettings = false;
|
||||||
@tracked showStripeConnect = false;
|
@tracked showStripeConnect = false;
|
||||||
@tracked showTierModal = false;
|
@tracked showTierModal = false;
|
||||||
@ -93,25 +92,8 @@ export default class MembersAccessController extends Controller {
|
|||||||
this.updatePortalPreview();
|
this.updatePortalPreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
leaveRoute(transition) {
|
get isDirty() {
|
||||||
if (this.settings.get('hasDirtyAttributes') || this.hasChangedPrices) {
|
return this.settings.get('hasDirtyAttributes') || this.hasChangedPrices;
|
||||||
transition.abort();
|
|
||||||
this.leaveSettingsTransition = transition;
|
|
||||||
this.showLeaveRouteModal = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@action
|
|
||||||
async confirmLeave() {
|
|
||||||
this.settings.rollbackAttributes();
|
|
||||||
this.resetPrices();
|
|
||||||
this.leaveSettingsTransition.retry();
|
|
||||||
}
|
|
||||||
|
|
||||||
@action
|
|
||||||
cancelLeave() {
|
|
||||||
this.showLeaveRouteModal = false;
|
|
||||||
this.leaveSettingsTransition = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
@ -389,6 +371,14 @@ export default class MembersAccessController extends Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@action
|
||||||
|
reset() {
|
||||||
|
this.settings.rollbackAttributes();
|
||||||
|
this.resetPrices();
|
||||||
|
this.showLeavePortalModal = false;
|
||||||
|
this.showPortalSettings = false;
|
||||||
|
}
|
||||||
|
|
||||||
resetPrices() {
|
resetPrices() {
|
||||||
const monthlyPrice = this.tier.get('monthlyPrice');
|
const monthlyPrice = this.tier.get('monthlyPrice');
|
||||||
const yearlyPrice = this.tier.get('yearlyPrice');
|
const yearlyPrice = this.tier.get('yearlyPrice');
|
||||||
@ -397,12 +387,6 @@ export default class MembersAccessController extends Controller {
|
|||||||
this.stripeYearlyAmount = yearlyPrice ? (yearlyPrice.amount / 100) : 50;
|
this.stripeYearlyAmount = yearlyPrice ? (yearlyPrice.amount / 100) : 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
reset() {
|
|
||||||
this.showLeaveRouteModal = false;
|
|
||||||
this.showLeavePortalModal = false;
|
|
||||||
this.showPortalSettings = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
_validateSignupRedirect(url, type) {
|
_validateSignupRedirect(url, type) {
|
||||||
const siteUrl = this.config.get('blogUrl');
|
const siteUrl = this.config.get('blogUrl');
|
||||||
let errMessage = `Please enter a valid URL`;
|
let errMessage = `Please enter a valid URL`;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import AdminRoute from 'ghost-admin/routes/admin';
|
import AdminRoute from 'ghost-admin/routes/admin';
|
||||||
|
import ConfirmUnsavedChangesModal from '../../components/modals/confirm-unsaved-changes';
|
||||||
import VerifyEmail from '../../components/modals/settings/verify-email';
|
import VerifyEmail from '../../components/modals/settings/verify-email';
|
||||||
|
import {action} from '@ember/object';
|
||||||
import {inject as service} from '@ember/service';
|
import {inject as service} from '@ember/service';
|
||||||
|
|
||||||
export default class MembershipSettingsRoute extends AdminRoute {
|
export default class MembershipSettingsRoute extends AdminRoute {
|
||||||
@ -41,11 +43,46 @@ export default class MembershipSettingsRoute extends AdminRoute {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
actions = {
|
@action
|
||||||
willTransition(transition) {
|
async willTransition(transition) {
|
||||||
return this.controller.leaveRoute(transition);
|
if (this.hasConfirmed) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
transition.abort();
|
||||||
|
|
||||||
|
// wait for any existing confirm modal to be closed before allowing transition
|
||||||
|
if (this.confirmModal) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.controller.saveTask?.isRunning) {
|
||||||
|
await this.controller.saveTask.last;
|
||||||
|
}
|
||||||
|
|
||||||
|
const shouldLeave = await this.confirmUnsavedChanges();
|
||||||
|
|
||||||
|
if (shouldLeave) {
|
||||||
|
this.controller.reset();
|
||||||
|
|
||||||
|
this.hasConfirmed = true;
|
||||||
|
return transition.retry();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async confirmUnsavedChanges() {
|
||||||
|
if (this.controller.isDirty) {
|
||||||
|
this.confirmModal = this.modals
|
||||||
|
.open(ConfirmUnsavedChangesModal)
|
||||||
|
.finally(() => {
|
||||||
|
this.confirmModal = null;
|
||||||
|
});
|
||||||
|
|
||||||
|
return this.confirmModal;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
buildRouteInfoMetadata() {
|
buildRouteInfoMetadata() {
|
||||||
return {
|
return {
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
<div class="gh-main-layout gh-setting-membership content-preview">
|
<div class="gh-main-layout gh-setting-membership content-preview">
|
||||||
<div class="gh-setting-members-basicsform">
|
<div class="gh-setting-members-basicsform">
|
||||||
<p class="intro">Fund your work with subscription revenue. Connect your Stripe account and offer premium content to your audience. Our creators are already making over $12 million per year, while <strong>Ghost takes 0% payment fees</strong>.</p>
|
<p class="intro">Fund your work with subscription revenue. Connect your Stripe account and offer premium content to your audience. Our creators are already making over $12 million per year, while <strong>Ghost takes 0% payment fees</strong>.</p>
|
||||||
|
|
||||||
<div class="flex flex-column justify-between mt3">
|
<div class="flex flex-column justify-between mt3">
|
||||||
<section class="gh-expandable gh-setting-members-portalcta">
|
<section class="gh-expandable gh-setting-members-portalcta">
|
||||||
<div class="gh-expandable-block">
|
<div class="gh-expandable-block">
|
||||||
@ -160,15 +160,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{{#if this.showLeaveRouteModal}}
|
|
||||||
<GhFullscreenModal
|
|
||||||
@modal="leave-settings"
|
|
||||||
@confirm={{this.confirmLeave}}
|
|
||||||
@close={{this.cancelLeave}}
|
|
||||||
@modifier="action wide"
|
|
||||||
/>
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{#if this.showPortalSettings}}
|
{{#if this.showPortalSettings}}
|
||||||
<GhFullscreenModal @modal="portal-settings"
|
<GhFullscreenModal @modal="portal-settings"
|
||||||
@model={{hash
|
@model={{hash
|
||||||
|
Loading…
Reference in New Issue
Block a user