github.com/outbrain/consul@v1.4.5/ui-v2/app/routes/dc/acls/policies/edit.js (about)

     1  import SingleRoute from 'consul-ui/routing/single';
     2  import { inject as service } from '@ember/service';
     3  import { hash } from 'rsvp';
     4  import { get } from '@ember/object';
     5  
     6  import WithPolicyActions from 'consul-ui/mixins/policy/with-actions';
     7  
     8  export default SingleRoute.extend(WithPolicyActions, {
     9    repo: service('repository/policy'),
    10    tokenRepo: service('repository/token'),
    11    datacenterRepo: service('repository/dc'),
    12    model: function(params) {
    13      const dc = this.modelFor('dc').dc.Name;
    14      const tokenRepo = get(this, 'tokenRepo');
    15      return this._super(...arguments).then(model => {
    16        return hash({
    17          ...model,
    18          ...{
    19            datacenters: get(this, 'datacenterRepo').findAll(),
    20            items: tokenRepo.findByPolicy(get(model.item, 'ID'), dc).catch(function(e) {
    21              switch (get(e, 'errors.firstObject.status')) {
    22                case '403':
    23                case '401':
    24                  // do nothing the SingleRoute will have caught it already
    25                  return;
    26              }
    27              throw e;
    28            }),
    29          },
    30        });
    31      });
    32    },
    33    setupController: function(controller, model) {
    34      this._super(...arguments);
    35      controller.setProperties(model);
    36    },
    37  });