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

Fix navigation via clicking recent allocation row #6087

Merged
merged 2 commits into from
Aug 8, 2019
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
5 changes: 4 additions & 1 deletion ui/app/components/job-page/parts/recent-allocations.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import Component from '@ember/component';
import { computed } from '@ember/object';
import { inject as service } from '@ember/service';
import PromiseArray from 'nomad-ui/utils/classes/promise-array';

export default Component.extend({
classNames: ['boxed-section'],

router: service(),

sortProperty: 'modifyIndex',
sortDescending: true,
sortedAllocations: computed('job.allocations.@each.modifyIndex', function() {
Expand All @@ -20,7 +23,7 @@ export default Component.extend({

actions: {
gotoAllocation(allocation) {
this.transitionToRoute('allocations.allocation', allocation);
this.router.transitionTo('allocations.allocation', allocation.id);
Copy link

Choose a reason for hiding this comment

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

any specific reason to reload the record?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I found that without the .id, I got this error:

You didn't provide enough string/numeric parameters to satisfy all of the dynamic segments for route

My belief is that it’s because the router is expecting allocation_id, but the model only has an id. Changing the router seemed like Too Much for this small fix.

},
},
});
13 changes: 13 additions & 0 deletions ui/tests/helpers/module-for-job.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ export default function moduleForJob(title, context, jobFactory, additionalTests
assert.ok(JobDetail.allocationsSummary, 'Allocations are shown in the summary section');
assert.notOk(JobDetail.childrenSummary, 'Children are not shown in the summary section');
});

test('clicking in an allocation row navigates to that allocation', async function(assert) {
const allocationRow = JobDetail.allocations[0];
const allocationId = allocationRow.id;

await allocationRow.visitRow();

assert.equal(
currentURL(),
`/allocations/${allocationId}`,
'Allocation row links to allocation detail'
);
});
}

if (context === 'children') {
Expand Down
1 change: 1 addition & 0 deletions ui/tests/pages/components/allocations.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default function(selector = '[data-test-allocation]', propKey = 'allocati
rescheduled: isPresent('[data-test-indicators] [data-test-icon="reschedule"]'),

visit: clickable('[data-test-short-id] a'),
visitRow: clickable(),
visitJob: clickable('[data-test-job]'),
visitClient: clickable('[data-test-client] a'),
}),
Expand Down