Commit 304dc086 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'dbodicherla-add-prop-to-hide-header-in-monitoring-dashboard' into 'master'

Added showHeader prop to monitor dashboard

See merge request gitlab-org/gitlab!23709
parents 4a2a4765 ae621612
...@@ -69,6 +69,11 @@ export default { ...@@ -69,6 +69,11 @@ export default {
required: false, required: false,
default: true, default: true,
}, },
showHeader: {
type: Boolean,
required: false,
default: true,
},
showPanels: { showPanels: {
type: Boolean, type: Boolean,
required: false, required: false,
...@@ -129,7 +134,8 @@ export default { ...@@ -129,7 +134,8 @@ export default {
}, },
environmentsEndpoint: { environmentsEndpoint: {
type: String, type: String,
required: true, required: false,
default: '',
}, },
currentEnvironmentName: { currentEnvironmentName: {
type: String, type: String,
...@@ -356,86 +362,88 @@ export default { ...@@ -356,86 +362,88 @@ export default {
<template> <template>
<div class="prometheus-graphs"> <div class="prometheus-graphs">
<div class="prometheus-graphs-header gl-p-3 pb-0 border-bottom bg-gray-light"> <div
v-if="showHeader"
ref="prometheusGraphsHeader"
class="prometheus-graphs-header gl-p-3 pb-0 border-bottom bg-gray-light"
>
<div class="row"> <div class="row">
<template v-if="environmentsEndpoint"> <gl-form-group
<gl-form-group :label="__('Dashboard')"
:label="__('Dashboard')" label-size="sm"
label-size="sm" label-for="monitor-dashboards-dropdown"
label-for="monitor-dashboards-dropdown" class="col-sm-12 col-md-6 col-lg-2"
class="col-sm-12 col-md-6 col-lg-2" >
> <dashboards-dropdown
<dashboards-dropdown id="monitor-dashboards-dropdown"
id="monitor-dashboards-dropdown" class="mb-0 d-flex"
class="mb-0 d-flex" toggle-class="dropdown-menu-toggle"
toggle-class="dropdown-menu-toggle" :default-branch="defaultBranch"
:default-branch="defaultBranch" :selected-dashboard="selectedDashboard"
:selected-dashboard="selectedDashboard" @selectDashboard="selectDashboard($event)"
@selectDashboard="selectDashboard($event)" />
/> </gl-form-group>
</gl-form-group>
<gl-form-group <gl-form-group
:label="s__('Metrics|Environment')" :label="s__('Metrics|Environment')"
label-size="sm" label-size="sm"
label-for="monitor-environments-dropdown" label-for="monitor-environments-dropdown"
class="col-sm-6 col-md-6 col-lg-2" class="col-sm-6 col-md-6 col-lg-2"
>
<gl-dropdown
id="monitor-environments-dropdown"
ref="monitorEnvironmentsDropdown"
data-qa-selector="environments_dropdown"
class="mb-0 d-flex"
toggle-class="dropdown-menu-toggle"
menu-class="monitor-environment-dropdown-menu"
:text="currentEnvironmentName"
:disabled="filteredEnvironments.length === 0"
> >
<gl-dropdown <div class="d-flex flex-column overflow-hidden">
id="monitor-environments-dropdown" <gl-search-box-by-type
ref="monitorEnvironmentsDropdown" v-if="shouldRenderSearchableEnvironmentsDropdown"
data-qa-selector="environments_dropdown" ref="monitorEnvironmentsDropdownSearch"
class="mb-0 d-flex" class="m-2"
toggle-class="dropdown-menu-toggle" @input="debouncedEnvironmentsSearch"
menu-class="monitor-environment-dropdown-menu" />
:text="currentEnvironmentName" <div class="flex-fill overflow-auto">
:disabled="filteredEnvironments.length === 0" <gl-dropdown-item
> v-for="environment in filteredEnvironments"
<div class="d-flex flex-column overflow-hidden"> :key="environment.id"
<gl-search-box-by-type :active="environment.name === currentEnvironmentName"
v-if="shouldRenderSearchableEnvironmentsDropdown" active-class="is-active"
ref="monitorEnvironmentsDropdownSearch" :href="environment.metrics_path"
class="m-2" >{{ environment.name }}</gl-dropdown-item
@input="debouncedEnvironmentsSearch"
/>
<div class="flex-fill overflow-auto">
<gl-dropdown-item
v-for="environment in filteredEnvironments"
:key="environment.id"
:active="environment.name === currentEnvironmentName"
active-class="is-active"
:href="environment.metrics_path"
>{{ environment.name }}</gl-dropdown-item
>
</div>
<div
v-if="shouldRenderSearchableEnvironmentsDropdown"
v-show="filteredEnvironments.length === 0"
ref="monitorEnvironmentsDropdownMsg"
class="text-secondary no-matches-message"
> >
{{ s__('No matching results') }}
</div>
</div> </div>
</gl-dropdown> <div
</gl-form-group> v-if="shouldRenderSearchableEnvironmentsDropdown"
v-show="filteredEnvironments.length === 0"
ref="monitorEnvironmentsDropdownMsg"
class="text-secondary no-matches-message"
>
{{ s__('No matching results') }}
</div>
</div>
</gl-dropdown>
</gl-form-group>
<gl-form-group <gl-form-group
:label="s__('Metrics|Show last')" :label="s__('Metrics|Show last')"
label-size="sm" label-size="sm"
label-for="monitor-time-window-dropdown" label-for="monitor-time-window-dropdown"
class="col-sm-6 col-md-6 col-lg-4" class="col-sm-6 col-md-6 col-lg-4"
> >
<date-time-picker <date-time-picker
ref="dateTimePicker" ref="dateTimePicker"
:start="startDate" :start="startDate"
:end="endDate" :end="endDate"
:time-windows="datePickerTimeWindows" :time-windows="datePickerTimeWindows"
@apply="onDateTimePickerApply" @apply="onDateTimePickerApply"
@invalid="onDateTimePickerInvalid" @invalid="onDateTimePickerInvalid"
/> />
</gl-form-group> </gl-form-group>
</template>
<gl-form-group <gl-form-group
v-if="hasHeaderButtons" v-if="hasHeaderButtons"
......
...@@ -7,11 +7,11 @@ export default () => { ...@@ -7,11 +7,11 @@ export default () => {
initCeBundle({ initCeBundle({
...el.dataset, ...el.dataset,
showLegend: false, showLegend: false,
showHeader: false,
showPanels: false, showPanels: false,
forceSmallGraph: true, forceSmallGraph: true,
smallEmptyState: true, smallEmptyState: true,
currentEnvironmentName: '', currentEnvironmentName: '',
environmentsEndpoint: '',
hasMetrics: true, hasMetrics: true,
}); });
} }
......
...@@ -412,13 +412,17 @@ describe('Dashboard', () => { ...@@ -412,13 +412,17 @@ describe('Dashboard', () => {
describe('cluster health', () => { describe('cluster health', () => {
beforeEach(done => { beforeEach(done => {
mock.onGet(propsData.metricsEndpoint).reply(statusCodes.OK, JSON.stringify({})); mock.onGet(propsData.metricsEndpoint).reply(statusCodes.OK, JSON.stringify({}));
createShallowWrapper({ hasMetrics: true }); createShallowWrapper({ hasMetrics: true, showHeader: false });
// all_dashboards is not defined in health dashboards // all_dashboards is not defined in health dashboards
wrapper.vm.$store.commit(`monitoringDashboard/${types.SET_ALL_DASHBOARDS}`, undefined); wrapper.vm.$store.commit(`monitoringDashboard/${types.SET_ALL_DASHBOARDS}`, undefined);
wrapper.vm.$nextTick(done); wrapper.vm.$nextTick(done);
}); });
it('hides dashboard header by default', () => {
expect(wrapper.find({ ref: 'prometheusGraphsHeader' }).exists()).toEqual(false);
});
it('renders correctly', () => { it('renders correctly', () => {
expect(wrapper.isVueInstance()).toBe(true); expect(wrapper.isVueInstance()).toBe(true);
expect(wrapper.exists()).toBe(true); expect(wrapper.exists()).toBe(true);
......
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