Change exec URLs to use job’s namespace/region (#9968)

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.
This commit is contained in:
Buck Doyle 2021-02-04 13:14:15 -06:00 committed by GitHub
parent 3c6a3ba63d
commit 099162a55c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 8 deletions

View file

@ -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 = {

View file

@ -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] } },
});