Commit 148d630a authored by Alexander Turinske's avatar Alexander Turinske

Abstract out CSS logic for vulnerability filter

- create class that sets the filter immediately below the header
  and performance bar
- clean up computed property
- add tests
parent 55836b94
.security_dashboard_filters {
top: $header-height;
.with-performance-bar & {
top: $header-height + $performance-bar-height;
}
}
<script>
export default {
stickyHeight: process.env.NODE_ENV === 'development' ? '75px' : '40px',
computed: {
hasHeaderSlot() {
return Boolean(this.$slots.header);
......@@ -8,9 +7,6 @@ export default {
hasStickySlot() {
return Boolean(this.$slots.sticky);
},
stickyClasses() {
return this.hasStickySlot ? ['position-sticky', 'gl-z-index-2'] : [];
},
hasAsideSlot() {
return Boolean(this.$slots.aside);
},
......@@ -24,7 +20,7 @@ export default {
<slot name="header"></slot>
</header>
<section v-if="hasStickySlot" :class="stickyClasses" :style="{ top: $options.stickyHeight }">
<section v-if="hasStickySlot" class="position-sticky gl-z-index-2 security_dashboard_filters">
<slot name="sticky"></slot>
</section>
......
......@@ -17,6 +17,7 @@ describe('Security Dashboard Layout component', () => {
const findArticle = () => wrapper.find('article');
const findHeader = () => wrapper.find('header');
const findAside = () => wrapper.find('aside');
const findStickySection = () => wrapper.find('section');
afterEach(() => {
wrapper.destroy();
......@@ -30,10 +31,11 @@ describe('Security Dashboard Layout component', () => {
});
it.each`
element | exists
${'article'} | ${true}
${'header'} | ${false}
${'aside'} | ${false}
element | exists
${'article'} | ${true}
${'header'} | ${false}
${'aside'} | ${false}
${'section section'} | ${false}
`('should find that $element exists is $exists', ({ element, exists }) => {
expect(wrapper.find(element).exists()).toBe(exists);
});
......@@ -60,10 +62,11 @@ describe('Security Dashboard Layout component', () => {
});
it.each`
element | exists
${'article'} | ${true}
${'header'} | ${true}
${'aside'} | ${false}
element | exists
${'article'} | ${true}
${'header'} | ${true}
${'aside'} | ${false}
${'section section'} | ${false}
`('should find that $element exists is $exists', ({ element, exists }) => {
expect(wrapper.find(element).exists()).toBe(exists);
});
......@@ -80,6 +83,36 @@ describe('Security Dashboard Layout component', () => {
expect(header.find(DummyComponent).exists()).toBe(true);
});
});
describe('with the sticky section and main slots', () => {
beforeEach(() => {
createWrapper({
default: DummyComponent,
sticky: DummyComponent,
});
});
it.each`
element | exists
${'article'} | ${true}
${'header'} | ${false}
${'aside'} | ${false}
${'section section'} | ${true}
`('should find that $element exists is $exists', ({ element, exists }) => {
expect(wrapper.find(element).exists()).toBe(exists);
});
it('should render the dummy component in the main section', () => {
const article = findArticle();
expect(article.find(DummyComponent).exists()).toBe(true);
});
it('should render the dummy component in the sticky section', () => {
const section = findStickySection();
expect(section.find(DummyComponent).exists()).toBe(true);
});
});
describe('with the aside and main slots', () => {
beforeEach(() => {
......@@ -90,10 +123,11 @@ describe('Security Dashboard Layout component', () => {
});
it.each`
element | exists
${'article'} | ${true}
${'header'} | ${false}
${'aside'} | ${true}
element | exists
${'article'} | ${true}
${'header'} | ${false}
${'aside'} | ${true}
${'section section'} | ${false}
`('should find that $element exists is $exists', ({ element, exists }) => {
expect(wrapper.find(element).exists()).toBe(exists);
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment