mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-04 08:54:36 +03:00
ac17053863
closes TryGhost/Ghost#9942 - move custom integrations UI out from behind the developer experiments flag - put Admin API key and web hook secret fields behind the developer experiments flag - do not show "unsaved changes" modal when adding/editing a webhook - fixed all webhooks showing for each custom integration
66 lines
2.5 KiB
JavaScript
66 lines
2.5 KiB
JavaScript
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
|
|
import CurrentUserSettings from 'ghost-admin/mixins/current-user-settings';
|
|
import styleBody from 'ghost-admin/mixins/style-body';
|
|
|
|
export default AuthenticatedRoute.extend(styleBody, CurrentUserSettings, {
|
|
titleToken: 'Settings - Integrations',
|
|
classNames: ['settings-view-integration'],
|
|
|
|
beforeModel() {
|
|
this._super(...arguments);
|
|
return this.get('session.user')
|
|
.then(this.transitionAuthor())
|
|
.then(this.transitionEditor());
|
|
},
|
|
|
|
model(params, transition) {
|
|
let integration = this.store.peekRecord('integration', params.integration_id);
|
|
|
|
if (integration) {
|
|
return integration;
|
|
}
|
|
|
|
// integration is not already in the store so use the integrations controller
|
|
// to fetch all of them and pull out the one we're interested in. Using the
|
|
// integrations controller means it's possible to navigate back to the integrations
|
|
// screen without triggering a loading state
|
|
return this.controllerFor('settings.integrations')
|
|
.fetchIntegrations.perform()
|
|
.then((integrations) => {
|
|
let integration = integrations.findBy('id', params.integration_id);
|
|
|
|
if (!integration) {
|
|
let path = transition.intent.url.replace(/^\//, '');
|
|
return this.replaceWith('error404', {path, status: 404});
|
|
}
|
|
|
|
return integration;
|
|
});
|
|
},
|
|
|
|
actions: {
|
|
save() {
|
|
this.controller.send('save');
|
|
},
|
|
|
|
willTransition(transition) {
|
|
let {controller} = this;
|
|
|
|
// check to see if we're navigating away from the custom integration
|
|
// route - we want to allow editing webhooks without showing the
|
|
// "unsaved changes" confirmation modal
|
|
let isExternalRoute =
|
|
// allow sub-routes of settings.integration
|
|
!transition.targetName.match(/^settings\.integration\./)
|
|
// do not allow changes in integration
|
|
|| transition.params['settings.integration'].integration_id !== controller.integration.id;
|
|
|
|
if (isExternalRoute && !controller.integration.isDeleted && controller.integration.hasDirtyAttributes) {
|
|
transition.abort();
|
|
controller.send('toggleUnsavedChangesModal', transition);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
});
|