github.com/hernad/nomad@v1.6.112/ui/app/controllers/variables/index.js (about) 1 /** 2 * Copyright (c) HashiCorp, Inc. 3 * SPDX-License-Identifier: MPL-2.0 4 */ 5 6 import Controller, { inject as controller } from '@ember/controller'; 7 import { inject as service } from '@ember/service'; 8 import { action } from '@ember/object'; 9 10 const ALL_NAMESPACE_WILDCARD = '*'; 11 12 export default class VariablesIndexController extends Controller { 13 @service router; 14 @service store; 15 16 isForbidden = false; 17 18 @action 19 goToVariable(variable) { 20 this.router.transitionTo('variables.variable', variable.path); 21 } 22 23 @action goToNewVariable() { 24 this.router.transitionTo('variables.new'); 25 } 26 27 @controller variables; 28 29 @action 30 setNamespace(namespace) { 31 this.variables.setNamespace(namespace); 32 } 33 34 get namespaceSelection() { 35 return this.variables.qpNamespace; 36 } 37 38 get hasVariables() { 39 return this.model.variables.length; 40 } 41 42 get root() { 43 return this.model.root; 44 } 45 46 get namespaceOptions() { 47 const namespaces = this.store 48 .peekAll('namespace') 49 .map(({ name }) => ({ key: name, label: name })); 50 51 if (namespaces.length <= 1) return null; 52 53 // Create default namespace selection 54 namespaces.unshift({ 55 key: ALL_NAMESPACE_WILDCARD, 56 label: 'All (*)', 57 }); 58 59 return namespaces; 60 } 61 }