Commit 16628afa authored by Clement Ho's avatar Clement Ho

Merge branch 'jivanvl-updated-embed-charts-component' into 'master'

Update the monitoring/embed.vue component

See merge request gitlab-org/gitlab!19787
parents 16f64fa1 93a56ba0
...@@ -18,8 +18,6 @@ import Icon from '~/vue_shared/components/icon.vue'; ...@@ -18,8 +18,6 @@ import Icon from '~/vue_shared/components/icon.vue';
import { getParameterValues, mergeUrlParams, redirectTo } from '~/lib/utils/url_utility'; import { getParameterValues, mergeUrlParams, redirectTo } from '~/lib/utils/url_utility';
import invalidUrl from '~/lib/utils/invalid_url'; import invalidUrl from '~/lib/utils/invalid_url';
import DateTimePicker from './date_time_picker/date_time_picker.vue'; import DateTimePicker from './date_time_picker/date_time_picker.vue';
import MonitorTimeSeriesChart from './charts/time_series.vue';
import MonitorSingleStatChart from './charts/single_stat.vue';
import GraphGroup from './graph_group.vue'; import GraphGroup from './graph_group.vue';
import EmptyState from './empty_state.vue'; import EmptyState from './empty_state.vue';
import TrackEventDirective from '~/vue_shared/directives/track_event'; import TrackEventDirective from '~/vue_shared/directives/track_event';
...@@ -28,8 +26,6 @@ import { getTimeDiff, isValidDate, getAddMetricTrackingOptions } from '../utils' ...@@ -28,8 +26,6 @@ import { getTimeDiff, isValidDate, getAddMetricTrackingOptions } from '../utils'
export default { export default {
components: { components: {
VueDraggable, VueDraggable,
MonitorTimeSeriesChart,
MonitorSingleStatChart,
PanelType, PanelType,
GraphGroup, GraphGroup,
EmptyState, EmptyState,
......
<script> <script>
import { mapActions, mapState } from 'vuex'; import { mapActions, mapState } from 'vuex';
import { getParameterValues, removeParams } from '~/lib/utils/url_utility'; import { getParameterValues, removeParams } from '~/lib/utils/url_utility';
import PanelType from 'ee_else_ce/monitoring/components/panel_type.vue';
import GraphGroup from './graph_group.vue'; import GraphGroup from './graph_group.vue';
import MonitorTimeSeriesChart from './charts/time_series.vue';
import { sidebarAnimationDuration } from '../constants'; import { sidebarAnimationDuration } from '../constants';
import { getTimeDiff } from '../utils'; import { getTimeDiff } from '../utils';
...@@ -11,7 +11,7 @@ let sidebarMutationObserver; ...@@ -11,7 +11,7 @@ let sidebarMutationObserver;
export default { export default {
components: { components: {
GraphGroup, GraphGroup,
MonitorTimeSeriesChart, PanelType,
}, },
props: { props: {
dashboardUrl: { dashboardUrl: {
...@@ -92,16 +92,13 @@ export default { ...@@ -92,16 +92,13 @@ export default {
<template> <template>
<div class="metrics-embed" :class="{ 'd-inline-flex col-lg-6 p-0': isSingleChart }"> <div class="metrics-embed" :class="{ 'd-inline-flex col-lg-6 p-0': isSingleChart }">
<div v-if="charts.length" class="row w-100 m-n2 pb-4"> <div v-if="charts.length" class="row w-100 m-n2 pb-4">
<monitor-time-series-chart <panel-type
v-for="graphData in charts" v-for="(graphData, graphIndex) in charts"
:key="graphData.title" :key="`panel-type-${graphIndex}`"
class="w-100" class="w-100"
clipboard-text=""
:graph-data="graphData" :graph-data="graphData"
:container-width="elWidth"
:group-id="dashboardUrl" :group-id="dashboardUrl"
:project-path="null"
:show-border="true"
:single-embed="isSingleChart"
/> />
</div> </div>
</div> </div>
......
...@@ -47,6 +47,11 @@ export default { ...@@ -47,6 +47,11 @@ export default {
required: false, required: false,
default: '', default: '',
}, },
groupId: {
type: String,
required: false,
default: 'panel-type-chart',
},
}, },
computed: { computed: {
...mapState('monitoringDashboard', ['deploymentData', 'projectPath']), ...mapState('monitoringDashboard', ['deploymentData', 'projectPath']),
...@@ -117,7 +122,7 @@ export default { ...@@ -117,7 +122,7 @@ export default {
:deployment-data="deploymentData" :deployment-data="deploymentData"
:project-path="projectPath" :project-path="projectPath"
:thresholds="getGraphAlertValues(graphData.metrics)" :thresholds="getGraphAlertValues(graphData.metrics)"
group-id="panel-type-chart" :group-id="groupId"
> >
<div class="d-flex align-items-center"> <div class="d-flex align-items-center">
<alert-widget <alert-widget
......
...@@ -20,6 +20,11 @@ export default { ...@@ -20,6 +20,11 @@ export default {
required: false, required: false,
default: false, default: false,
}, },
groupId: {
type: String,
required: false,
default: 'panel-type-chart',
},
}, },
data() { data() {
return { return {
......
import { createLocalVue, shallowMount } from '@vue/test-utils'; import { createLocalVue, shallowMount } from '@vue/test-utils';
import Vuex from 'vuex'; import Vuex from 'vuex';
import Embed from '~/monitoring/components/embed.vue'; import Embed from '~/monitoring/components/embed.vue';
import MonitorTimeSeriesChart from '~/monitoring/components/charts/time_series.vue'; import PanelType from 'ee_else_ce/monitoring/components/panel_type.vue';
import { TEST_HOST } from 'helpers/test_constants'; import { TEST_HOST } from 'helpers/test_constants';
import { groups, initialState, metricsData, metricsWithData } from './mock_data'; import { groups, initialState, metricsData, metricsWithData } from './mock_data';
...@@ -55,7 +55,7 @@ describe('Embed', () => { ...@@ -55,7 +55,7 @@ describe('Embed', () => {
it('shows an empty state when no metrics are present', () => { it('shows an empty state when no metrics are present', () => {
expect(wrapper.find('.metrics-embed').exists()).toBe(true); expect(wrapper.find('.metrics-embed').exists()).toBe(true);
expect(wrapper.find(MonitorTimeSeriesChart).exists()).toBe(false); expect(wrapper.find(PanelType).exists()).toBe(false);
}); });
}); });
...@@ -71,12 +71,12 @@ describe('Embed', () => { ...@@ -71,12 +71,12 @@ describe('Embed', () => {
it('shows a chart when metrics are present', () => { it('shows a chart when metrics are present', () => {
wrapper.setProps({}); wrapper.setProps({});
expect(wrapper.find('.metrics-embed').exists()).toBe(true); expect(wrapper.find('.metrics-embed').exists()).toBe(true);
expect(wrapper.find(MonitorTimeSeriesChart).exists()).toBe(true); expect(wrapper.find(PanelType).exists()).toBe(true);
expect(wrapper.findAll(MonitorTimeSeriesChart).length).toBe(2); expect(wrapper.findAll(PanelType).length).toBe(2);
}); });
it('includes groupId with dashboardUrl', () => { it('includes groupId with dashboardUrl', () => {
expect(wrapper.find(MonitorTimeSeriesChart).props('groupId')).toBe(TEST_HOST); expect(wrapper.find(PanelType).props('groupId')).toBe(TEST_HOST);
}); });
}); });
}); });
...@@ -102,6 +102,10 @@ describe('Panel Type component', () => { ...@@ -102,6 +102,10 @@ describe('Panel Type component', () => {
expect(clipboardText()).toBe(exampleText); expect(clipboardText()).toBe(exampleText);
}); });
it('includes a default group id', () => {
expect(panelType.vm.groupId).toBe('panel-type-chart');
});
}); });
describe('Anomaly Chart panel type', () => { describe('Anomaly Chart panel type', () => {
......
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