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: Proper task group breadcrumb on the allocation pages #4801

Merged
merged 2 commits into from
Nov 7, 2018
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
12 changes: 7 additions & 5 deletions ui/app/routes/allocations/allocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@ export default Route.extend(WithWatchers, {
// Allocation breadcrumbs extend from job / task group breadcrumbs
// even though the route structure does not.
breadcrumbs(model) {
const jobQueryParams = qpBuilder({
jobNamespace: model.get('job.namespace.name') || 'default',
});

return [
{ label: 'Jobs', args: ['jobs.index'] },
{ label: 'Jobs', args: ['jobs.index', jobQueryParams] },
...jobCrumbs(model.get('job')),
{
label: model.get('taskGroupName'),
args: [
'jobs.job.task-group',
model.get('job'),
model.get('job.plainId'),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was job.name, which meant the job route was attempting to fetch a job with the wrong ID in the event that name and plainId aren't equal (which is rare but possible).

model.get('taskGroupName'),
qpBuilder({
jobNamespace: model.get('namespace.name') || 'default',
}),
jobQueryParams,
],
},
{
Expand Down
1 change: 1 addition & 0 deletions ui/app/routes/jobs/job/task-group.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default Route.extend(WithWatchers, {
label: model.get('name'),
args: [
'jobs.job.task-group',
model.get('job'),
model.get('name'),
qpBuilder({ jobNamespace: model.get('job.namespace.name') || 'default' }),
],
Expand Down
2 changes: 1 addition & 1 deletion ui/app/services/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default Service.extend({

// If the namespace in localStorage is no longer in the cluster, it needs to
// be cleared from localStorage
this.set('activeNamespace', null);
window.localStorage.removeItem('nomadActiveNamespace');
return this.get('namespaces').findBy('id', 'default');
},
set(key, value) {
Expand Down
67 changes: 67 additions & 0 deletions ui/tests/acceptance/task-detail-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,70 @@ moduleForAcceptance('Acceptance | task detail (no addresses)', {
test('when the task has no addresses, the addresses table is not shown', function(assert) {
assert.notOk(Task.hasAddresses, 'No addresses table');
});

moduleForAcceptance('Acceptance | task detail (different namespace)', {
beforeEach() {
server.create('agent');
server.create('node');
server.create('namespace');
server.create('namespace', { id: 'other-namespace' });
server.create('job', { createAllocations: false, namespaceId: 'other-namespace' });
allocation = server.create('allocation', 'withTaskWithPorts');
task = server.db.taskStates.where({ allocationId: allocation.id })[0];

Task.visit({ id: allocation.id, name: task.name });
},
});

test('breadcrumbs match jobs / job / task group / allocation / task', function(assert) {
const { jobId, taskGroup } = allocation;
const job = server.db.jobs.find(jobId);

Task.breadcrumbFor('jobs.index').visit();
andThen(() => {
assert.equal(
currentURL(),
'/jobs?namespace=other-namespace',
'Jobs breadcrumb links correctly'
);
});
andThen(() => {
Task.visit({ id: allocation.id, name: task.name });
});
andThen(() => {
Task.breadcrumbFor('jobs.job.index').visit();
});
andThen(() => {
assert.equal(
currentURL(),
`/jobs/${job.id}?namespace=other-namespace`,
'Job breadcrumb links correctly'
);
});
andThen(() => {
Task.visit({ id: allocation.id, name: task.name });
});
andThen(() => {
Task.breadcrumbFor('jobs.job.task-group').visit();
});
andThen(() => {
assert.equal(
currentURL(),
`/jobs/${job.id}/${taskGroup}?namespace=other-namespace`,
'Task Group breadcrumb links correctly'
);
});
andThen(() => {
Task.visit({ id: allocation.id, name: task.name });
});
andThen(() => {
Task.breadcrumbFor('allocations.allocation').visit();
});
andThen(() => {
assert.equal(
currentURL(),
`/allocations/${allocation.id}`,
'Allocations breadcrumb links correctly'
);
});
});