github.com/outbrain/consul@v1.4.5/ui-v2/app/routing/single.js (about)

     1  import Route from '@ember/routing/route';
     2  import { get } from '@ember/object';
     3  import { assert } from '@ember/debug';
     4  import { Promise, hash } from 'rsvp';
     5  export default Route.extend({
     6    // repo: service('repositoryName'),
     7    isCreate: function(params, transition) {
     8      return transition.targetName.split('.').pop() === 'create';
     9    },
    10    model: function(params, transition) {
    11      const repo = get(this, 'repo');
    12      assert(
    13        "`repo` is undefined, please define RepositoryService using `repo: service('repositoryName')`",
    14        typeof repo !== 'undefined'
    15      );
    16      const dc = this.modelFor('dc').dc.Name;
    17      const create = this.isCreate(...arguments);
    18      return hash({
    19        isLoading: false,
    20        create: create,
    21        ...repo.status({
    22          item: create
    23            ? Promise.resolve(repo.create({ Datacenter: dc }))
    24            : repo.findBySlug(params.id, dc),
    25        }),
    26      });
    27    },
    28  });