open-consul/ui-v2/app/mixins/intention/with-actions.js
John Cowen 455dfe0a1b ui: Per Service Intentions Tab (#7615)
* Add model layer support for filtering intentions by service

* Add Route, Controller and template for services.show.intentions tab

We are still loading the intentions themselves in the parent Route for
the moment

* Load the intentions in in the parent route for the moment

* Temporarily add support for returning to history -1

Once we have an intention form underneath the service/intention tab this
will no longer be needed

* Add the new tab and enable blocking queries for it

* Add some further acceptance testing around intention listings
2020-05-12 17:14:26 +00:00

40 lines
1.3 KiB
JavaScript

import Mixin from '@ember/object/mixin';
import WithBlockingActions from 'consul-ui/mixins/with-blocking-actions';
import { get } from '@ember/object';
import { INTERNAL_SERVER_ERROR as HTTP_INTERNAL_SERVER_ERROR } from 'consul-ui/utils/http/status';
export default Mixin.create(WithBlockingActions, {
errorCreate: function(type, e) {
if (e && e.errors && e.errors[0]) {
const error = e.errors[0];
if (parseInt(error.status) === HTTP_INTERNAL_SERVER_ERROR) {
if (error.detail.indexOf('duplicate intention found:') === 0) {
return 'exists';
}
}
}
return type;
},
afterUpdate: function(item) {
if (get(this, 'history.length') > 0) {
return this.transitionTo(this.history[0].key, this.history[0].value);
}
return this._super(...arguments);
},
afterCreate: function(item) {
if (get(this, 'history.length') > 0) {
return this.transitionTo(this.history[0].key, this.history[0].value);
}
return this._super(...arguments);
},
afterDelete: function(item) {
if (get(this, 'history.length') > 0) {
return this.transitionTo(this.history[0].key, this.history[0].value);
}
if (this.routeName === 'dc.services.show') {
return this.transitionTo(this.routeName, this._router.currentRoute.params.name);
}
return this._super(...arguments);
},
});