mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 11:34:24 +03:00
d0f6dd7fef
refs https://github.com/TryGhost/Team/issues/559 - switched to new ember-promise-modals pattern - removed controller and template in favor of opening modals directly from the route - removed unused `mousedown` event handlers - they are only necessary when an input blur would trigger validation errors - fixed Enter key not triggering create action by adding an `{{on-key "Enter"}}` event handler to the name input - fixed scroll not resetting to top of integrations screens when navigating between them by adding `{{scroll-top}}` element modifier to the main content sections
46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
import Route from '@ember/routing/route';
|
|
import {action} from '@ember/object';
|
|
import {inject as service} from '@ember/service';
|
|
|
|
export default class NewIntegrationRoute extends Route {
|
|
@service limit;
|
|
@service modals;
|
|
|
|
modal = null;
|
|
|
|
async model() {
|
|
if (this.limit.limiter?.isLimited('customIntegrations')) {
|
|
try {
|
|
await this.limit.limiter.errorIfWouldGoOverLimit('customIntegrations');
|
|
} catch (error) {
|
|
this.modal = this.modals.open('modals/limits/custom-integration', {
|
|
message: error.message
|
|
}, {
|
|
beforeClose: this.beforeModalClose
|
|
});
|
|
return;
|
|
}
|
|
}
|
|
|
|
this.modal = this.modals.open('modals/new-custom-integration', {}, {
|
|
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.isLeaving) {
|
|
this.transitionTo('settings.integrations');
|
|
}
|
|
}
|
|
}
|