2017-08-30 01:16:23 -04:00
|
|
|
<script>
|
2020-07-15 05:09:34 -04:00
|
|
|
import { GlLoadingIcon, GlIcon } from '@gitlab/ui';
|
2019-08-26 18:25:36 -04:00
|
|
|
|
2018-03-27 15:19:20 -04:00
|
|
|
export default {
|
2019-08-26 18:25:36 -04:00
|
|
|
components: {
|
2020-07-15 05:09:34 -04:00
|
|
|
GlLoadingIcon,
|
|
|
|
GlIcon,
|
2019-08-26 18:25:36 -04:00
|
|
|
},
|
2018-03-27 15:19:20 -04:00
|
|
|
props: {
|
|
|
|
name: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
2017-08-30 01:16:23 -04:00
|
|
|
},
|
2018-03-27 15:19:20 -04:00
|
|
|
showPanels: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: true,
|
|
|
|
},
|
2020-07-15 05:09:34 -04:00
|
|
|
isLoading: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
2019-12-11 04:08:12 -05:00
|
|
|
/**
|
|
|
|
* Initial value of collapse on mount.
|
|
|
|
*/
|
2019-07-23 23:18:57 -04:00
|
|
|
collapseGroup: {
|
|
|
|
type: Boolean,
|
2019-12-11 04:08:12 -05:00
|
|
|
required: false,
|
|
|
|
default: false,
|
2019-07-23 23:18:57 -04:00
|
|
|
},
|
2018-03-27 15:19:20 -04:00
|
|
|
},
|
2019-08-26 18:25:36 -04:00
|
|
|
data() {
|
|
|
|
return {
|
2019-12-11 04:08:12 -05:00
|
|
|
isCollapsed: this.collapseGroup,
|
2019-08-26 18:25:36 -04:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
caretIcon() {
|
2022-06-13 11:09:34 -04:00
|
|
|
return this.isCollapsed ? 'chevron-lg-right' : 'chevron-lg-down';
|
2019-12-11 04:08:12 -05:00
|
|
|
},
|
|
|
|
},
|
|
|
|
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-08-26 18:25:36 -04:00
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
collapse() {
|
2019-12-11 04:08:12 -05:00
|
|
|
this.isCollapsed = !this.isCollapsed;
|
2019-08-26 18:25:36 -04:00
|
|
|
},
|
|
|
|
},
|
2018-03-27 15:19:20 -04:00
|
|
|
};
|
2017-08-30 01:16:23 -04:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2020-07-09 17:09:33 -04:00
|
|
|
<div v-if="showPanels" ref="graph-group" class="card prometheus-panel">
|
2019-08-26 18:25:36 -04:00
|
|
|
<div class="card-header d-flex align-items-center">
|
|
|
|
<h4 class="flex-grow-1">{{ name }}</h4>
|
2021-07-07 05:08:35 -04:00
|
|
|
<gl-loading-icon v-if="isLoading" size="sm" name="loading" />
|
2020-05-25 05:08:30 -04:00
|
|
|
<a
|
|
|
|
data-testid="group-toggle-button"
|
2020-07-15 05:09:34 -04:00
|
|
|
:aria-label="__('Toggle collapse')"
|
|
|
|
:icon="caretIcon"
|
2020-05-25 05:08:30 -04:00
|
|
|
role="button"
|
2020-07-15 05:09:34 -04:00
|
|
|
class="js-graph-group-toggle gl-display-flex gl-ml-2 gl-text-gray-900"
|
2020-05-25 05:08:30 -04:00
|
|
|
tabindex="0"
|
|
|
|
@click="collapse"
|
|
|
|
@keyup.enter="collapse"
|
|
|
|
>
|
2020-07-15 05:09:34 -04:00
|
|
|
<gl-icon :name="caretIcon" />
|
2019-08-26 18:25:36 -04:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<div
|
2019-12-11 04:08:12 -05:00
|
|
|
v-show="!isCollapsed"
|
|
|
|
ref="graph-group-content"
|
2019-10-09 08:06:13 -04:00
|
|
|
class="card-body prometheus-graph-group p-0"
|
2019-08-26 18:25:36 -04:00
|
|
|
>
|
|
|
|
<slot></slot>
|
2017-08-30 01:16:23 -04:00
|
|
|
</div>
|
2018-02-22 03:55:29 -05:00
|
|
|
</div>
|
2019-12-11 04:08:12 -05:00
|
|
|
<div v-else ref="graph-group-content" class="prometheus-graph-group"><slot></slot></div>
|
2017-08-30 01:16:23 -04:00
|
|
|
</template>
|