Skip to content

Commit

Permalink
Only render job sidebar block if it has content
Browse files Browse the repository at this point in the history
Change sidebar's renderBlock() to return true only if
any of the block's <detail-row>s will be rendered
Change block to render only if renderBlock() returns true
  • Loading branch information
Miranda Fluharty authored and Alex Buijs committed Aug 2, 2019
1 parent 37736c3 commit 8d578ae
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
9 changes: 4 additions & 5 deletions app/assets/javascripts/jobs/components/sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,14 @@ export default {
},
renderBlock() {
return (
this.job.merge_request ||
this.job.duration ||
this.job.finished_data ||
this.job.finished_at ||
this.job.erased_at ||
this.job.queued ||
this.hasTimeout ||
this.job.runner ||
this.job.coverage ||
this.job.tags.length ||
this.job.cancel_path
this.job.tags.length
);
},
hasArtifact() {
Expand Down Expand Up @@ -160,7 +159,7 @@ export default {
</gl-link>
</div>

<div :class="{ block: renderBlock }">
<div v-if="renderBlock" class="block">
<detail-row
v-if="job.duration"
:value="duration"
Expand Down
5 changes: 5 additions & 0 deletions changelogs/unreleased/59521-job-sidebar-has-a-blank-block.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Remove blank block from job sidebar
merge_request: 30754
author:
type: fixed
25 changes: 25 additions & 0 deletions spec/javascripts/jobs/components/job_app_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,31 @@ describe('Job App ', () => {
});
});
});

describe('sidebar', () => {
it('has no blank blocks', done => {
mock.onGet(props.endpoint).replyOnce(
200,
Object.assign({}, job, {
duration: null,
finished_at: null,
erased_at: null,
queued: null,
runner: null,
coverage: null,
tags: [],
cancel_path: null,
}),
);

vm.$nextTick(() => {
vm.$el.querySelectorAll('.blocks-container > *').forEach(block => {
expect(block.textContent.trim()).not.toBe('');
});
done();
});
});
});
});

describe('archived job', () => {
Expand Down

0 comments on commit 8d578ae

Please sign in to comment.