mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-14 18:52:05 +03:00
f654b24486
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
50 lines
1.3 KiB
JavaScript
50 lines
1.3 KiB
JavaScript
import AdminRoute from 'ghost-admin/routes/admin';
|
|
import WebhookFormModal from '../../../../components/settings/integrations/webhook-form-modal';
|
|
import {action} from '@ember/object';
|
|
import {inject as service} from '@ember/service';
|
|
|
|
export default class EditWebhookRoute extends AdminRoute {
|
|
@service modals;
|
|
@service router;
|
|
|
|
webhook = null;
|
|
modal = null;
|
|
|
|
get integration() {
|
|
return this.modelFor('settings.integration');
|
|
}
|
|
|
|
model(params) {
|
|
return this.integration.webhooks.findBy('id', params.webhook_id);
|
|
}
|
|
|
|
setupController(controller, model) {
|
|
this.webhook = model;
|
|
|
|
this.modal = this.modals.open(WebhookFormModal, {
|
|
webhook: this.webhook
|
|
}, {
|
|
beforeClose: this.beforeModalClose
|
|
});
|
|
}
|
|
|
|
deactivate() {
|
|
this.webhook?.errors.clear();
|
|
this.webhook?.rollbackAttributes();
|
|
|
|
// 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.integration', this.integration);
|
|
}
|
|
}
|
|
}
|