Files
nomad/ui/app/adapters/variable.js
Jai 6602659d61 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

48 lines
1.3 KiB
JavaScript

import ApplicationAdapter from './application';
import { pluralize } from 'ember-inflector';
import classic from 'ember-classic-decorator';
@classic
export default class VariableAdapter extends ApplicationAdapter {
pathForType = () => 'var';
// PUT instead of POST on create;
// /v1/var instead of /v1/vars on create (urlForFindRecord)
createRecord(_store, _type, snapshot) {
let data = this.serialize(snapshot);
return this.ajax(
this.urlForFindRecord(snapshot.id, snapshot.modelName),
'PUT',
{ data }
);
}
urlForFindAll(modelName) {
let baseUrl = this.buildURL(modelName);
return pluralize(baseUrl);
}
urlForQuery(_query, modelName) {
let baseUrl = this.buildURL(modelName);
return pluralize(baseUrl);
}
urlForFindRecord(id, modelName, snapshot) {
const namespace = snapshot?.attr('namespace') || 'default';
let baseUrl = this.buildURL(modelName, id, snapshot);
return `${baseUrl}?namespace=${namespace}`;
}
urlForUpdateRecord(id, modelName) {
return this.buildURL(modelName, id);
}
urlForDeleteRecord(id, modelName, snapshot) {
const namespace = snapshot?.attr('namespace') || 'default';
const baseUrl = this.buildURL(modelName, id);
return `${baseUrl}?namespace=${namespace}`;
}
}