Skip to content

Commit

Permalink
Merge pull request #4801 from hashicorp/b-ui-proper-task-group-breadc…
Browse files Browse the repository at this point in the history
…rumb

UI: Proper task group breadcrumb on the allocation pages
  • Loading branch information
DingoEatingFuzz committed Nov 7, 2018
2 parents 31e21ae + 4e36c52 commit 7af84f3
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 6 deletions.
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'),
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'
);
});
});

0 comments on commit 7af84f3

Please sign in to comment.