2018-03-17 18:26:18 +05:30
|
|
|
<script>
|
2019-12-04 20:38:33 +05:30
|
|
|
import Icon from '~/vue_shared/components/icon.vue';
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
export default {
|
2019-12-04 20:38:33 +05:30
|
|
|
components: {
|
|
|
|
Icon,
|
|
|
|
},
|
2018-05-09 12:01:36 +05:30
|
|
|
props: {
|
|
|
|
name: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2018-05-09 12:01:36 +05:30
|
|
|
showPanels: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: true,
|
|
|
|
},
|
2020-01-01 13:55:28 +05:30
|
|
|
/**
|
|
|
|
* Initial value of collapse on mount.
|
|
|
|
*/
|
2019-10-12 21:52:04 +05:30
|
|
|
collapseGroup: {
|
|
|
|
type: Boolean,
|
2020-01-01 13:55:28 +05:30
|
|
|
required: false,
|
|
|
|
default: false,
|
2019-10-12 21:52:04 +05:30
|
|
|
},
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
2019-12-04 20:38:33 +05:30
|
|
|
data() {
|
|
|
|
return {
|
2020-01-01 13:55:28 +05:30
|
|
|
isCollapsed: this.collapseGroup,
|
2019-12-04 20:38:33 +05:30
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
caretIcon() {
|
2020-01-01 13:55:28 +05:30
|
|
|
return this.isCollapsed ? 'angle-right' : 'angle-down';
|
2019-12-04 20:38:33 +05:30
|
|
|
},
|
|
|
|
},
|
2020-01-01 13:55:28 +05:30
|
|
|
watch: {
|
|
|
|
collapseGroup(val) {
|
|
|
|
// Respond to changes in collapseGroup but do not
|
|
|
|
// collapse it once was opened by the user.
|
|
|
|
if (this.showPanels && !val) {
|
|
|
|
this.isCollapsed = false;
|
|
|
|
}
|
|
|
|
},
|
2019-12-04 20:38:33 +05:30
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
collapse() {
|
2020-01-01 13:55:28 +05:30
|
|
|
this.isCollapsed = !this.isCollapsed;
|
2019-12-04 20:38:33 +05:30
|
|
|
},
|
|
|
|
},
|
2018-05-09 12:01:36 +05:30
|
|
|
};
|
2018-03-17 18:26:18 +05:30
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2020-06-23 00:09:42 +05:30
|
|
|
<div v-if="showPanels" ref="graph-group" class="card prometheus-panel" tabindex="0">
|
2019-12-04 20:38:33 +05:30
|
|
|
<div class="card-header d-flex align-items-center">
|
|
|
|
<h4 class="flex-grow-1">{{ name }}</h4>
|
2020-06-23 00:09:42 +05:30
|
|
|
<a
|
|
|
|
data-testid="group-toggle-button"
|
|
|
|
role="button"
|
|
|
|
class="js-graph-group-toggle gl-text-gray-900"
|
|
|
|
tabindex="0"
|
|
|
|
@click="collapse"
|
|
|
|
@keyup.enter="collapse"
|
|
|
|
>
|
2019-12-04 20:38:33 +05:30
|
|
|
<icon :size="16" :aria-label="__('Toggle collapse')" :name="caretIcon" />
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<div
|
2020-01-01 13:55:28 +05:30
|
|
|
v-show="!isCollapsed"
|
|
|
|
ref="graph-group-content"
|
2019-12-21 20:55:43 +05:30
|
|
|
class="card-body prometheus-graph-group p-0"
|
2019-12-04 20:38:33 +05:30
|
|
|
>
|
|
|
|
<slot></slot>
|
2018-03-17 18:26:18 +05:30
|
|
|
</div>
|
2018-03-27 19:54:05 +05:30
|
|
|
</div>
|
2020-01-01 13:55:28 +05:30
|
|
|
<div v-else ref="graph-group-content" class="prometheus-graph-group"><slot></slot></div>
|
2018-03-17 18:26:18 +05:30
|
|
|
</template>
|