Skip to content

Commit

Permalink
ui: set namespace when querying eval
Browse files Browse the repository at this point in the history
Evals have a unique UUID as ID, but when querying them the Nomad API
still expects a namespace query param, otherwise it assumes `default`.
  • Loading branch information
lgfa29 committed Jul 8, 2022
1 parent fe3a7f6 commit 75e70c0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .changelog/13530.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
```release-note:bug
api: Fix listing evaluations with the wildcard namespace and an ACL token
```

```release-note:bug
ui: Fix a bug that prevented viewing the details of an evaluation in a non-default namespace
```
6 changes: 4 additions & 2 deletions ui/app/adapters/evaluation.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ export default class EvaluationAdapter extends ApplicationAdapter {
}

urlForFindRecord(_id, _modelName, snapshot) {
const url = super.urlForFindRecord(...arguments);
const namespace = snapshot.attr('namespace') || 'default';
const baseURL = super.urlForFindRecord(...arguments);
const url = `${baseURL}?namespace=${namespace}`;

if (snapshot.adapterOptions?.related) {
return `${url}?related=true`;
return `${url}&related=true`;
}
return url;
}
Expand Down
9 changes: 8 additions & 1 deletion ui/tests/acceptance/evaluations-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,14 @@ module('Acceptance | evaluations list', function (hooks) {
module('evaluation detail', function () {
test('clicking an evaluation opens the detail view', async function (assert) {
server.get('/evaluations', getStandardRes);
server.get('/evaluation/:id', function (_, { params }) {
server.get('/evaluation/:id', function (_, { queryParams, params }) {
const expectedNamespaces = ['default', 'ted-lasso'];
assert.notEqual(
expectedNamespaces.indexOf(queryParams.namespace),
-1,
'Eval details request has namespace query param'
);

return { ...generateAcceptanceTestEvalMock(params.id), ID: params.id };
});

Expand Down

0 comments on commit 75e70c0

Please sign in to comment.