From a475d59513f4612edebedfbb6ee936a102b503bb Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Thu, 19 Oct 2017 22:30:10 -0700 Subject: [PATCH] Switch from href-to to link-to for QP persistence See this issue: https://github.com/intercom/ember-href-to/issues/62 --- ui/app/helpers/href-to-spread.js | 18 ------------------ ui/app/templates/allocations/allocation.hbs | 4 ++-- ui/app/templates/components/allocation-row.hbs | 8 ++++---- .../templates/components/client-node-row.hbs | 2 +- ui/app/templates/components/job-row.hbs | 2 +- .../templates/components/server-agent-row.hbs | 2 +- ui/app/templates/components/task-group-row.hbs | 6 +++++- ui/app/templates/jobs/job/definition.hbs | 2 +- ui/app/templates/jobs/job/deployments.hbs | 2 +- ui/app/templates/jobs/job/index.hbs | 2 +- ui/app/templates/jobs/job/loading.hbs | 2 +- ui/app/templates/jobs/job/task-group.hbs | 2 +- ui/app/templates/jobs/job/versions.hbs | 2 +- ui/app/templates/nodes/node.hbs | 2 +- ui/tests/acceptance/job-detail-test.js | 18 ++++++++++++++++-- 15 files changed, 37 insertions(+), 37 deletions(-) delete mode 100644 ui/app/helpers/href-to-spread.js diff --git a/ui/app/helpers/href-to-spread.js b/ui/app/helpers/href-to-spread.js deleted file mode 100644 index 3c7d76d1b..000000000 --- a/ui/app/helpers/href-to-spread.js +++ /dev/null @@ -1,18 +0,0 @@ -import Ember from 'ember'; -import hrefTo from 'ember-href-to/helpers/href-to'; - -const { Helper } = Ember; - -/** - * Href-to Spread - * - * Usage: {{href-to-spread hrefToPositionalParamsAsArray query=whatever}} - * - * Does the same thing as href-to but takes an array of arguments instead of a static list. - * This way arguments can be managed in js and provided to the template. - */ -export default Helper.extend({ - compute([params], options = {}) { - return hrefTo.create().compute.call(this, params, options); - }, -}); diff --git a/ui/app/templates/allocations/allocation.hbs b/ui/app/templates/allocations/allocation.hbs index 2e5cbbfb5..6c5fbbff8 100644 --- a/ui/app/templates/allocations/allocation.hbs +++ b/ui/app/templates/allocations/allocation.hbs @@ -1,8 +1,8 @@

Allocation {{model.name}}

- For job {{model.job.name}} - on node {{model.node.shortId}} + For job {{#link-to "jobs.job" model.job}}{{model.job.name}}{{/link-to}} + on node {{#link-to "nodes.node" model.node}}{{model.node.shortId}}{{/link-to}}

diff --git a/ui/app/templates/components/allocation-row.hbs b/ui/app/templates/components/allocation-row.hbs index 00feb779e..09b71a53b 100644 --- a/ui/app/templates/components/allocation-row.hbs +++ b/ui/app/templates/components/allocation-row.hbs @@ -1,7 +1,7 @@ - + {{#link-to "allocations.allocation" allocation class="is-primary"}} {{allocation.shortId}} - + {{/link-to}} {{allocation.modifyIndex}} {{allocation.name}} @@ -10,13 +10,13 @@ {{#if (eq context "job")}} {{allocation.jobVersion}} - {{allocation.node.shortId}} + {{#link-to "nodes.node" allocation.node}}{{allocation.node.shortId}}{{/link-to}} {{else if (eq context "node")}} {{#if (or allocation.job.isPending allocation.job.isReloading)}} ... {{else}} - {{allocation.job.name}} + {{#link-to "jobs.job" allocation.job}}{{allocation.job.name}}{{/link-to}} / {{allocation.taskGroup.name}} {{/if}} diff --git a/ui/app/templates/components/client-node-row.hbs b/ui/app/templates/components/client-node-row.hbs index a49a7e5e8..7eedfd4b5 100644 --- a/ui/app/templates/components/client-node-row.hbs +++ b/ui/app/templates/components/client-node-row.hbs @@ -1,4 +1,4 @@ -{{node.shortId}} +{{#link-to "nodes.node" node.id class="is-primary"}}{{node.shortId}}{{/link-to}} {{node.name}} {{node.status}} {{node.address}} diff --git a/ui/app/templates/components/job-row.hbs b/ui/app/templates/components/job-row.hbs index 94e0118bd..39b04e86f 100644 --- a/ui/app/templates/components/job-row.hbs +++ b/ui/app/templates/components/job-row.hbs @@ -1,4 +1,4 @@ -{{job.name}} +{{#link-to "jobs.job" job.id class="is-primary"}}{{job.name}}{{/link-to}} {{job.status}} diff --git a/ui/app/templates/components/server-agent-row.hbs b/ui/app/templates/components/server-agent-row.hbs index e74c0d4b4..6a5779b3d 100644 --- a/ui/app/templates/components/server-agent-row.hbs +++ b/ui/app/templates/components/server-agent-row.hbs @@ -1,4 +1,4 @@ -{{agent.name}} +{{#link-to "servers.server" agent.id class="is-primary"}}{{agent.name}}{{/link-to}} {{agent.status}} {{if agent.isLeader "True" "False"}} {{agent.address}} diff --git a/ui/app/templates/components/task-group-row.hbs b/ui/app/templates/components/task-group-row.hbs index 36e95c60c..f37f720b2 100644 --- a/ui/app/templates/components/task-group-row.hbs +++ b/ui/app/templates/components/task-group-row.hbs @@ -1,4 +1,8 @@ -{{taskGroup.name}} + + {{#link-to "jobs.job.task-group" taskGroup.job taskGroup class="is-primary"}} + {{taskGroup.name}} + {{/link-to}} + {{taskGroup.count}}
{{allocation-status-bar allocationContainer=taskGroup.summary isNarrow=true}}
diff --git a/ui/app/templates/jobs/job/definition.hbs b/ui/app/templates/jobs/job/definition.hbs index 1d528f8f5..f566613c6 100644 --- a/ui/app/templates/jobs/job/definition.hbs +++ b/ui/app/templates/jobs/job/definition.hbs @@ -1,6 +1,6 @@ {{#global-header class="page-header"}} {{#each breadcrumbs as |breadcrumb|}} - {{breadcrumb.label}} + {{#link-to params=breadcrumb.args class="breadcrumb"}}{{breadcrumb.label}}{{/link-to}} {{/each}} {{/global-header}} {{#gutter-menu class="page-body"}} diff --git a/ui/app/templates/jobs/job/deployments.hbs b/ui/app/templates/jobs/job/deployments.hbs index b83b05ff4..b08222656 100644 --- a/ui/app/templates/jobs/job/deployments.hbs +++ b/ui/app/templates/jobs/job/deployments.hbs @@ -1,6 +1,6 @@ {{#global-header class="page-header"}} {{#each breadcrumbs as |breadcrumb|}} - {{breadcrumb.label}} + {{#link-to params=breadcrumb.args class="breadcrumb"}}{{breadcrumb.label}}{{/link-to}} {{/each}} {{/global-header}} {{#gutter-menu class="page-body"}} diff --git a/ui/app/templates/jobs/job/index.hbs b/ui/app/templates/jobs/job/index.hbs index ff87e81e9..53cde8e21 100644 --- a/ui/app/templates/jobs/job/index.hbs +++ b/ui/app/templates/jobs/job/index.hbs @@ -1,6 +1,6 @@ {{#global-header class="page-header"}} {{#each breadcrumbs as |breadcrumb|}} - {{breadcrumb.label}} + {{#link-to params=breadcrumb.args class="breadcrumb"}}{{breadcrumb.label}}{{/link-to}} {{/each}} {{/global-header}} {{#gutter-menu class="page-body"}} diff --git a/ui/app/templates/jobs/job/loading.hbs b/ui/app/templates/jobs/job/loading.hbs index 072715949..503faa81f 100644 --- a/ui/app/templates/jobs/job/loading.hbs +++ b/ui/app/templates/jobs/job/loading.hbs @@ -1,6 +1,6 @@ {{#global-header class="page-header"}} {{#each breadcrumbs as |breadcrumb|}} - {{breadcrumb.label}} + {{#link-to params=breadcrumb.args class="breadcrumb"}}{{breadcrumb.label}}{{/link-to}} {{/each}} {{/global-header}} {{#gutter-menu class="page-body"}} diff --git a/ui/app/templates/jobs/job/task-group.hbs b/ui/app/templates/jobs/job/task-group.hbs index 0dfa0afcc..ea67b29d1 100644 --- a/ui/app/templates/jobs/job/task-group.hbs +++ b/ui/app/templates/jobs/job/task-group.hbs @@ -1,6 +1,6 @@ {{#global-header class="page-header"}} {{#each breadcrumbs as |breadcrumb|}} - {{breadcrumb.label}} + {{#link-to params=breadcrumb.args class="breadcrumb"}}{{breadcrumb.label}}{{/link-to}} {{/each}} {{/global-header}} {{#gutter-menu class="page-body"}} diff --git a/ui/app/templates/jobs/job/versions.hbs b/ui/app/templates/jobs/job/versions.hbs index 279e2a9ea..2f3f05d5f 100644 --- a/ui/app/templates/jobs/job/versions.hbs +++ b/ui/app/templates/jobs/job/versions.hbs @@ -1,6 +1,6 @@ {{#global-header class="page-header"}} {{#each breadcrumbs as |breadcrumb|}} - {{breadcrumb.label}} + {{#link-to params=breadcrumb.args class="breadcrumb"}}{{breadcrumb.label}}{{/link-to}} {{/each}} {{/global-header}} {{#gutter-menu class="page-body"}} diff --git a/ui/app/templates/nodes/node.hbs b/ui/app/templates/nodes/node.hbs index e6a70bd3a..0b13a4920 100644 --- a/ui/app/templates/nodes/node.hbs +++ b/ui/app/templates/nodes/node.hbs @@ -1,5 +1,5 @@ {{#global-header class="page-header"}} - Nodes + {{#link-to "nodes" class="breadcrumb"}}Nodes{{/link-to}} {{model.shortId}} {{/global-header}} {{#gutter-menu class="page-body"}} diff --git a/ui/tests/acceptance/job-detail-test.js b/ui/tests/acceptance/job-detail-test.js index 140267d6a..f8bedf8bc 100644 --- a/ui/tests/acceptance/job-detail-test.js +++ b/ui/tests/acceptance/job-detail-test.js @@ -58,8 +58,22 @@ test('each row in the task group table should show basic information about the t const tasks = server.db.tasks.where({ taskGroupId: taskGroup.id }); const sum = (list, key) => list.reduce((sum, item) => sum + get(item, key), 0); - assert.equal(taskGroupRow.find('td:eq(0)').text(), taskGroup.name, 'Name'); - assert.equal(taskGroupRow.find('td:eq(1)').text(), taskGroup.count, 'Count'); + assert.equal( + taskGroupRow + .find('td:eq(0)') + .text() + .trim(), + taskGroup.name, + 'Name' + ); + assert.equal( + taskGroupRow + .find('td:eq(1)') + .text() + .trim(), + taskGroup.count, + 'Count' + ); assert.equal( taskGroupRow.find('td:eq(3)').text(), `${sum(tasks, 'Resources.CPU')} MHz`,