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 envConfig from 'ghost-admin/config/environment';
|
||||
import {action} from '@ember/object';
|
||||
|
@ -18,11 +19,11 @@ export default class MembersAccessController extends Controller {
|
|||
@service config;
|
||||
@service feature;
|
||||
@service membersUtils;
|
||||
@service modals;
|
||||
@service settings;
|
||||
@service store;
|
||||
@service session;
|
||||
|
||||
@tracked showLeavePortalModal = false;
|
||||
@tracked showPortalSettings = false;
|
||||
@tracked showStripeConnect = false;
|
||||
@tracked showTierModal = false;
|
||||
|
@ -216,29 +217,23 @@ export default class MembersAccessController extends Controller {
|
|||
}
|
||||
|
||||
@action
|
||||
closePortalSettings() {
|
||||
async closePortalSettings() {
|
||||
const changedAttributes = this.settings.changedAttributes();
|
||||
|
||||
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 {
|
||||
this.showPortalSettings = false;
|
||||
this.updatePortalPreview();
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
async confirmClosePortalSettings() {
|
||||
this.settings.rollbackAttributes();
|
||||
this.showPortalSettings = false;
|
||||
this.showLeavePortalModal = false;
|
||||
this.updatePortalPreview();
|
||||
}
|
||||
|
||||
@action
|
||||
cancelClosePortalSettings() {
|
||||
this.showLeavePortalModal = false;
|
||||
}
|
||||
|
||||
@action
|
||||
updatePortalPreview({forceRefresh} = {forceRefresh: false}) {
|
||||
// TODO: can these be worked out from settings in membersUtils?
|
||||
|
|
|
@ -161,7 +161,8 @@
|
|||
</section>
|
||||
|
||||
{{#if this.showPortalSettings}}
|
||||
<GhFullscreenModal @modal="portal-settings"
|
||||
<GhFullscreenModal
|
||||
@modal="portal-settings"
|
||||
@model={{hash
|
||||
preloadTask=this.saveSettingsTask
|
||||
openStripeConnect=this.openStripeConnect
|
||||
|
@ -171,15 +172,6 @@
|
|||
@modifier="full-overlay portal-settings" />
|
||||
{{/if}}
|
||||
|
||||
{{#if this.showLeavePortalModal}}
|
||||
<GhFullscreenModal
|
||||
@modal="leave-settings"
|
||||
@confirm={{this.confirmClosePortalSettings}}
|
||||
@close={{this.cancelClosePortalSettings}}
|
||||
@modifier="action wide"
|
||||
/>
|
||||
{{/if}}
|
||||
|
||||
{{#if this.showStripeConnect}}
|
||||
<GhFullscreenModal
|
||||
@modal="stripe-connect"
|
||||
|
|
Loading…
Add table
Reference in a new issue