mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 03:44:29 +03:00
85d7932e45
refs https://github.com/TryGhost/Team/issues/559
refs 054a5f15f5
- with the update of `ember-promise-modals` we started to get deprecation warnings when using `modals.open('modal-component-name')`
- upcoming Ember build updates will introduce tree shaking but using run-time lookup of modal components by name works against that because it's not statically analysable
- switched to importing components and passing the component class directly, eg. `modals.open(ModalComponent)`
- standardized modal component class names with a `MyModal` style to get better behaviour in code editors when it auto generates imports
- dropped the modal defaults from the modals service because we can now use a static `modalOptions` property on the modal components themselves when we want to override the defaults
49 lines
1.5 KiB
JavaScript
49 lines
1.5 KiB
JavaScript
import AdminRoute from 'ghost-admin/routes/admin';
|
|
import CustomIntegrationLimitsModal from '../../../components/modals/limits/custom-integration';
|
|
import NewCustomIntegrationModal from '../../../components/modals/new-custom-integration';
|
|
import {action} from '@ember/object';
|
|
import {inject as service} from '@ember/service';
|
|
|
|
export default class NewIntegrationRoute extends AdminRoute {
|
|
@service limit;
|
|
@service modals;
|
|
@service router;
|
|
|
|
modal = null;
|
|
|
|
async model() {
|
|
if (this.limit.limiter?.isLimited('customIntegrations')) {
|
|
try {
|
|
await this.limit.limiter.errorIfWouldGoOverLimit('customIntegrations');
|
|
} catch (error) {
|
|
this.modal = this.modals.open(CustomIntegrationLimitsModal, {
|
|
message: error.message
|
|
}, {
|
|
beforeClose: this.beforeModalClose
|
|
});
|
|
return;
|
|
}
|
|
}
|
|
|
|
this.modal = this.modals.open(NewCustomIntegrationModal, {}, {
|
|
beforeClose: this.beforeModalClose
|
|
});
|
|
}
|
|
|
|
deactivate() {
|
|
// ensure we don't try to redirect on modal close if we're already transitioning away
|
|
this.isLeaving = true;
|
|
this.modal?.close();
|
|
|
|
this.modal = null;
|
|
this.isLeaving = false;
|
|
}
|
|
|
|
@action
|
|
beforeModalClose() {
|
|
if (this.modal && !this.isLeaving) {
|
|
this.router.transitionTo('settings.integrations');
|
|
}
|
|
}
|
|
}
|