Commit 45afd801 authored by Simon Knox's avatar Simon Knox

Remove EE differences from monitoring/dashboard.vue

Remove dashboard_mixin - use EE component instead
We alreay know whether to showEnvironmentDropdown
Can infer this from whether or not the endpoint is passed
parent def97bf8
<script> <script>
// ee-only
import DashboardMixin from 'ee/monitoring/components/dashboard_mixin';
import { GlDropdown, GlDropdownItem } from '@gitlab/ui'; import { GlDropdown, GlDropdownItem } from '@gitlab/ui';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import '~/vue_shared/mixins/is_ee';
import Flash from '../../flash'; import Flash from '../../flash';
import MonitoringService from '../services/monitoring_service'; import MonitoringService from '../services/monitoring_service';
import MonitorAreaChart from './charts/area.vue'; import MonitorAreaChart from './charts/area.vue';
...@@ -24,9 +23,6 @@ export default { ...@@ -24,9 +23,6 @@ export default {
GlDropdownItem, GlDropdownItem,
}, },
// ee-only
mixins: [DashboardMixin],
props: { props: {
hasMetrics: { hasMetrics: {
type: Boolean, type: Boolean,
...@@ -91,11 +87,6 @@ export default { ...@@ -91,11 +87,6 @@ export default {
type: String, type: String,
required: true, required: true,
}, },
showEnvironmentDropdown: {
type: Boolean,
required: false,
default: true,
},
}, },
data() { data() {
return { return {
...@@ -131,7 +122,7 @@ export default { ...@@ -131,7 +122,7 @@ export default {
if (!this.hasMetrics) { if (!this.hasMetrics) {
this.state = 'gettingStarted'; this.state = 'gettingStarted';
} else { } else {
if (this.showEnvironmentDropdown) { if (this.environmentsEndpoint) {
this.servicePromises.push( this.servicePromises.push(
this.service this.service
.getEnvironmentsData() .getEnvironmentsData()
...@@ -180,7 +171,7 @@ export default { ...@@ -180,7 +171,7 @@ export default {
<template> <template>
<div v-if="!showEmptyState" class="prometheus-graphs prepend-top-default"> <div v-if="!showEmptyState" class="prometheus-graphs prepend-top-default">
<div v-if="showEnvironmentDropdown" class="environments d-flex align-items-center"> <div v-if="environmentsEndpoint" class="environments d-flex align-items-center">
<strong>{{ s__('Metrics|Environment') }}</strong> <strong>{{ s__('Metrics|Environment') }}</strong>
<gl-dropdown <gl-dropdown
class="prepend-left-10 js-environments-dropdown" class="prepend-left-10 js-environments-dropdown"
...@@ -212,9 +203,8 @@ export default { ...@@ -212,9 +203,8 @@ export default {
:container-width="elWidth" :container-width="elWidth"
group-id="monitor-area-chart" group-id="monitor-area-chart"
> >
<!-- EE content -->
<alert-widget <alert-widget
v-if="prometheusAlertsAvailable && alertsEndpoint && graphData.id" v-if="isEE && prometheusAlertsAvailable && alertsEndpoint && graphData.id"
:alerts-endpoint="alertsEndpoint" :alerts-endpoint="alertsEndpoint"
:label="getGraphLabel(graphData)" :label="getGraphLabel(graphData)"
:current-alerts="getQueryAlerts(graphData)" :current-alerts="getQueryAlerts(graphData)"
......
<script>
import CeDashboard from '~/monitoring/components/dashboard.vue';
import AlertWidget from './alert_widget.vue'; import AlertWidget from './alert_widget.vue';
export default { export default {
components: { components: {
AlertWidget, AlertWidget,
}, },
extends: CeDashboard,
props: { props: {
alertsEndpoint: { alertsEndpoint: {
type: String, type: String,
...@@ -35,3 +38,4 @@ export default { ...@@ -35,3 +38,4 @@ export default {
}, },
}, },
}; };
</script>
import Vue from 'vue'; import Vue from 'vue';
import { parseBoolean } from '~/lib/utils/common_utils'; import { parseBoolean } from '~/lib/utils/common_utils';
import Dashboard from '~/monitoring/components/dashboard.vue'; import Dashboard from './components/dashboard.vue';
export default () => { export default () => {
const el = document.getElementById('prometheus-graphs'); const el = document.getElementById('prometheus-graphs');
......
...@@ -15,7 +15,6 @@ export default () => { ...@@ -15,7 +15,6 @@ export default () => {
showLegend: false, showLegend: false,
showPanels: false, showPanels: false,
forceSmallGraph: true, forceSmallGraph: true,
showEnvironmentDropdown: false,
currentEnvironmentName: '', currentEnvironmentName: '',
environmentsEndpoint: '', environmentsEndpoint: '',
}, },
......
import { shallowMount, createLocalVue } from '@vue/test-utils'; import { shallowMount, createLocalVue } from '@vue/test-utils';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import Dashboard from '~/monitoring/components/dashboard.vue'; import Dashboard from 'ee/monitoring/components/dashboard.vue';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { metricsGroupsAPIResponse, mockApiEndpoint } from 'spec/monitoring/mock_data'; import { metricsGroupsAPIResponse, mockApiEndpoint } from 'spec/monitoring/mock_data';
import propsData from 'spec/monitoring/dashboard_spec'; import propsData from 'spec/monitoring/dashboard_spec';
...@@ -17,6 +17,12 @@ describe('Dashboard', () => { ...@@ -17,6 +17,12 @@ describe('Dashboard', () => {
<div class="prometheus-graphs"></div> <div class="prometheus-graphs"></div>
<div class="layout-page"></div> <div class="layout-page"></div>
`); `);
window.gon = {
...window.gon,
ee: true,
};
mock = new MockAdapter(axios); mock = new MockAdapter(axios);
Component = localVue.extend(Dashboard); Component = localVue.extend(Dashboard);
}); });
......
...@@ -33,6 +33,11 @@ describe('Dashboard', () => { ...@@ -33,6 +33,11 @@ describe('Dashboard', () => {
<div class="layout-page"></div> <div class="layout-page"></div>
`); `);
window.gon = {
...window.gon,
ee: false,
};
mock = new MockAdapter(axios); mock = new MockAdapter(axios);
DashboardComponent = Vue.extend(Dashboard); DashboardComponent = Vue.extend(Dashboard);
}); });
...@@ -160,7 +165,7 @@ describe('Dashboard', () => { ...@@ -160,7 +165,7 @@ describe('Dashboard', () => {
...propsData, ...propsData,
hasMetrics: true, hasMetrics: true,
showPanels: false, showPanels: false,
showEnvironmentDropdown: false, environmentsEndpoint: '',
}, },
}); });
......
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