2020-03-24 23:22:16 +00:00
|
|
|
export default function generateExecUrl(router, { job, taskGroup, task, allocation }) {
|
|
|
|
const queryParams = router.currentRoute.queryParams;
|
|
|
|
|
|
|
|
if (task) {
|
2020-04-29 12:54:04 +00:00
|
|
|
return router.urlFor('exec.task-group.task', job.plainId, taskGroup.name, task.name, {
|
2020-03-24 23:22:16 +00:00
|
|
|
queryParams: {
|
2020-04-29 12:54:04 +00:00
|
|
|
allocation: allocation.shortId,
|
2020-03-24 23:22:16 +00:00
|
|
|
...queryParams,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
} else if (taskGroup) {
|
2020-04-29 12:54:04 +00:00
|
|
|
return router.urlFor('exec.task-group', job.plainId, taskGroup.name, { queryParams });
|
2020-03-24 23:22:16 +00:00
|
|
|
} else if (allocation) {
|
2020-04-29 12:54:04 +00:00
|
|
|
return router.urlFor('exec', job.plainId, { queryParams: { allocation: allocation.shortId, ...queryParams } });
|
2020-03-24 23:22:16 +00:00
|
|
|
} else {
|
2020-04-29 12:54:04 +00:00
|
|
|
return router.urlFor('exec', job.plainId, { queryParams });
|
2020-03-24 23:22:16 +00:00
|
|
|
}
|
|
|
|
}
|