Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: Add handling for allocation-less exec URL #8856

Merged
merged 1 commit into from
Sep 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions ui/app/utils/generate-exec-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,21 @@ export default function generateExecUrl(router, { job, taskGroup, task, allocati
const queryParams = router.currentRoute.queryParams;

if (task) {
const queryParamsOptions = {
...queryParams,
};

if (allocation) {
queryParamsOptions.allocation = get(allocation, 'shortId');
}

return router.urlFor(
'exec.task-group.task',
get(job, 'plainId'),
get(taskGroup, 'name'),
get(task, 'name'),
{
queryParams: {
allocation: get(allocation, 'shortId'),
...queryParams,
},
queryParams: queryParamsOptions,
}
);
} else if (taskGroup) {
Expand Down
12 changes: 12 additions & 0 deletions ui/tests/unit/utils/generate-exec-url-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ module('Unit | Utility | generate-exec-url', function(hooks) {
);
});

test('it generates an exec task URL without an allocation', function(assert) {
generateExecUrl(this.router, {
job: { plainId: 'job-name' },
taskGroup: { name: 'task-group-name' },
task: { name: 'task-name' },
});

assert.ok(
this.urlForSpy.calledWith('exec.task-group.task', 'job-name', 'task-group-name', 'task-name')
);
});

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