github.com/hernad/nomad@v1.6.112/ui/app/controllers/policies/index.js (about)

     1  /**
     2   * Copyright (c) HashiCorp, Inc.
     3   * SPDX-License-Identifier: MPL-2.0
     4   */
     5  
     6  import Controller from '@ember/controller';
     7  import { inject as service } from '@ember/service';
     8  import { action } from '@ember/object';
     9  
    10  export default class PoliciesIndexController extends Controller {
    11    @service router;
    12    get policies() {
    13      return this.model.policies.map((policy) => {
    14        policy.tokens = (this.model.tokens || []).filter((token) => {
    15          return token.policies.includes(policy);
    16        });
    17        return policy;
    18      });
    19    }
    20  
    21    @action openPolicy(policy) {
    22      this.router.transitionTo('policies.policy', policy.name);
    23    }
    24  }