[ui] Remove unnecessary subnav for parent jobs (#17190)

* Nest job subnav in a parent-check

* Move the evaluation tab test to withn an else of the children condition
This commit is contained in:
Phil Renaud 2023-05-16 16:07:12 -04:00 committed by GitHub
parent 2426aae832
commit 817b2cab9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 51 additions and 42 deletions

View File

@ -16,4 +16,11 @@ export default class JobSubnav extends Component {
job?.hasClientStatus && !job?.hasChildren && this.can.can('read client')
);
}
// Periodic and Parameterized jobs "parents" are not jobs unto themselves, but more like summaries.
// They should not have tabs for allocations, evaluations, etc.
// but their child jobs, and other job types generally, should.
get shouldHideNonParentTabs() {
return this.args.job?.hasChildren;
}
}

View File

@ -44,43 +44,45 @@
</LinkTo>
</li>
{{/if}}
<li data-test-tab="allocations">
<LinkTo
@route="jobs.job.allocations"
@model={{format-job-id @job.id}}
@activeClass="is-active"
>
Allocations
</LinkTo>
</li>
<li data-test-tab="evaluations">
<LinkTo
@route="jobs.job.evaluations"
@model={{@job}}
@activeClass="is-active"
>
Evaluations
</LinkTo>
</li>
{{#if this.shouldRenderClientsTab}}
<li data-test-tab="clients">
{{#unless this.shouldHideNonParentTabs}}
<li data-test-tab="allocations">
<LinkTo
@route="jobs.job.clients"
@route="jobs.job.allocations"
@model={{format-job-id @job.id}}
@activeClass="is-active"
>
Allocations
</LinkTo>
</li>
<li data-test-tab="evaluations">
<LinkTo
@route="jobs.job.evaluations"
@model={{@job}}
@activeClass="is-active"
>
Clients
Evaluations
</LinkTo>
</li>
{{/if}}
<li data-test-tab="services">
<LinkTo
@route="jobs.job.services"
@model={{@job}}
@activeClass="is-active"
>
Services
</LinkTo>
</li>
{{#if this.shouldRenderClientsTab}}
<li data-test-tab="clients">
<LinkTo
@route="jobs.job.clients"
@model={{@job}}
@activeClass="is-active"
>
Clients
</LinkTo>
</li>
{{/if}}
<li data-test-tab="services">
<LinkTo
@route="jobs.job.services"
@model={{@job}}
@activeClass="is-active"
>
Services
</LinkTo>
</li>
{{/unless}}
</ul>
</div>

View File

@ -101,16 +101,6 @@ export default function moduleForJob(
assert.equal(decodeURIComponent(currentURL()), expectedURL);
});
test('the subnav links to evaluations', async function (assert) {
await JobDetail.tabFor('evaluations').visit();
const expectedURL = job.namespace
? `/jobs/${job.name}@${job.namespace}/evaluations`
: `/jobs/${job.name}/evaluations`;
assert.equal(decodeURIComponent(currentURL()), expectedURL);
});
test('the title buttons are dependent on job status', async function (assert) {
if (job.status === 'dead') {
assert.ok(JobDetail.start.isPresent);
@ -229,6 +219,16 @@ export default function moduleForJob(
'Allocations are not shown in the summary section'
);
});
} else {
test('the subnav links to evaluations', async function (assert) {
await JobDetail.tabFor('evaluations').visit();
const expectedURL = job.namespace
? `/jobs/${job.name}@${job.namespace}/evaluations`
: `/jobs/${job.name}/evaluations`;
assert.equal(decodeURIComponent(currentURL()), expectedURL);
});
}
for (var testName in additionalTests) {