open-nomad/ui/app/utils/generate-exec-url.js
Buck Doyle d4708860f0
UI: Fix exec popup link for job id ≠ name (#7815)
This closes #7814. It makes URL-generation more central and changes
the exec URL to include job id instead of name.
2020-04-29 07:54:04 -05:00

19 lines
692 B
JavaScript

export default function generateExecUrl(router, { job, taskGroup, task, allocation }) {
const queryParams = router.currentRoute.queryParams;
if (task) {
return router.urlFor('exec.task-group.task', job.plainId, taskGroup.name, task.name, {
queryParams: {
allocation: allocation.shortId,
...queryParams,
},
});
} else if (taskGroup) {
return router.urlFor('exec.task-group', job.plainId, taskGroup.name, { queryParams });
} else if (allocation) {
return router.urlFor('exec', job.plainId, { queryParams: { allocation: allocation.shortId, ...queryParams } });
} else {
return router.urlFor('exec', job.plainId, { queryParams });
}
}