2021-04-28 10:29:25 +03:00
|
|
|
import RSVP from 'rsvp';
|
2018-10-18 02:18:29 +03:00
|
|
|
import Route from '@ember/routing/route';
|
2021-04-28 10:29:25 +03:00
|
|
|
import {inject as service} from '@ember/service';
|
2018-10-18 02:18:29 +03:00
|
|
|
|
|
|
|
export default Route.extend({
|
2021-04-28 10:29:25 +03:00
|
|
|
limit: service(),
|
|
|
|
|
2018-10-18 02:18:29 +03:00
|
|
|
model() {
|
2021-04-28 10:29:25 +03:00
|
|
|
if (this.limit.limiter
|
|
|
|
&& this.limit.limiter.isLimited('customIntegrations')) {
|
|
|
|
return RSVP.hash({
|
|
|
|
integration: this.store.createRecord('integration'),
|
|
|
|
hostLimitError: this.limit.limiter.errorIfWouldGoOverLimit('customIntegrations')
|
|
|
|
.then(() => null)
|
|
|
|
.catch((error) => {
|
|
|
|
return error;
|
|
|
|
})
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
return RSVP.hash({
|
|
|
|
integration: this.store.createRecord('integration'),
|
|
|
|
hostLimitError: null
|
|
|
|
});
|
|
|
|
}
|
2018-10-18 02:18:29 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
deactivate() {
|
|
|
|
this._super(...arguments);
|
|
|
|
this.controller.integration.rollbackAttributes();
|
|
|
|
}
|
|
|
|
});
|