github.com/outbrain/consul@v1.4.5/ui-v2/app/mixins/kv/with-actions.js (about) 1 import Mixin from '@ember/object/mixin'; 2 import { get, set } from '@ember/object'; 3 import WithBlockingActions from 'consul-ui/mixins/with-blocking-actions'; 4 5 export default Mixin.create(WithBlockingActions, { 6 // afterCreate just calls afterUpdate 7 afterUpdate: function(item, parent) { 8 const key = get(parent, 'Key'); 9 if (key === '/') { 10 return this.transitionTo('dc.kv.index'); 11 } else { 12 return this.transitionTo('dc.kv.folder', key); 13 } 14 }, 15 afterDelete: function(item, parent) { 16 if (this.routeName === 'dc.kv.folder') { 17 return this.refresh(); 18 } 19 return this._super(...arguments); 20 }, 21 actions: { 22 invalidateSession: function(item) { 23 const controller = this.controller; 24 const repo = get(this, 'sessionRepo'); 25 return get(this, 'feedback').execute(() => { 26 return repo.remove(item).then(() => { 27 const item = get(controller, 'item'); 28 set(item, 'Session', null); 29 delete item.Session; 30 set(controller, 'session', null); 31 }); 32 }, 'delete'); 33 }, 34 }, 35 });