2020-05-14 19:09:09 +00:00
|
|
|
import { get } from '@ember/object';
|
|
|
|
|
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-05-14 19:09:09 +00:00
|
|
|
return router.urlFor('exec.task-group.task', get(job, 'plainId'), get(taskGroup, 'name'), get(task, 'name'), {
|
2020-03-24 23:22:16 +00:00
|
|
|
queryParams: {
|
2020-05-14 19:09:09 +00:00
|
|
|
allocation: get(allocation, 'shortId'),
|
2020-03-24 23:22:16 +00:00
|
|
|
...queryParams,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
} else if (taskGroup) {
|
2020-05-14 19:09:09 +00:00
|
|
|
return router.urlFor('exec.task-group', get(job, 'plainId'), get(taskGroup, 'name'), { queryParams });
|
2020-03-24 23:22:16 +00:00
|
|
|
} else if (allocation) {
|
2020-05-14 19:09:09 +00:00
|
|
|
return router.urlFor('exec', get(job, 'plainId'), { queryParams: { allocation: get(allocation, 'shortId'), ...queryParams } });
|
2020-03-24 23:22:16 +00:00
|
|
|
} else {
|
2020-05-14 19:09:09 +00:00
|
|
|
return router.urlFor('exec', get(job, 'plainId'), { queryParams });
|
2020-03-24 23:22:16 +00:00
|
|
|
}
|
|
|
|
}
|