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: Make task rows clickable. #4387

Merged
merged 1 commit into from
Jun 6, 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
11 changes: 11 additions & 0 deletions ui/app/controllers/allocations/allocation/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { alias } from '@ember/object/computed';
import Controller, { inject as controller } from '@ember/controller';
import Sortable from 'nomad-ui/mixins/sortable';
import { lazyClick } from 'nomad-ui/helpers/lazy-click';

export default Controller.extend(Sortable, {
allocationController: controller('allocations.allocation'),
Expand All @@ -17,4 +18,14 @@ export default Controller.extend(Sortable, {

listToSort: alias('model.states'),
sortedStates: alias('listSorted'),

actions: {
gotoTask(allocation, task) {
this.transitionToRoute('allocations.allocation.task', task);
},

taskClick(allocation, task, event) {
lazyClick([() => this.send('gotoTask', allocation, task), event]);
},
},
});
5 changes: 4 additions & 1 deletion ui/app/templates/allocations/allocation/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@
<th>Addresses</th>
{{/t.head}}
{{#t.body as |row|}}
<tr data-test-task-row={{row.model.task.name}}>
<tr
data-test-task-row={{row.model.task.name}}
onclick={{action "taskClick" row.model.allocation row.model}}
class="is-interactive">
<td class="is-narrow">
{{#if (not row.model.driverStatus.healthy)}}
<span data-test-icon="unhealthy-driver" class="tooltip text-center" aria-label="{{row.model.driver}} is unhealthy">
Expand Down
30 changes: 30 additions & 0 deletions ui/tests/acceptance/allocation-detail-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,36 @@ test('each task row should list high-level information for the task', function(a
});
});

test('each task row should link to the task detail page', function(assert) {
const task = server.db.taskStates.where({ allocationId: allocation.id }).sortBy('name')[0];

click('[data-test-task-row] [data-test-name] a');

andThen(() => {
assert.equal(
currentURL(),
`/allocations/${allocation.id}/${task.name}`,
'Task name in task row links to task detail'
);
});

andThen(() => {
visit(`/allocations/${allocation.id}`);
});

andThen(() => {
click('[data-test-task-row]');
});

andThen(() => {
assert.equal(
currentURL(),
`/allocations/${allocation.id}/${task.name}`,
'Task row links to task detail'
);
});
});

test('tasks with an unhealthy driver have a warning icon', function(assert) {
assert.ok(find('[data-test-task-row] [data-test-icon="unhealthy-driver"]'), 'Warning is shown');
});
Expand Down