Merge pull request #3439 from hashicorp/b-ui-hide-deployments-tab-based-on-type

Don't show the deployments tab for non-service jobs
This commit is contained in:
Michael Lange 2017-10-24 16:39:47 -07:00 committed by GitHub
commit 53211f9175
3 changed files with 30 additions and 6 deletions

View File

@ -55,6 +55,8 @@ export default Model.extend({
deployments: hasMany('deployments'), deployments: hasMany('deployments'),
namespace: belongsTo('namespace'), namespace: belongsTo('namespace'),
supportsDeployments: computed.equal('type', 'service'),
runningDeployment: computed('deployments.@each.status', function() { runningDeployment: computed('deployments.@each.status', function() {
return this.get('deployments').findBy('status', 'running'); return this.get('deployments').findBy('status', 'running');
}), }),

View File

@ -3,6 +3,8 @@
<li>{{#link-to "jobs.job.index" job activeClass="is-active"}}Overview{{/link-to}}</li> <li>{{#link-to "jobs.job.index" job activeClass="is-active"}}Overview{{/link-to}}</li>
<li>{{#link-to "jobs.job.definition" job activeClass="is-active"}}Definition{{/link-to}}</li> <li>{{#link-to "jobs.job.definition" job activeClass="is-active"}}Definition{{/link-to}}</li>
<li>{{#link-to "jobs.job.versions" job activeClass="is-active"}}Versions{{/link-to}}</li> <li>{{#link-to "jobs.job.versions" job activeClass="is-active"}}Versions{{/link-to}}</li>
<li>{{#link-to "jobs.job.deployments" job activeClass="is-active"}}Deployments{{/link-to}}</li> {{#if job.supportsDeployments}}
<li>{{#link-to "jobs.job.deployments" job activeClass="is-active"}}Deployments{{/link-to}}</li>
{{/if}}
</ul> </ul>
</div> </div>

View File

@ -12,8 +12,7 @@ let job;
moduleForAcceptance('Acceptance | job detail', { moduleForAcceptance('Acceptance | job detail', {
beforeEach() { beforeEach() {
server.create('node'); server.create('node');
server.create('job'); job = server.create('job', { type: 'service' });
job = server.db.jobs[0];
visit(`/jobs/${job.id}`); 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) { 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('.title .tag')[0].textContent.includes(job.status), 'Status');
assert.ok(findAll('.job-stats span')[0].textContent.includes(job.type), 'Type'); 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 // TODO: it would be better to not visit two different job pages in one test, but this
// way is much more convenient. // way is much more convenient.
job = server.create('job', { noActiveDeployment: true }); job = server.create('job', { noActiveDeployment: true, type: 'service' });
visit(`/jobs/${job.id}`); visit(`/jobs/${job.id}`);
andThen(() => { 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( test('the active deployment section shows up for the currently running deployment', function(
assert 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 deployment = server.db.deployments.where({ jobId: job.id })[0];
const taskGroupSummaries = server.db.deploymentTaskGroupSummaries.where({ const taskGroupSummaries = server.db.deploymentTaskGroupSummaries.where({
deploymentId: deployment.id, 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( test('the active deployment section can be expanded to show task groups and allocations', function(
assert assert
) { ) {
job = server.create('job', { activeDeployment: true }); job = server.create('job', { activeDeployment: true, type: 'service' });
visit(`/jobs/${job.id}`); visit(`/jobs/${job.id}`);
andThen(() => { andThen(() => {