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

     1  /**
     2   * Copyright (c) HashiCorp, Inc.
     3   * SPDX-License-Identifier: MPL-2.0
     4   */
     5  
     6  // @ts-check
     7  import Route from '@ember/routing/route';
     8  import { inject as service } from '@ember/service';
     9  
    10  export default class JobsRunTemplatesIndexRoute extends Route {
    11    @service can;
    12    @service router;
    13    @service store;
    14  
    15    beforeModel() {
    16      const hasPermissions = this.can.can('write variable', null, {
    17        namespace: '*',
    18        path: '*',
    19      });
    20  
    21      if (!hasPermissions) {
    22        this.router.transitionTo('jobs');
    23      }
    24    }
    25  
    26    model() {
    27      return this.store.adapterFor('variable').getJobTemplates();
    28    }
    29  
    30    resetController(controller) {
    31      controller.set('selectedTemplate', null);
    32    }
    33  }