mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
Switched Portal settings 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
8fde9a05d2
commit
a11554aaba
2 changed files with 13 additions and 26 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import ConfirmUnsavedChangesModal from '../../components/modals/confirm-unsaved-changes';
|
||||||
import Controller from '@ember/controller';
|
import Controller from '@ember/controller';
|
||||||
import envConfig from 'ghost-admin/config/environment';
|
import envConfig from 'ghost-admin/config/environment';
|
||||||
import {action} from '@ember/object';
|
import {action} from '@ember/object';
|
||||||
|
@ -18,11 +19,11 @@ export default class MembersAccessController extends Controller {
|
||||||
@service config;
|
@service config;
|
||||||
@service feature;
|
@service feature;
|
||||||
@service membersUtils;
|
@service membersUtils;
|
||||||
|
@service modals;
|
||||||
@service settings;
|
@service settings;
|
||||||
@service store;
|
@service store;
|
||||||
@service session;
|
@service session;
|
||||||
|
|
||||||
@tracked showLeavePortalModal = false;
|
|
||||||
@tracked showPortalSettings = false;
|
@tracked showPortalSettings = false;
|
||||||
@tracked showStripeConnect = false;
|
@tracked showStripeConnect = false;
|
||||||
@tracked showTierModal = false;
|
@tracked showTierModal = false;
|
||||||
|
@ -216,29 +217,23 @@ export default class MembersAccessController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
closePortalSettings() {
|
async closePortalSettings() {
|
||||||
const changedAttributes = this.settings.changedAttributes();
|
const changedAttributes = this.settings.changedAttributes();
|
||||||
|
|
||||||
if (changedAttributes && Object.keys(changedAttributes).length > 0) {
|
if (changedAttributes && Object.keys(changedAttributes).length > 0) {
|
||||||
this.showLeavePortalModal = true;
|
const shouldClose = await this.modals.open(ConfirmUnsavedChangesModal);
|
||||||
|
|
||||||
|
if (shouldClose) {
|
||||||
|
this.settings.rollbackAttributes();
|
||||||
|
this.showPortalSettings = false;
|
||||||
|
this.updatePortalPreview();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.showPortalSettings = false;
|
this.showPortalSettings = false;
|
||||||
this.updatePortalPreview();
|
this.updatePortalPreview();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
|
||||||
async confirmClosePortalSettings() {
|
|
||||||
this.settings.rollbackAttributes();
|
|
||||||
this.showPortalSettings = false;
|
|
||||||
this.showLeavePortalModal = false;
|
|
||||||
this.updatePortalPreview();
|
|
||||||
}
|
|
||||||
|
|
||||||
@action
|
|
||||||
cancelClosePortalSettings() {
|
|
||||||
this.showLeavePortalModal = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@action
|
@action
|
||||||
updatePortalPreview({forceRefresh} = {forceRefresh: false}) {
|
updatePortalPreview({forceRefresh} = {forceRefresh: false}) {
|
||||||
// TODO: can these be worked out from settings in membersUtils?
|
// TODO: can these be worked out from settings in membersUtils?
|
||||||
|
|
|
@ -161,7 +161,8 @@
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{{#if this.showPortalSettings}}
|
{{#if this.showPortalSettings}}
|
||||||
<GhFullscreenModal @modal="portal-settings"
|
<GhFullscreenModal
|
||||||
|
@modal="portal-settings"
|
||||||
@model={{hash
|
@model={{hash
|
||||||
preloadTask=this.saveSettingsTask
|
preloadTask=this.saveSettingsTask
|
||||||
openStripeConnect=this.openStripeConnect
|
openStripeConnect=this.openStripeConnect
|
||||||
|
@ -171,15 +172,6 @@
|
||||||
@modifier="full-overlay portal-settings" />
|
@modifier="full-overlay portal-settings" />
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if this.showLeavePortalModal}}
|
|
||||||
<GhFullscreenModal
|
|
||||||
@modal="leave-settings"
|
|
||||||
@confirm={{this.confirmClosePortalSettings}}
|
|
||||||
@close={{this.cancelClosePortalSettings}}
|
|
||||||
@modifier="action wide"
|
|
||||||
/>
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{#if this.showStripeConnect}}
|
{{#if this.showStripeConnect}}
|
||||||
<GhFullscreenModal
|
<GhFullscreenModal
|
||||||
@modal="stripe-connect"
|
@modal="stripe-connect"
|
||||||
|
|
Loading…
Add table
Reference in a new issue