github.com/hernad/nomad@v1.6.112/ui/app/routes/jobs/run/templates/template.js (about)

     1  /**
     2   * Copyright (c) HashiCorp, Inc.
     3   * SPDX-License-Identifier: MPL-2.0
     4   */
     5  
     6  import Route from '@ember/routing/route';
     7  import { inject as service } from '@ember/service';
     8  import notifyForbidden from 'nomad-ui/utils/notify-forbidden';
     9  
    10  export default class JobsRunTemplatesTemplateRoute extends Route {
    11    @service can;
    12    @service router;
    13    @service store;
    14    @service system;
    15  
    16    beforeModel(transition) {
    17      if (
    18        this.can.cannot('write variable', null, {
    19          namespace: transition.to.queryParams.namespace,
    20        })
    21      ) {
    22        this.router.transitionTo('jobs.run');
    23      }
    24    }
    25  
    26    async model({ name }) {
    27      try {
    28        return this.store.findRecord('variable', name);
    29      } catch (e) {
    30        notifyForbidden(this)(e);
    31      }
    32    }
    33  }