Commit 71e44e7c authored by Clement Ho's avatar Clement Ho

Merge branch 'jivanvl-add-caret-icon-dashboard' into 'master'

Add caret icons to the monitoring dashboard

See merge request gitlab-org/gitlab-ce!32239
parents 96480a31 b5b2879e
<script> <script>
import Icon from '~/vue_shared/components/icon.vue';
export default { export default {
components: {
Icon,
},
props: { props: {
name: { name: {
type: String, type: String,
...@@ -15,15 +20,42 @@ export default { ...@@ -15,15 +20,42 @@ export default {
required: true, required: true,
}, },
}, },
data() {
return {
showGroup: true,
};
},
computed: {
caretIcon() {
return this.collapseGroup && this.showGroup ? 'angle-down' : 'angle-right';
},
},
created() {
this.showGroup = this.collapseGroup;
},
methods: {
collapse() {
this.showGroup = !this.showGroup;
},
},
}; };
</script> </script>
<template> <template>
<div v-if="showPanels" class="card prometheus-panel"> <div v-if="showPanels" class="card prometheus-panel">
<div class="card-header"> <div class="card-header d-flex align-items-center">
<h4>{{ name }}</h4> <h4 class="flex-grow-1">{{ name }}</h4>
<a role="button" @click="collapse">
<icon :size="16" :aria-label="__('Toggle collapse')" :name="caretIcon" />
</a>
</div>
<div
v-if="collapseGroup"
v-show="collapseGroup && showGroup"
class="card-body prometheus-graph-group"
>
<slot></slot>
</div> </div>
<div v-if="collapseGroup" class="card-body prometheus-graph-group"><slot></slot></div>
</div> </div>
<div v-else class="prometheus-graph-group"><slot></slot></div> <div v-else class="prometheus-graph-group"><slot></slot></div>
</template> </template>
---
title: Add caret icons to the monitoring dashboard
merge_request: 32239
author:
type: changed
...@@ -12308,6 +12308,9 @@ msgstr "" ...@@ -12308,6 +12308,9 @@ msgstr ""
msgid "Toggle backtrace" msgid "Toggle backtrace"
msgstr "" msgstr ""
msgid "Toggle collapse"
msgstr ""
msgid "Toggle comments for this file" msgid "Toggle comments for this file"
msgstr "" msgstr ""
......
import { shallowMount } from '@vue/test-utils';
import GraphGroup from '~/monitoring/components/graph_group.vue';
describe('Graph group component', () => {
let graphGroup;
afterEach(() => {
graphGroup.destroy();
});
describe('When groups can be collapsed', () => {
beforeEach(() => {
graphGroup = shallowMount(GraphGroup, {
propsData: {
name: 'panel',
collapseGroup: true,
},
});
});
it('should show the angle-down caret icon when collapseGroup is true', () => {
expect(graphGroup.vm.caretIcon).toBe('angle-down');
});
it('should show the angle-right caret icon when collapseGroup is false', () => {
graphGroup.vm.collapse();
expect(graphGroup.vm.caretIcon).toBe('angle-right');
});
});
describe('When groups can not be collapsed', () => {
beforeEach(() => {
graphGroup = shallowMount(GraphGroup, {
propsData: {
name: 'panel',
collapseGroup: true,
showPanels: false,
},
});
});
it('should not contain a prometheus-graph-group container when showPanels is false', () => {
expect(graphGroup.vm.$el.querySelector('.prometheus-graph-group')).toBe(null);
});
});
});
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