diff --git a/ui/app/models/job.js b/ui/app/models/job.js index 43c4b1225..18d74b8ff 100644 --- a/ui/app/models/job.js +++ b/ui/app/models/job.js @@ -55,6 +55,8 @@ export default Model.extend({ deployments: hasMany('deployments'), namespace: belongsTo('namespace'), + supportsDeployments: computed.equal('type', 'service'), + runningDeployment: computed('deployments.@each.status', function() { return this.get('deployments').findBy('status', 'running'); }), diff --git a/ui/app/templates/jobs/job/subnav.hbs b/ui/app/templates/jobs/job/subnav.hbs index 77e44a2f1..63e712a6c 100644 --- a/ui/app/templates/jobs/job/subnav.hbs +++ b/ui/app/templates/jobs/job/subnav.hbs @@ -3,6 +3,8 @@
  • {{#link-to "jobs.job.index" job activeClass="is-active"}}Overview{{/link-to}}
  • {{#link-to "jobs.job.definition" job activeClass="is-active"}}Definition{{/link-to}}
  • {{#link-to "jobs.job.versions" job activeClass="is-active"}}Versions{{/link-to}}
  • -
  • {{#link-to "jobs.job.deployments" job activeClass="is-active"}}Deployments{{/link-to}}
  • + {{#if job.supportsDeployments}} +
  • {{#link-to "jobs.job.deployments" job activeClass="is-active"}}Deployments{{/link-to}}
  • + {{/if}} diff --git a/ui/tests/acceptance/job-detail-test.js b/ui/tests/acceptance/job-detail-test.js index 59d200cd3..512c572e4 100644 --- a/ui/tests/acceptance/job-detail-test.js +++ b/ui/tests/acceptance/job-detail-test.js @@ -12,8 +12,7 @@ let job; moduleForAcceptance('Acceptance | job detail', { beforeEach() { server.create('node'); - server.create('job'); - job = server.db.jobs[0]; + job = server.create('job', { type: 'service' }); visit(`/jobs/${job.id}`); }, }); @@ -36,6 +35,27 @@ test('breadcrumbs includes job name and link back to the jobs list', function(as }); }); +test('the subnav includes links to definition, versions, and deployments when type = service', function( + assert +) { + const subnavLabels = findAll('.tabs.is-subnav a').map(anchor => anchor.textContent); + assert.ok(subnavLabels.some(label => label === 'Definition'), 'Definition link'); + assert.ok(subnavLabels.some(label => label === 'Versions'), 'Versions link'); + assert.ok(subnavLabels.some(label => label === 'Deployments'), 'Deployments link'); +}); + +test('the subnav includes links to definition and versions when type != service', function(assert) { + job = server.create('job', { type: 'batch' }); + visit(`/jobs/${job.id}`); + + andThen(() => { + const subnavLabels = findAll('.tabs.is-subnav a').map(anchor => anchor.textContent); + assert.ok(subnavLabels.some(label => label === 'Definition'), 'Definition link'); + assert.ok(subnavLabels.some(label => label === 'Versions'), 'Versions link'); + assert.notOk(subnavLabels.some(label => label === 'Deployments'), 'Deployments link'); + }); +}); + test('the job detail page should contain basic information about the job', function(assert) { assert.ok(findAll('.title .tag')[0].textContent.includes(job.status), 'Status'); assert.ok(findAll('.job-stats span')[0].textContent.includes(job.type), 'Type'); @@ -150,7 +170,7 @@ test('there is no active deployment section when the job has no active deploymen ) { // TODO: it would be better to not visit two different job pages in one test, but this // way is much more convenient. - job = server.create('job', { noActiveDeployment: true }); + job = server.create('job', { noActiveDeployment: true, type: 'service' }); visit(`/jobs/${job.id}`); andThen(() => { @@ -161,7 +181,7 @@ test('there is no active deployment section when the job has no active deploymen test('the active deployment section shows up for the currently running deployment', function( assert ) { - job = server.create('job', { activeDeployment: true }); + job = server.create('job', { activeDeployment: true, type: 'service' }); const deployment = server.db.deployments.where({ jobId: job.id })[0]; const taskGroupSummaries = server.db.deploymentTaskGroupSummaries.where({ deploymentId: deployment.id, @@ -246,7 +266,7 @@ test('the active deployment section shows up for the currently running deploymen test('the active deployment section can be expanded to show task groups and allocations', function( assert ) { - job = server.create('job', { activeDeployment: true }); + job = server.create('job', { activeDeployment: true, type: 'service' }); visit(`/jobs/${job.id}`); andThen(() => {