Skip to content

Commit

Permalink
Change exec URLs to use job’s namespace/region
Browse files Browse the repository at this point in the history
This closes #9966. It was looking at the query parameters
for the namespace and region, but allocation (and task!)
routes don’t have a namespace query parameter. Since the URL
generator requires the job for all calls, it makes sense to
extract the namespace and region from the job instead.
  • Loading branch information
backspace committed Feb 4, 2021
1 parent e45a124 commit 3619d53
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
13 changes: 12 additions & 1 deletion ui/app/utils/generate-exec-url.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
import { get } from '@ember/object';

export default function generateExecUrl(router, { job, taskGroup, task, allocation }) {
const queryParams = router.currentRoute.queryParams;
const queryParams = {};

const namespace = get(job, 'namespace.name');
const region = get(job, 'region');

if (namespace) {
queryParams.namespace = namespace;
}

if (region) {
queryParams.region = region;
}

if (task) {
const queryParamsOptions = {
Expand Down
15 changes: 8 additions & 7 deletions ui/tests/unit/utils/generate-exec-url-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,15 @@ module('Unit | Utility | generate-exec-url', function(hooks) {
);
});

test('it includes query parameters from the current route', function(assert) {
this.router.currentRoute.queryParams = {
namespace: 'a-namespace',
region: 'a-region',
};

test('it includes job namespace and region when they exist', function(assert) {
generateExecUrl(this.router, {
job: { plainId: 'job-name' },
job: {
namespace: {
name: 'a-namespace',
},
plainId: 'job-name',
region: 'a-region',
},
allocation: { shortId: 'id', taskGroup: { name: 'task-group-name', tasks: [0, 1] } },
});

Expand Down

0 comments on commit 3619d53

Please sign in to comment.