open-nomad/ui/app/controllers/variables/index.js
Jai 7d90d22956
ui: add namespace filter to variables.index (#13618)
* ui: add namespace filter feature

ui:  add namespace filtering to variables.index

test:  namespace filter

refact:  fix action in template

ui:  move data fetching and query param logic to

ui:  controller query parameter logic

ui:  prevent  from forwarding query param

ui:  create variables controller

refact:  use dependency injection for controlling parent qp

chore: clean-up reset in  route

chore:  clean-up reset in  route

* ui:  add namespace filter to secure var form (#13629)

ui:  update variable factory to accept namespaces

refact:  update  api to accept disabled

ui:  add namespace setting logic to form

refact:  remove debugger

refact:  get correct selectors for

ui:  move data loading to namespace-filter component

chore:  prettify template

ui: update factory to handle namespace setting

refact:  remove inline styling for grid class

* ui:  fix placement of filter in `SecureVariablesForm` (#13762)

* refact:  conditionally render css class

* chore:  remove unused CSS property

* refact:  edit path-input class to prevent textarea override

* refact:  inject missing store service (#13763)

* chore:  patch fixes for when no default namespace is available (#13782)

* test:  add tests for namespace filtering conditions (#13816)

* test:  add tests for namespace filtering and namespaces appearing in form

* patch namespace related issue to saving and querying (#13825)

* refact:  use namespace id, not entity

* refact:  update adapter to edit request to include qp

* ui: early exit if no snapshot

* refact:  test passes wrong interface to method

* chore:  add missing url update URL builder

* refact:  model in  doesn't have absolutePath

* Align error message

* chore:  update tests (#13905)

* chore:  patch brittle tests with better selectors

* chore:  update assertion count

Co-authored-by: Phil Renaud <phil@riotindustries.com>
2022-07-22 16:05:35 -04:00

53 lines
1.1 KiB
JavaScript

import Controller, { inject as controller } from '@ember/controller';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
const ALL_NAMESPACE_WILDCARD = '*';
export default class VariablesIndexController extends Controller {
@service router;
@service store;
isForbidden = false;
@action
goToVariable(variable) {
this.router.transitionTo('variables.variable', variable.path);
}
@controller variables;
@action
setNamespace(namespace) {
this.variables.setNamespace(namespace);
}
get namespaceSelection() {
return this.variables.qpNamespace;
}
get hasVariables() {
return this.model.variables.length;
}
get root() {
return this.model.root;
}
get namespaceOptions() {
const namespaces = this.store
.peekAll('namespace')
.map(({ name }) => ({ key: name, label: name }));
if (namespaces.length <= 1) return null;
// Create default namespace selection
namespaces.unshift({
key: ALL_NAMESPACE_WILDCARD,
label: 'All (*)',
});
return namespaces;
}
}