mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Re-ordered memberships controller code
no issue - put setup and leave methods at the beginning so it's clearer what is happening when the screen is navigated to / away from - move "private" method to the end to keep it out of the way
This commit is contained in:
parent
32c9ee003f
commit
5a3c9a54b1
1 changed files with 41 additions and 40 deletions
|
@ -56,6 +56,12 @@ export default class MembersAccessController extends Controller {
|
||||||
return envConfig.environment !== 'development' && !/^https:/.test(siteUrl);
|
return envConfig.environment !== 'development' && !/^https:/.test(siteUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@action
|
||||||
|
setup() {
|
||||||
|
this.fetchDefaultProduct.perform();
|
||||||
|
this.updatePortalPreview();
|
||||||
|
}
|
||||||
|
|
||||||
leaveRoute(transition) {
|
leaveRoute(transition) {
|
||||||
if (this.settings.get('hasDirtyAttributes')) {
|
if (this.settings.get('hasDirtyAttributes')) {
|
||||||
transition.abort();
|
transition.abort();
|
||||||
|
@ -64,29 +70,17 @@ export default class MembersAccessController extends Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_validateSignupRedirect(url, type) {
|
@action
|
||||||
const siteUrl = this.config.get('blogUrl');
|
async confirmLeave() {
|
||||||
let errMessage = `Please enter a valid URL`;
|
this.settings.rollbackAttributes();
|
||||||
this.settings.get('errors').remove(type);
|
this.resetPrices();
|
||||||
this.settings.get('hasValidated').removeObject(type);
|
this.leaveSettingsTransition.retry();
|
||||||
|
|
||||||
if (url === null) {
|
|
||||||
this.settings.get('errors').add(type, errMessage);
|
|
||||||
this.settings.get('hasValidated').pushObject(type);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (url === undefined) {
|
@action
|
||||||
// Not initialised
|
cancelLeave() {
|
||||||
return;
|
this.showLeaveRouteModal = false;
|
||||||
}
|
this.leaveSettingsTransition = null;
|
||||||
|
|
||||||
if (url.href.startsWith(siteUrl)) {
|
|
||||||
const path = url.href.replace(siteUrl, '');
|
|
||||||
this.settings.set(type, path);
|
|
||||||
} else {
|
|
||||||
this.settings.set(type, url.href);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
|
@ -168,18 +162,6 @@ export default class MembersAccessController extends Controller {
|
||||||
this.showLeavePortalModal = false;
|
this.showLeavePortalModal = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
|
||||||
async confirmLeave() {
|
|
||||||
this.settings.rollbackAttributes();
|
|
||||||
this.leaveSettingsTransition.retry();
|
|
||||||
}
|
|
||||||
|
|
||||||
@action
|
|
||||||
cancelLeave() {
|
|
||||||
this.showLeaveRouteModal = false;
|
|
||||||
this.leaveSettingsTransition = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@action
|
@action
|
||||||
updatePortalPreview() {
|
updatePortalPreview() {
|
||||||
// TODO: can these be worked out from settings in membersUtils?
|
// TODO: can these be worked out from settings in membersUtils?
|
||||||
|
@ -243,12 +225,6 @@ export default class MembersAccessController extends Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
|
||||||
setup() {
|
|
||||||
this.fetchDefaultProduct.perform();
|
|
||||||
this.updatePortalPreview();
|
|
||||||
}
|
|
||||||
|
|
||||||
async saveProduct() {
|
async saveProduct() {
|
||||||
if (this.product) {
|
if (this.product) {
|
||||||
const stripePrices = this.product.stripePrices || [];
|
const stripePrices = this.product.stripePrices || [];
|
||||||
|
@ -392,4 +368,29 @@ export default class MembersAccessController extends Controller {
|
||||||
this.showLeavePortalModal = false;
|
this.showLeavePortalModal = false;
|
||||||
this.showPortalSettings = false;
|
this.showPortalSettings = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_validateSignupRedirect(url, type) {
|
||||||
|
const siteUrl = this.config.get('blogUrl');
|
||||||
|
let errMessage = `Please enter a valid URL`;
|
||||||
|
this.settings.get('errors').remove(type);
|
||||||
|
this.settings.get('hasValidated').removeObject(type);
|
||||||
|
|
||||||
|
if (url === null) {
|
||||||
|
this.settings.get('errors').add(type, errMessage);
|
||||||
|
this.settings.get('hasValidated').pushObject(type);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (url === undefined) {
|
||||||
|
// Not initialised
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (url.href.startsWith(siteUrl)) {
|
||||||
|
const path = url.href.replace(siteUrl, '');
|
||||||
|
this.settings.set(type, path);
|
||||||
|
} else {
|
||||||
|
this.settings.set(type, url.href);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue