2022-01-17 13:05:27 +03:00
|
|
|
import AdminRoute from 'ghost-admin/routes/admin';
|
2022-09-08 11:18:56 +03:00
|
|
|
import WebhookFormModal from '../../../../components/settings/integrations/webhook-form-modal';
|
|
|
|
import {action} from '@ember/object';
|
|
|
|
import {inject as service} from '@ember/service';
|
|
|
|
|
|
|
|
export default class NewWebhookRoute extends AdminRoute {
|
|
|
|
@service modals;
|
|
|
|
@service router;
|
|
|
|
|
|
|
|
webhook = null;
|
|
|
|
modal = null;
|
|
|
|
|
|
|
|
get integration() {
|
|
|
|
return this.modelFor('settings.integration');
|
|
|
|
}
|
2021-10-18 15:46:29 +03:00
|
|
|
|
|
|
|
model() {
|
2022-09-08 11:18:56 +03:00
|
|
|
this.webhook = this.store.createRecord('webhook', {integration: this.integration});
|
|
|
|
|
|
|
|
this.modal = this.modals.open(WebhookFormModal, {
|
|
|
|
webhook: this.webhook
|
|
|
|
}, {
|
|
|
|
beforeClose: this.beforeModalClose
|
|
|
|
});
|
2022-01-17 12:34:55 +03:00
|
|
|
}
|
2021-10-18 15:46:29 +03:00
|
|
|
|
|
|
|
deactivate() {
|
2022-09-08 11:18:56 +03:00
|
|
|
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);
|
|
|
|
}
|
2021-10-18 15:46:29 +03:00
|
|
|
}
|
2022-01-17 12:34:55 +03:00
|
|
|
}
|